From 3799606fc2324f3b9c6f4cfb6f79cdebafe624b0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Feb 2021 20:19:38 +0100 Subject: [PATCH] wayland: Make XDnD grab unlink source/offer manually This currently happens by default whenever the grab is finished. We want to eventually do this manually everywhere, so start here. Part-of: --- src/wayland/meta-xwayland-dnd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/wayland/meta-xwayland-dnd.c b/src/wayland/meta-xwayland-dnd.c index 7f19be24c..77bf56783 100644 --- a/src/wayland/meta-xwayland-dnd.c +++ b/src/wayland/meta-xwayland-dnd.c @@ -340,14 +340,22 @@ xdnd_send_status (MetaXWaylandDnd *dnd, } static void -meta_xwayland_end_dnd_grab (MetaWaylandDataDevice *data_device) +meta_xwayland_end_dnd_grab (MetaWaylandDataDevice *data_device, + gboolean success) { Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default (); MetaXWaylandManager *manager = &compositor->xwayland_manager; + MetaWaylandDragGrab *drag_grab = compositor->seat->data_device.current_grab; MetaXWaylandDnd *dnd = manager->dnd; - meta_wayland_data_device_end_drag (data_device); + if (drag_grab) + { + if (!success && dnd->source) + meta_wayland_data_source_set_current_offer (dnd->source, NULL); + + meta_wayland_data_device_end_drag (data_device); + } XMoveResizeWindow (xdisplay, dnd->dnd_window, -1, -1, 1, 1); XUnmapWindow (xdisplay, dnd->dnd_window); @@ -717,7 +725,7 @@ drag_xgrab_button (MetaWaylandPointerGrab *grab, (!meta_wayland_drag_grab_get_focus ((MetaWaylandDragGrab *) grab) || meta_wayland_data_source_get_current_action (data_source) == WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE)) - meta_xwayland_end_dnd_grab (&seat->data_device); + meta_xwayland_end_dnd_grab (&seat->data_device, FALSE); } static const MetaWaylandPointerGrabInterface drag_xgrab_interface = { @@ -861,7 +869,7 @@ meta_xwayland_dnd_handle_client_message (MetaWaylandCompositor *compositor, { dnd->client_message_timestamp = event->data.l[2]; meta_wayland_surface_drag_dest_drop (drag_focus); - meta_xwayland_end_dnd_grab (&seat->data_device); + meta_xwayland_end_dnd_grab (&seat->data_device, TRUE); return TRUE; } } @@ -900,7 +908,7 @@ meta_xwayland_dnd_handle_xfixes_selection_notify (MetaWaylandCompositor *composi } else if (event->owner == None) { - meta_xwayland_end_dnd_grab (data_device); + meta_xwayland_end_dnd_grab (data_device, FALSE); } return FALSE;