From 26e1812ab3eb75ba5c13f1a4060dd74fb4c93263 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Tue, 30 Aug 2022 19:22:33 +0300 Subject: [PATCH] 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. --- types/wlr_output_layout.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 275f87d74..37c57fc66 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -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;