output-layout: improve wlr_output_layout_output_in_direction()

Now the function checks if the reference output belongs to the layout,
and returns NULL if it doesn't.
This commit is contained in:
Kirill Primak 2022-08-30 19:22:33 +03:00
parent 2ea80eb115
commit 26e1812ab3
1 changed files with 4 additions and 0 deletions

View File

@ -459,6 +459,10 @@ static struct wlr_output *wlr_output_layout_output_in_direction(
struct wlr_box ref_box;
wlr_output_layout_get_box(layout, reference, &ref_box);
if (wlr_box_empty(&ref_box)) {
// The output doesn't belong to the layout
return NULL;
}
double min_distance = (distance_method == NEAREST) ? DBL_MAX : DBL_MIN;
struct wlr_output *closest_output = NULL;