From 9f6fcdc51615be98d2a026c302868061045176ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 27 Dec 2004 15:24:12 +0000 Subject: * xmenu.c (popup_get_selection): Pop down on C-g. (set_frame_menubar): Install translations for Lucid/Motif/Lesstif that pops down menu on C-g. (xdialog_show): If dialog popped down and no button in the dialog was pushed, call Fsignal to quit. (xmenu_show): In no toolkit version, if menu returns NO_SELECT call Fsignal to quit. * xfns.c (Fx_file_dialog): Motif/Lesstif version: Pop down on C-g. * gtkutil.c (xg_initialize): Install bindings for C-g so that dialogs and menus pop down. --- src/xmenu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/xmenu.c') diff --git a/src/xmenu.c b/src/xmenu.c index ff012634b50..b20147417be 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1243,6 +1243,11 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) && dpyinfo->display == event.xbutton.display) { KeySym keysym = XLookupKeysym (&event.xkey, 0); + + /* Pop down on C-g. */ + if (keysym == XK_g && (event.xkey.state & ControlMask) != 0) + popup_activated_flag = 0; + if (!IsModifierKey (keysym) && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL) popup_activated_flag = 0; @@ -2226,6 +2231,9 @@ set_frame_menubar (f, first_time, deep_p) } else { + char menuOverride[] = "Ctrlg: MenuGadgetEscape()"; + XtTranslations override = XtParseTranslationTable (menuOverride); + menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv, f->output_data.x->column_widget, 0, @@ -2234,6 +2242,9 @@ set_frame_menubar (f, first_time, deep_p) 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); } { @@ -3155,6 +3166,9 @@ xdialog_show (f, keymaps, title, error) } } } + else + /* Make "Cancel" equivalent to C-g. */ + Fsignal (Qquit, Qnil); return Qnil; } @@ -3500,7 +3514,13 @@ xmenu_show (f, x, y, for_click, keymaps, title, error) 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; } -- cgit v1.2.1 From c0b0f54b8c5246c6a17e1370c096da02b0d9e07e Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 27 Dec 2004 15:58:25 +0000 Subject: Indentation fix. --- src/xmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmenu.c') diff --git a/src/xmenu.c b/src/xmenu.c index b20147417be..55c28d831e8 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1203,7 +1203,7 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) while (popup_activated_flag) { - if (initial_event) + if (initial_event) { event = *initial_event; initial_event = 0; -- cgit v1.2.1 From 33385c6fa06f2a9faef28252cd2e073b11e84c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 27 Dec 2004 20:34:03 +0000 Subject: * xmenu.c (popup_get_selection): Only pop down dialogs on C-g and Escape. --- src/xmenu.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/xmenu.c') diff --git a/src/xmenu.c b/src/xmenu.c index 55c28d831e8..ba4177fab67 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1232,25 +1232,16 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) 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); - /* Pop down on C-g. */ - if (keysym == XK_g && (event.xkey.state & ControlMask) != 0) + if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0) + || keysym == XK_Escape) /* Any escape, ignore modifiers. */ popup_activated_flag = 0; - - if (!IsModifierKey (keysym) - && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL) - popup_activated_flag = 0; } x_dispatch_event (&event, event.xany.display); -- cgit v1.2.1 From 95bdef2ed441e60ae9fc0d0b252f008f2121942e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 27 Dec 2004 20:56:56 +0000 Subject: (popup_get_selection): Remove parameter down_on_keypress. (create_and_show_popup_menu, create_and_show_dialog): Remove parameter down_on_keypress to popup_get_selection. --- src/xmenu.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/xmenu.c') diff --git a/src/xmenu.c b/src/xmenu.c index ba4177fab67..f9c2dc4bd1b 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -116,7 +116,7 @@ extern XtAppContext Xt_app_con; 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. */ @@ -1186,18 +1186,15 @@ x_menu_wait_for_event (void *data) 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; @@ -1234,7 +1231,6 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) } /* 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); @@ -2599,7 +2595,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click) 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); } @@ -2977,7 +2973,7 @@ create_and_show_dialog (f, first_wv) 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); } -- cgit v1.2.1