]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix menus on the no-toolkit build when using XI2
authorPo Lu <luangruo@yahoo.com>
Sun, 23 Jan 2022 11:34:39 +0000 (19:34 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 23 Jan 2022 11:34:39 +0000 (19:34 +0800)
* src/xmenu.c (x_activate_menubar):
(create_and_show_popup_menu): Only ungrab the device if it is
actually grabbed.
(x_menu_show): Release XI2 passive grab.

src/xmenu.c

index b755f75da02b347716aeac6e4b5423856a0e9dcc..9e4e6b62fce1a6761db780250dd7c084813f3d5a 100644 (file)
@@ -457,8 +457,11 @@ x_activate_menubar (struct frame *f)
   if (dpyinfo->num_devices)
     {
       for (int i = 0; i < dpyinfo->num_devices; ++i)
-       XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
-                       CurrentTime);
+       {
+         if (dpyinfo->devices[i].grab)
+           XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
+                           CurrentTime);
+       }
     }
 #endif
   XtDispatchEvent (f->output_data.x->saved_menu_event);
@@ -1469,8 +1472,11 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
   if (dpyinfo->num_devices)
     {
       for (int i = 0; i < dpyinfo->num_devices; ++i)
-       XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
-                       CurrentTime);
+       {
+         if (dpyinfo->devices[i].grab)
+           XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
+                           CurrentTime);
+       }
     }
 #endif
   /* Display the menu.  */
@@ -2367,6 +2373,22 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
   /* Help display under X won't work because XMenuActivate contains
      a loop that doesn't give Emacs a chance to process it.  */
   menu_help_frame = f;
+
+#ifdef HAVE_XINPUT2
+  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+  /* Clear the XI2 grab so a core grab can be set.  */
+
+  if (dpyinfo->num_devices)
+    {
+      for (int i = 0; i < dpyinfo->num_devices; ++i)
+       {
+         if (dpyinfo->devices[i].grab)
+           XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
+                           CurrentTime);
+       }
+    }
+#endif
+
   status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
                           x, y, ButtonReleaseMask, &datap,
                           menu_help_callback);