emacs-diffs
[Top][All Lists]
Advanced

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

master cbe1af96a2: Fix oldXMenu grab handling


From: Po Lu
Subject: master cbe1af96a2: Fix oldXMenu grab handling
Date: Fri, 5 Aug 2022 04:26:30 -0400 (EDT)

branch: master
commit cbe1af96a266d7153c3dde098194a7e154902b60
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix oldXMenu grab handling
    
    * src/xmenu.c (x_menu_translate_generic_event, pop_down_menu):
    Clear grab correctly on individual XI2 devices.
---
 src/xmenu.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/xmenu.c b/src/xmenu.c
index 3be0fb1876..5b8a8f77a2 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -232,6 +232,7 @@ static void
 x_menu_translate_generic_event (XEvent *event)
 {
   struct x_display_info *dpyinfo;
+  struct xi_device_t *device;
   XEvent copy;
   XIDeviceEvent *xev;
 
@@ -265,6 +266,16 @@ x_menu_translate_generic_event (XEvent *event)
              copy.xbutton.button = xev->detail;
              copy.xbutton.same_screen = True;
 
+             device = xi_device_from_id (dpyinfo, xev->deviceid);
+
+             /* I don't know the repercussions of changing
+                device->grab on XI_ButtonPress events, so be safe and
+                only do what is necessary to prevent the grab from
+                being left invalid as XMenuActivate swallows
+                events.  */
+             if (device && xev->evtype == XI_ButtonRelease)
+               device->grab &= ~(1 << xev->detail);
+
              XPutBackEvent (dpyinfo->display, &copy);
 
              break;
@@ -2507,6 +2518,10 @@ pop_down_menu (void *arg)
   struct pop_down_menu *data = arg;
   struct frame *f = data->frame;
   XMenu *menu = data->menu;
+#ifdef HAVE_XINPUT2
+  int i;
+  struct xi_device_t *device;
+#endif
 
   block_input ();
 #ifndef MSDOS
@@ -2526,6 +2541,17 @@ pop_down_menu (void *arg)
      results, and it is a pain to ask which are actually held now.  */
   FRAME_DISPLAY_INFO (f)->grabbed = 0;
 
+#ifdef HAVE_XINPUT2
+  /* Likewise for XI grabs when the mouse is released on top of the
+     menu itself.  */
+
+  for (i = 0; i < FRAME_DISPLAY_INFO (f)->num_devices; ++i)
+    {
+      device = &FRAME_DISPLAY_INFO (f)->devices[i];
+      device->grab = 0;
+    }
+#endif
+
 #endif /* HAVE_X_WINDOWS */
 
   unblock_input ();



reply via email to

[Prev in Thread] Current Thread [Next in Thread]