summaryrefslogtreecommitdiff
path: root/src/xmenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmenu.c')
-rw-r--r--src/xmenu.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index ea2cbab2030..f3b7c45ffff 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. */
@@ -105,7 +109,11 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
/* Flag which when set indicates a dialog or menu has been posted by
Xt on behalf of one of the widget sets. */
+#ifndef HAVE_XINPUT2
static int popup_activated_flag;
+#else
+int popup_activated_flag;
+#endif
#ifdef USE_X_TOOLKIT
@@ -440,6 +448,19 @@ x_activate_menubar (struct frame *f)
XPutBackEvent (f->output_data.x->display_info->display,
f->output_data.x->saved_menu_event);
#else
+#if defined USE_X_TOOLKIT && defined HAVE_XINPUT2
+ struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+ /* Clear the XI2 grab so Motif or lwlib can set a core grab.
+ Otherwise some versions of Motif will emit a warning and hang,
+ and lwlib will fail to destroy the menu window. */
+
+ 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 ();
@@ -1441,7 +1462,17 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
/* Don't allow any geometry request from the user. */
XtSetArg (av[ac], (char *) XtNgeometry, 0); ac++;
XtSetValues (menu, av, ac);
+#if defined HAVE_XINPUT2 && defined USE_LUCID
+ struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+ /* Clear the XI2 grab so lwlib can set a core grab. */
+ if (dpyinfo->num_devices)
+ {
+ for (int i = 0; i < dpyinfo->num_devices; ++i)
+ XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id,
+ CurrentTime);
+ }
+#endif
/* Display the menu. */
lw_popup_menu (menu, &dummy);
popup_activated_flag = 1;