From: Po Lu Date: Mon, 27 Dec 2021 01:16:18 +0000 (+0800) Subject: Fix Lucid popup menu being stuck on XI2 builds X-Git-Tag: emacs-29.0.90~3423 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2ccb1568876f6ac7d8b980d60d91a689e797ab36;p=emacs.git Fix Lucid popup menu being stuck on XI2 builds * src/xmenu.c (x_activate_menubar): Make some changes conditional on XI2. (create_and_show_popup_menu): Clear XI2 grab before showing popup. * src/xterm.c (xi_grab_or_ungrab_device): Don't grab device if popup is activated on Lucid. --- diff --git a/src/xmenu.c b/src/xmenu.c index 4d969fa25f8..9b0353f133f 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -449,6 +449,7 @@ x_activate_menubar (struct frame *f) f->output_data.x->saved_menu_event); #else #ifdef USE_MOTIF +#ifdef HAVE_XINPUT2 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. */ @@ -459,6 +460,7 @@ x_activate_menubar (struct frame *f) XIUngrabDevice (dpyinfo->display, dpyinfo->devices[i].device_id, CurrentTime); } +#endif #endif XtDispatchEvent (f->output_data.x->saved_menu_event); #endif @@ -1461,7 +1463,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; diff --git a/src/xterm.c b/src/xterm.c index 8ba4f46c2c9..4ca68848d2e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -638,7 +638,7 @@ xi_grab_or_ungrab_device (struct xi_device_t *device, XISetMask (m, XI_Leave); if (device->grab -#ifdef USE_MOTIF +#if defined USE_MOTIF || defined USE_LUCID && !popup_activated () #endif )