[mutter] wayland/xwayland: Gracefully handle Xdnd start drag focus race



commit b1d95438d697431d23cf06e5c0778bddbd03eb88
Author: Jonas Ådahl <jadahl gmail com>
Date:   Tue Sep 6 18:49:03 2016 +0800

    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 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c
index c346ba8..5735fe4 100644
--- a/src/wayland/meta-xwayland-selection.c
+++ b/src/wayland/meta-xwayland-selection.c
@@ -33,7 +33,9 @@
 #include <gdk/gdkx.h>
 #include <X11/Xatom.h>
 #include <X11/extensions/Xfixes.h>
+
 #include <meta/errors.h>
+#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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]