aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2023-01-21 14:02:27 +0300
committerSimon Ser <contact@emersion.fr>2023-01-21 12:48:43 +0000
commit843b874f22b87140a04bfc279852e025967c055e (patch)
tree399b35f1ea51a0508dc302e06069ca5738672a2b
parent377668aaf6f2d8d0cb11895c4a884c7cfdfe08b6 (diff)
output-layout: improve closest point for no outputs case
Without outputs, all points are equally invalid anyway, but for e.g. cursor warping it makes more sense to preserve the original position.
-rw-r--r--include/wlr/types/wlr_output_layout.h1
-rw-r--r--types/wlr_output_layout.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h
index 7d567579..bb73958e 100644
--- a/include/wlr/types/wlr_output_layout.h
+++ b/include/wlr/types/wlr_output_layout.h
@@ -120,6 +120,7 @@ bool wlr_output_layout_intersects(struct wlr_output_layout *layout,
/**
* Get the closest point on this layout from the given point from the reference
* output. If reference is NULL, gets the closest point from the entire layout.
+ * If the layout is empty, the result is the given point itself.
*/
void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
struct wlr_output *reference, double lx, double ly,
diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c
index 83be909c..974e6a74 100644
--- a/types/wlr_output_layout.c
+++ b/types/wlr_output_layout.c
@@ -302,7 +302,7 @@ void wlr_output_layout_closest_point(struct wlr_output_layout *layout,
return;
}
- double min_x = 0, min_y = 0, min_distance = DBL_MAX;
+ double min_x = lx, min_y = ly, min_distance = DBL_MAX;
struct wlr_output_layout_output *l_output;
wl_list_for_each(l_output, &layout->outputs, link) {
if (reference != NULL && reference != l_output->output) {