[Xfce4-commits] [xfce/xfwm4] 16/18: device: Check standard passive button grabs

noreply at xfce.org noreply at xfce.org
Sat Apr 11 17:58:52 CEST 2020


This is an automated email from the git hooks/post-receive script.

o   l   i   v   i   e   r       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       x   f   c   e   -   4   .   1   4   
   in repository xfce/xfwm4.

commit 1bdc36fbdda0cd53c5f50744cd6c2c3bdef00dbb
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Tue Apr 7 19:53:58 2020 +0200

    device: Check standard passive button grabs
    
    Bug: 16649
    
    With Xi2 we need to use Xi2 routines.
    
    But some client may issue standard X11 core protocol grabs the on the
    client window.
    
    Grabs from the standard core protocol and Xi2 grabs do not mix well.
    
    So instead of ditching the Xi2 grabs, we issue the core protocol first,
    check that it succeeds and only if that works we can issue the Xi2
    grabs.
    
    That keeps the Xi2 grabs logic while fixing the issue with X-AIR-Edit
    which uses a passive grab on the pointer using core X11 protocol.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
    (cherry picked from commit 0c376d254293ca52162bcddf4bcfa5908fb28e4c)
    (cherry picked from commit de4db5273d5449c08875b53e1d0506b8e1cc68b4)
---
 src/device.c | 49 ++++++++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/device.c b/src/device.c
index 47403b1..dc89b3f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -27,6 +27,8 @@
 #include <X11/extensions/XInput2.h>
 #endif
 
+#include "display.h"
+
 #ifdef HAVE_XI2
 static const struct
 {
@@ -404,11 +406,22 @@ xfwm_device_grab_button (XfwmDevices *devices, Display *display,
 {
     gboolean result;
     Status status;
+    DisplayInfo *display_info;
 #ifdef HAVE_XI2
     XIGrabModifiers xi2_modifiers;
     XIEventMask xievent_mask;
 #endif
 
+    display_info = myDisplayGetDefault ();
+    myDisplayErrorTrapPush (display_info);
+    result = XGrabButton (display, button, modifiers, grab_window,
+                          owner_events, event_mask, grab_mode, paired_device_mode,
+                          confine_to, cursor);
+    if (myDisplayErrorTrapPop (display_info) || !result)
+    {
+        return FALSE;
+    }
+
 #ifdef HAVE_XI2
     if (devices->xi2_available)
     {
@@ -422,14 +435,8 @@ xfwm_device_grab_button (XfwmDevices *devices, Display *display,
         g_free (xievent_mask.mask);
         result = (status == XIGrabSuccess);
     }
-    else
 #endif
-    {
-        status = XGrabButton (display, button, modifiers, grab_window,
-                              owner_events, event_mask, grab_mode, paired_device_mode,
-                              confine_to, cursor);
-        result = (status == GrabSuccess);
-    }
+
     return result;
 }
 
@@ -441,6 +448,7 @@ xfwm_device_ungrab_button (XfwmDevices *devices, Display *display,
     XIGrabModifiers xi2_modifiers;
 #endif
 
+    XUngrabButton (display, button, modifiers, grab_window);
 #ifdef HAVE_XI2
     if (devices->xi2_available)
     {
@@ -450,11 +458,7 @@ xfwm_device_ungrab_button (XfwmDevices *devices, Display *display,
         XIUngrabButton (display, devices->pointer.xi2_device, button,
                         grab_window, 1, &xi2_modifiers);
     }
-    else
 #endif
-    {
-        XUngrabButton (display, button, modifiers, grab_window);
-    }
 }
 
 gboolean
@@ -465,11 +469,21 @@ xfwm_device_grab_keycode (XfwmDevices *devices, Display *display,
 {
     gboolean result;
     Status status;
+    DisplayInfo *display_info;
 #ifdef HAVE_XI2
     XIGrabModifiers xi2_modifiers;
     XIEventMask xievent_mask;
 #endif
 
+    display_info = myDisplayGetDefault ();
+    myDisplayErrorTrapPush (display_info);
+    result = XGrabKey (display, keycode, modifiers, grab_window,
+                       owner_events, grab_mode, paired_device_mode);
+    if (myDisplayErrorTrapPop (display_info) || !result)
+    {
+        return FALSE;
+    }
+
 #ifdef HAVE_XI2
     if (devices->xi2_available)
     {
@@ -483,13 +497,8 @@ xfwm_device_grab_keycode (XfwmDevices *devices, Display *display,
         g_free (xievent_mask.mask);
         result = (status == XIGrabSuccess);
     }
-    else
 #endif
-    {
-        status = XGrabKey (display, keycode, modifiers, grab_window,
-                           owner_events, grab_mode, paired_device_mode);
-        result = (status == GrabSuccess);
-    }
+
     return result;
 }
 
@@ -501,6 +510,8 @@ xfwm_device_ungrab_keycode (XfwmDevices *devices, Display *display,
     XIGrabModifiers xi2_modifiers;
 #endif
 
+    XUngrabKey (display, keycode, modifiers, grab_window);
+
 #ifdef HAVE_XI2
     if (devices->xi2_available)
     {
@@ -510,11 +521,7 @@ xfwm_device_ungrab_keycode (XfwmDevices *devices, Display *display,
         XIUngrabKeycode (display, devices->keyboard.xi2_device, keycode,
                          grab_window, 1, &xi2_modifiers);
     }
-    else
 #endif
-    {
-        XUngrabKey (display, keycode, modifiers, grab_window);
-    }
 }
 
 #ifdef HAVE_XI2

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list