int submenu_destroyed;
+/* For debug, set this to 0 to not grab the keyboard on menu popup */
+int x_menu_grab_keyboard = 1;
+
static int next_release_must_exit;
\f/* Utilities */
+/* Ungrab pointer and keyboard */
+static void
+ungrab_all (w, ungrabtime)
+ Widget w;
+ Time ungrabtime;
+{
+ XtUngrabPointer (w, ungrabtime);
+ if (x_menu_grab_keyboard) XtUngrabKeyboard (w, ungrabtime);
+}
/* Like abort, but remove grabs from widget W before. */
{
if (XtIsShell (XtParent (w)))
XtRemoveGrab (w);
- XtUngrabPointer (w, CurrentTime);
+ ungrab_all (w, CurrentTime);
abort ();
}
XlwMenuWidget mw = (XlwMenuWidget) w;
if (pointer_grabbed)
- XtUngrabPointer ((Widget)w, CurrentTime);
+ ungrab_all ((Widget)w, CurrentTime);
pointer_grabbed = 0;
submenu_destroyed = 1;
if (mw->menu.popped_up)
{
mw->menu.popped_up = False;
- XtUngrabPointer ((Widget)mw, ev->xmotion.time);
+ ungrab_all ((Widget)mw, ev->xmotion.time);
if (XtIsShell (XtParent ((Widget) mw)))
XtPopdown (XtParent ((Widget) mw));
else
if (mw->menu.popped_up)
{
mw->menu.popped_up = False;
- XtUngrabPointer ((Widget)mw, ev->xmotion.time);
+ ungrab_all ((Widget)mw, ev->xmotion.time);
if (XtIsShell (XtParent ((Widget) mw)))
XtPopdown (XtParent ((Widget) mw));
else
#ifdef emacs
count = x_catch_errors (display);
#endif
- XtGrabPointer ((Widget)mw, False,
- (PointerMotionMask
- | PointerMotionHintMask
- | ButtonReleaseMask
- | ButtonPressMask),
- GrabModeAsync, GrabModeAsync, None,
- mw->menu.cursor_shape,
- event->time);
- pointer_grabbed = 1;
+ if (XtGrabPointer ((Widget)mw, False,
+ (PointerMotionMask
+ | PointerMotionHintMask
+ | ButtonReleaseMask
+ | ButtonPressMask),
+ GrabModeAsync, GrabModeAsync, None,
+ mw->menu.cursor_shape,
+ event->time) == Success)
+ {
+ if (! x_menu_grab_keyboard
+ || XtGrabKeyboard ((Widget)mw, False, GrabModeAsync,
+ GrabModeAsync, event->time) == Success)
+ {
+ XtSetKeyboardFocus((Widget)mw, None);
+ pointer_grabbed = 1;
+ }
+ else
+ XtUngrabPointer ((Widget)mw, event->time);
+ }
+
#ifdef emacs
if (x_had_errors_p (display))
{