]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix recent change to xlwmenu.c
authorPo Lu <luangruo@yahoo.com>
Tue, 21 Jun 2022 14:14:49 +0000 (22:14 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 21 Jun 2022 14:14:49 +0000 (22:14 +0800)
* 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.

lwlib/xlwmenu.c

index 3c7a493616391242d6344349005358c54bffbcf6..eba85631bd8c2ab6dba95db3e2a06bd6be7fb205 100644 (file)
@@ -48,6 +48,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 #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