[gnome-settings-daemon] mouse: Also grab button presses so as to replay them on locate pointer



commit c29144c974501272a499fc8f7bd8e496c9b59528
Author: Rui Matos <tiagomatos gmail com>
Date:   Sat Oct 6 01:39:41 2012 +0200

    mouse: Also grab button presses so as to replay them on locate pointer
    
    Applications might want to establish keyboard grabs on button presses
    so we should also ungrab the keyboard when a button press occurs after
    the locate pointer key is pressed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=125618

 plugins/mouse/gsd-locate-pointer.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/plugins/mouse/gsd-locate-pointer.c b/plugins/mouse/gsd-locate-pointer.c
index 6a26253..32b1a75 100644
--- a/plugins/mouse/gsd-locate-pointer.c
+++ b/plugins/mouse/gsd-locate-pointer.c
@@ -350,6 +350,19 @@ filter (GdkXEvent *xevent,
 
   GdkScreen *screen = (GdkScreen *)data;
 
+  if (xev->type == ButtonPress)
+    {
+      XAllowEvents (xev->xbutton.display,
+                    ReplayPointer,
+                    xev->xbutton.time);
+      XUngrabButton (xev->xbutton.display,
+                     AnyButton,
+                     AnyModifier,
+                     xev->xbutton.window);
+      XUngrabKeyboard (xev->xbutton.display,
+                       xev->xbutton.time);
+    }
+
   if (xev->type == KeyPress || xev->type == KeyRelease)
     {
       /* get the keysym */
@@ -367,9 +380,23 @@ filter (GdkXEvent *xevent,
               XAllowEvents (xev->xkey.display,
                             SyncKeyboard,
                             xev->xkey.time);
+              XGrabButton (xev->xkey.display,
+                           AnyButton,
+                           AnyModifier,
+                           xev->xkey.window,
+                           False,
+                           ButtonPressMask,
+                           GrabModeSync,
+                           GrabModeAsync,
+                           None,
+                           None);
             }
           else
             {
+              XUngrabButton (xev->xkey.display,
+                             AnyButton,
+                             AnyModifier,
+                             xev->xkey.window);
               XAllowEvents (xev->xkey.display,
                             AsyncKeyboard,
                             xev->xkey.time);
@@ -381,7 +408,11 @@ filter (GdkXEvent *xevent,
           XAllowEvents (xev->xkey.display,
                         ReplayKeyboard,
                         xev->xkey.time);
-          XUngrabKeyboard (gdk_x11_get_default_xdisplay (),
+          XUngrabButton (xev->xkey.display,
+                         AnyButton,
+                         AnyModifier,
+                         xev->xkey.window);
+          XUngrabKeyboard (xev->xkey.display,
                            xev->xkey.time);
         }
     }



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