From 988b9de210a92f4326f4c9c4a8d010050b4fc003 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Nov 2023 23:35:45 +0100 Subject: [PATCH] gdk/wayland: Pass surface-relative coordinates in DnD events Make this event behave like the other regular events, and emit coordinates based on native surfaces. Fixes DnD over popovers finding the correct coordinates. --- gdk/wayland/gdkseat-wayland.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/gdk/wayland/gdkseat-wayland.c b/gdk/wayland/gdkseat-wayland.c index f44258a05b..bad02169d6 100644 --- a/gdk/wayland/gdkseat-wayland.c +++ b/gdk/wayland/gdkseat-wayland.c @@ -345,7 +345,6 @@ data_device_enter (void *data, GdkWaylandSeat *seat = data; GdkSurface *dest_surface; GdkContentFormats *formats; - int origin_x, origin_y; GdkDevice *device; dest_surface = wl_surface_get_user_data (surface); @@ -392,12 +391,10 @@ data_device_enter (void *data, gdk_wayland_seat_discard_pending_offer (seat); - gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y); - gdk_drop_emit_enter_event (seat->drop, FALSE, - origin_x + seat->pointer_info.surface_x, - origin_y + seat->pointer_info.surface_y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, GDK_CURRENT_TIME); } @@ -431,7 +428,6 @@ data_device_motion (void *data, wl_fixed_t y) { GdkWaylandSeat *seat = data; - int origin_x, origin_y; GDK_SEAT_DEBUG (seat, EVENTS, "data device motion, data_device = %p, time = %d, x = %f, y = %f", @@ -444,12 +440,10 @@ data_device_motion (void *data, seat->pointer_info.surface_x = wl_fixed_to_double (x); seat->pointer_info.surface_y = wl_fixed_to_double (y); - gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y); - gdk_drop_emit_motion_event (seat->drop, FALSE, - origin_x + seat->pointer_info.surface_x, - origin_y + seat->pointer_info.surface_y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, time); } @@ -458,17 +452,14 @@ data_device_drop (void *data, struct wl_data_device *data_device) { GdkWaylandSeat *seat = data; - int origin_x, origin_y; GDK_SEAT_DEBUG (seat, EVENTS, "data device drop, data device %p", data_device); - gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y); - gdk_drop_emit_drop_event (seat->drop, FALSE, - origin_x + seat->pointer_info.surface_x, - origin_y + seat->pointer_info.surface_y, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, GDK_CURRENT_TIME); }