diff options
author | Po Lu <luangruo@yahoo.com> | 2022-08-05 16:26:01 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-08-05 16:26:01 +0800 |
commit | cbe1af96a266d7153c3dde098194a7e154902b60 (patch) | |
tree | b852c92d41cea6f2de6d16800f776eac0f20c088 /src/xmenu.c | |
parent | 9aa959efebc5b87022096c089a41ff8c899694c5 (diff) | |
download | emacs-cbe1af96a266d7153c3dde098194a7e154902b60.tar.gz |
Fix oldXMenu grab handling
* src/xmenu.c (x_menu_translate_generic_event, pop_down_menu):
Clear grab correctly on individual XI2 devices.
Diffstat (limited to 'src/xmenu.c')
-rw-r--r-- | src/xmenu.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index 3be0fb18766..5b8a8f77a2d 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -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, ©); 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 (); |