static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
- LWLIB_ID, int, int));
+ LWLIB_ID, int));
/* Define HAVE_BOXES if menus can handle radio and toggle buttons. */
popped down (deactivated). This is used for x-popup-menu
and x-popup-dialog; it is not used for the menu bar.
- If DOWN_ON_KEYPRESS is nonzero, pop down if a key is pressed.
-
NOTE: All calls to popup_get_selection should be protected
with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */
static void
-popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
+popup_get_selection (initial_event, dpyinfo, id, do_timers)
XEvent *initial_event;
struct x_display_info *dpyinfo;
LWLIB_ID id;
int do_timers;
- int down_on_keypress;
{
XEvent event;
while (popup_activated_flag)
{
- if (initial_event)
+ if (initial_event)
{
event = *initial_event;
initial_event = 0;
event.xbutton.state = 0;
#endif
}
- /* If the user presses a key that doesn't go to the menu,
- deactivate the menu.
- The user is likely to do that if we get wedged.
- All toolkits now pop down menus on ESC.
- For dialogs however, the focus may not be on the dialog, so
- in that case, we pop down. */
+ /* Pop down on C-g and Escape. */
else if (event.type == KeyPress
- && down_on_keypress
&& dpyinfo->display == event.xbutton.display)
{
KeySym keysym = XLookupKeysym (&event.xkey, 0);
- if (!IsModifierKey (keysym)
- && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL)
- popup_activated_flag = 0;
+
+ if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0)
+ || keysym == XK_Escape) /* Any escape, ignore modifiers. */
+ popup_activated_flag = 0;
}
x_dispatch_event (&event, event.xany.display);
}
else
{
+ char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
+ XtTranslations override = XtParseTranslationTable (menuOverride);
+
menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
f->output_data.x->column_widget,
0,
popup_deactivate_callback,
menu_highlight_callback);
f->output_data.x->menubar_widget = menubar_widget;
+
+ /* Make menu pop down on C-g. */
+ XtOverrideTranslations (menubar_widget, override);
}
{
G_CALLBACK (menu_highlight_callback));
xg_crazy_callback_abort = 0;
- for (i = 0; i < 5; i++)
- if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
- break;
-
if (! for_click)
{
/* Not invoked by a click. pop up at x/y. */
popup_x_y.x = x;
popup_x_y.y = y;
popup_x_y.f = f;
- }
+ i = 0; /* gtk_menu_popup needs this to be 0 for a non-button popup. */
+ }
+ else
+ {
+ for (i = 0; i < 5; i++)
+ if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
+ break;
+ }
+
/* Display the menu. */
gtk_widget_show_all (menu);
gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
make_number (menu_id & ~(-1 << (fact)))));
/* Process events that apply to the menu. */
- popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0);
+ popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1);
unbind_to (specpdl_count, Qnil);
}
make_number (dialog_id & ~(-1 << (fact)))));
popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f),
- dialog_id, 1, 1);
+ dialog_id, 1);
unbind_to (count, Qnil);
}
}
}
}
+ else
+ /* Make "Cancel" equivalent to C-g. */
+ Fsignal (Qquit, Qnil);
return Qnil;
}
case XM_FAILURE:
*error = "Can't activate menu";
case XM_IA_SELECT:
+ entry = Qnil;
+ break;
case XM_NO_SELECT:
+ /* Make "Cancel" equivalent to C-g unless this menu was popped up by
+ a mouse press. */
+ if (! for_click)
+ Fsignal (Qquit, Qnil);
entry = Qnil;
break;
}