[mutter] display: Make sure to ungrab the pointer before starting a grab op



commit 5b83bfb1dbdf4288e2621be1d73abfddecf7b7ac
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 24 10:42:18 2014 -0400

    display: Make sure to ungrab the pointer before starting a grab op
    
    Now that we grab devices on the X11 connection, we can run into
    cross-connection issues. Since GTK+ frames are on the UI connection,
    they'll get the passive grab when we click on them. Forcibly ungrab
    on GTK+'s connection before attempting to take a grab on the backend
    connection ourselves.

 src/core/display.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index f8f1041..15d51a6 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1762,7 +1762,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
               "Doing grab op %u on window %s button %d pointer already grabbed: %d pointer pos %d,%d\n",
               op, window ? window->desc : "none", button, pointer_already_grabbed,
               root_x, root_y);
-  
+
   if (display->grab_op != META_GRAB_OP_NONE)
     {
       if (window)
@@ -1800,6 +1800,15 @@ meta_display_begin_grab_op (MetaDisplay *display,
   if (pointer_already_grabbed)
     display->grab_have_pointer = TRUE;
 
+  /* Since grab operations often happen as a result of implicit
+   * pointer operations on the display X11 connection, we need
+   * to ungrab here to ensure that the backend's X11 can take
+   * the device grab. */
+  XIUngrabDevice (display->xdisplay,
+                  META_VIRTUAL_CORE_POINTER_ID,
+                  timestamp);
+  XSync (display->xdisplay, False);
+
   meta_display_set_grab_op_cursor (display, op, timestamp);
 
   if (!display->grab_have_pointer && !meta_grab_op_is_keyboard (op))


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