[mutter/wip/xinput2b: 14/19] display: Grab buttons with XI2



commit 95d768b6014dbc41bc1857d5e205d2320a5f8b26
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Nov 20 18:06:09 2012 -0500

    display: Grab buttons with XI2
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688779

 src/core/display.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index 1987de6..769f2e4 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -4132,6 +4132,13 @@ meta_change_button_grab (MetaDisplay *display,
 {
   unsigned int ignored_mask;
 
+  unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
+  XIEventMask mask = { XIAllMasterDevices, sizeof (mask_bits), mask_bits };
+
+  XISetMask (mask.mask, XI_ButtonPress);
+  XISetMask (mask.mask, XI_ButtonRelease);
+  XISetMask (mask.mask, XI_Motion);
+
   meta_verbose ("%s 0x%lx sync = %d button = %d modmask 0x%x\n",
                 grab ? "Grabbing" : "Ungrabbing",
                 xwindow,
@@ -4142,6 +4149,8 @@ meta_change_button_grab (MetaDisplay *display,
   ignored_mask = 0;
   while (ignored_mask <= display->ignored_modifier_mask)
     {
+      XIGrabModifiers mods;
+
       if (ignored_mask & ~(display->ignored_modifier_mask))
         {
           /* Not a combination of ignored modifiers
@@ -4151,22 +4160,24 @@ meta_change_button_grab (MetaDisplay *display,
           continue;
         }
 
+      mods = (XIGrabModifiers) { modmask | ignored_mask, 0 };
+
       if (meta_is_debugging ())
         meta_error_trap_push_with_return (display);
 
       /* GrabModeSync means freeze until XAllowEvents */
       
       if (grab)
-        XGrabButton (display->xdisplay, button, modmask | ignored_mask,
-                     xwindow, False,
-                     ButtonPressMask | ButtonReleaseMask |    
-                     PointerMotionMask | PointerMotionHintMask,
-                     sync ? GrabModeSync : GrabModeAsync,
-                     GrabModeAsync,
-                     False, None);
+        XIGrabButton (display->xdisplay,
+                      VIRTUAL_CORE_POINTER_ID,
+                      button, xwindow, None,
+                      sync ? GrabModeSync : GrabModeAsync,
+                      GrabModeAsync, False,
+                      &mask, 1, &mods);
       else
-        XUngrabButton (display->xdisplay, button, modmask | ignored_mask,
-                       xwindow);
+        XIUngrabButton (display->xdisplay,
+                        VIRTUAL_CORE_POINTER_ID,
+                        button, xwindow, 1, &mods);
 
       if (meta_is_debugging ())
         {



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