From b1d95438d697431d23cf06e5c0778bddbd03eb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 6 Sep 2016 18:49:03 +0800 Subject: [PATCH] wayland/xwayland: Gracefully handle Xdnd start drag focus race If a X11 client would initiate a Xdnd session after it had lost pointer focus (for example when the Xdnd event starting the drag happens after the implicit pointer grab is already broken due to the button being released), just end the drag operation instead of dereferencing the non-existing focus surface. Also avoid using a native Wayland surface as a drag origin, as that can never happen, but allow any arbitrary Xwayland client, since there is no way to find out the actual drag origin. https://bugzilla.gnome.org/show_bug.cgi?id=770940 --- src/wayland/meta-xwayland-selection.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c index c346ba8ab..5735fe438 100644 --- a/src/wayland/meta-xwayland-selection.c +++ b/src/wayland/meta-xwayland-selection.c @@ -33,7 +33,9 @@ #include #include #include + #include +#include "meta-xwayland.h" #include "meta-xwayland-private.h" #include "meta-xwayland-selection-private.h" #include "meta-wayland-data-device.h" @@ -1584,14 +1586,14 @@ meta_xwayland_selection_handle_xfixes_selection_notify (MetaWaylandCompositor *c { MetaWaylandDataDevice *data_device = &compositor->seat->data_device; MetaXWaylandSelection *selection_data = compositor->xwayland_manager.selection_data; + MetaWaylandSurface *focus; selection->owner = event->owner; + focus = compositor->seat->pointer->focus_surface; - if (event->owner != None && event->owner != selection->window) + if (event->owner != None && event->owner != selection->window && + focus && meta_xwayland_is_xwayland_surface (focus)) { - MetaWaylandSurface *focus; - - focus = compositor->seat->pointer->focus_surface; selection->source = meta_wayland_data_source_xwayland_new (selection); meta_wayland_data_device_set_dnd_source (&compositor->seat->data_device, selection->source);