emacs-diffs
[Top][All Lists]
Advanced

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

master 7078af6: Fix menu grabs on XI2 Motif builds


From: Po Lu
Subject: master 7078af6: Fix menu grabs on XI2 Motif builds
Date: Thu, 23 Dec 2021 22:10:55 -0500 (EST)

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

    Fix menu grabs on XI2 Motif builds
    
    * src/xmenu.c (x_activate_menubar) [USE_MOTIF]: Clear XI grab.
    * src/xterm.c (xi_grab_or_ungrab_device) [USE_MOTIF]: Always
    ungrab if a popup is active.
---
 src/xmenu.c | 16 ++++++++++++++++
 src/xterm.c |  6 +++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/xmenu.c b/src/xmenu.c
index 0725591..4d969fa 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -51,6 +51,10 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "msdos.h"
 #endif
 
+#ifdef HAVE_XINPUT2
+#include <X11/extensions/XInput2.h>
+#endif
+
 #ifdef HAVE_X_WINDOWS
 /* This may include sys/types.h, and that somehow loses
    if this is not done before the other system files.  */
@@ -444,6 +448,18 @@ x_activate_menubar (struct frame *f)
   XPutBackEvent (f->output_data.x->display_info->display,
                  f->output_data.x->saved_menu_event);
 #else
+#ifdef USE_MOTIF
+  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+  /* Clear the XI2 grab so Motif can set a core grab.  Otherwise some
+     versions of Motif will emit a warning and hang.  */
+
+  if (dpyinfo->num_devices)
+    {
+      for (int i = 0; i < dpyinfo->num_devices; ++i)
+       XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
+                       CurrentTime);
+    }
+#endif
   XtDispatchEvent (f->output_data.x->saved_menu_event);
 #endif
   unblock_input ();
diff --git a/src/xterm.c b/src/xterm.c
index b8cf637..aa88610 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -637,7 +637,11 @@ xi_grab_or_ungrab_device (struct xi_device_t *device,
   XISetMask (m, XI_Enter);
   XISetMask (m, XI_Leave);
 
-  if (device->grab)
+  if (device->grab
+#ifdef USE_MOTIF
+      && !popup_activated ()
+#endif
+      )
     {
       XIGrabDevice (dpyinfo->display, device->device_id, window,
                    CurrentTime, None, GrabModeAsync,



reply via email to

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