From: Po Lu Date: Tue, 21 Jun 2022 14:14:49 +0000 (+0800) Subject: Fix recent change to xlwmenu.c X-Git-Tag: emacs-29.0.90~1447^2~1558 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a4dcc8b9a94466c792be3743760a4a45cf6e1e61;p=emacs.git Fix recent change to xlwmenu.c * lwlib/xlwmenu.c (ungrab_all): Ungrab keyboard if it was grabbed. This handles `lucid--menu-grab-keyboard' changing while the menu is open. (XlwMenuDestroy): (pop_up_menu): Record if the keyboard was grabbed. --- diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c index 3c7a4936163..eba85631bd8 100644 --- a/lwlib/xlwmenu.c +++ b/lwlib/xlwmenu.c @@ -48,6 +48,7 @@ along with GNU Emacs. If not, see . */ #endif /* not emacs */ static int pointer_grabbed; +static int keyboard_grabbed; static XEvent menu_post_event; static char @@ -254,7 +255,8 @@ static void ungrab_all (Widget w, Time ungrabtime) { XtUngrabPointer (w, ungrabtime); - if (lucid__menu_grab_keyboard) + + if (keyboard_grabbed) XtUngrabKeyboard (w, ungrabtime); } @@ -2100,6 +2102,7 @@ XlwMenuDestroy (Widget w) if (pointer_grabbed) ungrab_all ((Widget)w, CurrentTime); pointer_grabbed = 0; + keyboard_grabbed = 0; if (!XtIsShell (XtParent (w))) submenu_destroyed = 1; @@ -2717,15 +2720,22 @@ pop_up_menu (XlwMenuWidget mw, XButtonPressedEvent *event) mw->menu.cursor_shape, event->time) == Success) { - if (!lucid__menu_grab_keyboard - || XtGrabKeyboard ((Widget)mw, False, GrabModeAsync, - GrabModeAsync, event->time) == Success) + if (true +#ifdef emacs + && lucid__menu_grab_keyboard +#endif + && XtGrabKeyboard ((Widget) mw, False, GrabModeAsync, + GrabModeAsync, event->time) == Success) { - XtSetKeyboardFocus((Widget)mw, None); + XtSetKeyboardFocus ((Widget) mw, None); pointer_grabbed = 1; + keyboard_grabbed = 1; } else - XtUngrabPointer ((Widget)mw, event->time); + { + XtUngrabPointer ((Widget) mw, event->time); + keyboard_grabbed = 0; + } } #ifdef emacs