aboutsummaryrefslogtreecommitdiffstats
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-01-06 15:00:09 +0000
committerKaroly Lorentey2005-01-06 15:00:09 +0000
commit0feecea9fb7079a2c1fbfee32a992449a22cf478 (patch)
tree0826d68e3dc2ce370c7bd4dae7db3cffc3568321 /src/xmenu.c
parent17d51b68fb4e7da4f18eff72c589b7ffc4f9c22c (diff)
parent1a63439b34c3455a317feda5c271dfdb7af0296b (diff)
downloademacs-0feecea9fb7079a2c1fbfee32a992449a22cf478.tar.gz
emacs-0feecea9fb7079a2c1fbfee32a992449a22cf478.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-747 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-748 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-749 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-750 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-751 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-752 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-78 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-79 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-80 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-278
Diffstat (limited to 'src/xmenu.c')
-rw-r--r--src/xmenu.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index 45b0742df0e..774f404fd42 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -116,7 +116,7 @@ extern XtAppContext Xt_app_con;
116 116
117static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **)); 117static Lisp_Object xdialog_show P_ ((FRAME_PTR, int, Lisp_Object, char **));
118static void popup_get_selection P_ ((XEvent *, struct x_display_info *, 118static void popup_get_selection P_ ((XEvent *, struct x_display_info *,
119 LWLIB_ID, int, int)); 119 LWLIB_ID, int));
120 120
121/* Define HAVE_BOXES if menus can handle radio and toggle buttons. */ 121/* Define HAVE_BOXES if menus can handle radio and toggle buttons. */
122 122
@@ -1186,24 +1186,21 @@ x_menu_wait_for_event (void *data)
1186 popped down (deactivated). This is used for x-popup-menu 1186 popped down (deactivated). This is used for x-popup-menu
1187 and x-popup-dialog; it is not used for the menu bar. 1187 and x-popup-dialog; it is not used for the menu bar.
1188 1188
1189 If DOWN_ON_KEYPRESS is nonzero, pop down if a key is pressed.
1190
1191 NOTE: All calls to popup_get_selection should be protected 1189 NOTE: All calls to popup_get_selection should be protected
1192 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ 1190 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */
1193 1191
1194static void 1192static void
1195popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) 1193popup_get_selection (initial_event, dpyinfo, id, do_timers)
1196 XEvent *initial_event; 1194 XEvent *initial_event;
1197 struct x_display_info *dpyinfo; 1195 struct x_display_info *dpyinfo;
1198 LWLIB_ID id; 1196 LWLIB_ID id;
1199 int do_timers; 1197 int do_timers;
1200 int down_on_keypress;
1201{ 1198{
1202 XEvent event; 1199 XEvent event;
1203 1200
1204 while (popup_activated_flag) 1201 while (popup_activated_flag)
1205 { 1202 {
1206 if (initial_event) 1203 if (initial_event)
1207 { 1204 {
1208 event = *initial_event; 1205 event = *initial_event;
1209 initial_event = 0; 1206 initial_event = 0;
@@ -1232,20 +1229,15 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1232 event.xbutton.state = 0; 1229 event.xbutton.state = 0;
1233#endif 1230#endif
1234 } 1231 }
1235 /* If the user presses a key that doesn't go to the menu, 1232 /* Pop down on C-g and Escape. */
1236 deactivate the menu.
1237 The user is likely to do that if we get wedged.
1238 All toolkits now pop down menus on ESC.
1239 For dialogs however, the focus may not be on the dialog, so
1240 in that case, we pop down. */
1241 else if (event.type == KeyPress 1233 else if (event.type == KeyPress
1242 && down_on_keypress
1243 && dpyinfo->display == event.xbutton.display) 1234 && dpyinfo->display == event.xbutton.display)
1244 { 1235 {
1245 KeySym keysym = XLookupKeysym (&event.xkey, 0); 1236 KeySym keysym = XLookupKeysym (&event.xkey, 0);
1246 if (!IsModifierKey (keysym) 1237
1247 && x_any_window_to_frame (dpyinfo, event.xany.window) != NULL) 1238 if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0)
1248 popup_activated_flag = 0; 1239 || keysym == XK_Escape) /* Any escape, ignore modifiers. */
1240 popup_activated_flag = 0;
1249 } 1241 }
1250 1242
1251 x_dispatch_event (&event, event.xany.display); 1243 x_dispatch_event (&event, event.xany.display);
@@ -2226,6 +2218,9 @@ set_frame_menubar (f, first_time, deep_p)
2226 } 2218 }
2227 else 2219 else
2228 { 2220 {
2221 char menuOverride[] = "Ctrl<KeyPress>g: MenuGadgetEscape()";
2222 XtTranslations override = XtParseTranslationTable (menuOverride);
2223
2229 menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv, 2224 menubar_widget = lw_create_widget ("menubar", "menubar", id, first_wv,
2230 f->output_data.x->column_widget, 2225 f->output_data.x->column_widget,
2231 0, 2226 0,
@@ -2234,6 +2229,9 @@ set_frame_menubar (f, first_time, deep_p)
2234 popup_deactivate_callback, 2229 popup_deactivate_callback,
2235 menu_highlight_callback); 2230 menu_highlight_callback);
2236 f->output_data.x->menubar_widget = menubar_widget; 2231 f->output_data.x->menubar_widget = menubar_widget;
2232
2233 /* Make menu pop down on C-g. */
2234 XtOverrideTranslations (menubar_widget, override);
2237 } 2235 }
2238 2236
2239 { 2237 {
@@ -2597,7 +2595,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2597 make_number (menu_id & ~(-1 << (fact))))); 2595 make_number (menu_id & ~(-1 << (fact)))));
2598 2596
2599 /* Process events that apply to the menu. */ 2597 /* Process events that apply to the menu. */
2600 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0); 2598 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1);
2601 2599
2602 unbind_to (specpdl_count, Qnil); 2600 unbind_to (specpdl_count, Qnil);
2603 } 2601 }
@@ -2975,7 +2973,7 @@ create_and_show_dialog (f, first_wv)
2975 make_number (dialog_id & ~(-1 << (fact))))); 2973 make_number (dialog_id & ~(-1 << (fact)))));
2976 2974
2977 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), 2975 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f),
2978 dialog_id, 1, 1); 2976 dialog_id, 1);
2979 2977
2980 unbind_to (count, Qnil); 2978 unbind_to (count, Qnil);
2981 } 2979 }
@@ -3155,6 +3153,9 @@ xdialog_show (f, keymaps, title, error)
3155 } 3153 }
3156 } 3154 }
3157 } 3155 }
3156 else
3157 /* Make "Cancel" equivalent to C-g. */
3158 Fsignal (Qquit, Qnil);
3158 3159
3159 return Qnil; 3160 return Qnil;
3160} 3161}
@@ -3500,7 +3501,13 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3500 case XM_FAILURE: 3501 case XM_FAILURE:
3501 *error = "Can't activate menu"; 3502 *error = "Can't activate menu";
3502 case XM_IA_SELECT: 3503 case XM_IA_SELECT:
3504 entry = Qnil;
3505 break;
3503 case XM_NO_SELECT: 3506 case XM_NO_SELECT:
3507 /* Make "Cancel" equivalent to C-g unless this menu was popped up by
3508 a mouse press. */
3509 if (! for_click)
3510 Fsignal (Qquit, Qnil);
3504 entry = Qnil; 3511 entry = Qnil;
3505 break; 3512 break;
3506 } 3513 }