1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-27 10:54:40 +00:00

Fix oldXMenu grab handling

* src/xmenu.c (x_menu_translate_generic_event, pop_down_menu):
Clear grab correctly on individual XI2 devices.
This commit is contained in:
Po Lu 2022-08-05 16:26:01 +08:00
parent 9aa959efeb
commit cbe1af96a2

View File

@ -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 ();