From 08a54bd3f54af67252fd547889a7950d5d0bf1a1 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Wed, 20 Oct 2021 20:57:12 +0100 Subject: [PATCH] desktop: use correct coordinates layer_surface_at() Use output coordinates rather than layout coordinates in order to correctly handle pointer button event on multi-output setup. --- src/desktop.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/desktop.c b/src/desktop.c index 59999091..9f3791c6 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -264,13 +264,13 @@ _view_at(struct view *view, double lx, double ly, struct wlr_surface **surface, } static struct -wlr_surface *layer_surface_at(struct wl_list *layer, double lx, double ly, +wlr_surface *layer_surface_at(struct wl_list *layer, double ox, double oy, double *sx, double *sy) { struct lab_layer_surface *surface; wl_list_for_each_reverse(surface, layer, link) { - double _sx = lx - surface->geo.x; - double _sy = ly - surface->geo.y; + double _sx = ox - surface->geo.x; + double _sy = oy - surface->geo.y; struct wlr_surface *wlr_surface; wlr_surface = wlr_layer_surface_v1_surface_at(surface->layer_surface, _sx, _sy, sx, sy); @@ -294,16 +294,19 @@ desktop_surface_and_view_at(struct server *server, double lx, double ly, return NULL; } + double ox = lx, oy = ly; + wlr_output_layout_output_coords(output->server->output_layout, + wlr_output, &ox, &oy); *surface = layer_surface_at( &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], - lx, ly, sx, sy); + ox, oy, sx, sy); if (*surface) { return NULL; } *surface = layer_surface_at( &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], - lx, ly, sx, sy); + ox, oy, sx, sy); if (*surface) { return NULL; } @@ -327,13 +330,13 @@ desktop_surface_and_view_at(struct server *server, double lx, double ly, *surface = layer_surface_at( &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], - lx, ly, sx, sy); + ox, oy, sx, sy); if (*surface) { return NULL; } *surface = layer_surface_at( &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], - lx, ly, sx, sy); + ox, oy, sx, sy); if (*surface) { return NULL; }