diff options
| author | Richard M. Stallman | 2002-12-21 18:19:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-12-21 18:19:13 +0000 |
| commit | f02cac82a2b832fe157c051fc6ce854736b99dc8 (patch) | |
| tree | 001fa9ace7beb777215e50772c5d1b6e748000fd /src | |
| parent | 40a301b3524036f179f3293e80304fd3f435624b (diff) | |
| download | emacs-f02cac82a2b832fe157c051fc6ce854736b99dc8.tar.gz emacs-f02cac82a2b832fe157c051fc6ce854736b99dc8.zip | |
(popup_get_selection): Now static. New arg DO_TIMERS.
If it is non-nil, run timers. Use an unwind-protect to requeue
the events that were read ahead.
(popup_get_selection_unwind): New subroutine.
(popup_get_selection_queue): File-scope variable now holds that queue.
(xmenu_show): Pass 0 for DO_TIMERS to popup_get_selection.
(xdialog_show): Pass 1 for DO_TIMERS to popup_get_selection.
Use an unwind-protect to pop down the dialog box.
(xdialog_show_unwind): New subroutine implements that.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 43 | ||||
| -rw-r--r-- | src/xmenu.c | 118 |
2 files changed, 126 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c07918b0487..6de8602e6f6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,9 +1,46 @@ | |||
| 1 | 2002-12-21 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * xmenu.c (popup_get_selection): Now static. New arg DO_TIMERS. | ||
| 4 | If it is non-nil, run timers. Use an unwind-protect to requeue | ||
| 5 | the events that were read ahead. | ||
| 6 | (popup_get_selection_unwind): New subroutine. | ||
| 7 | (popup_get_selection_queue): File-scope variable now holds that queue. | ||
| 8 | (xmenu_show): Pass 0 for DO_TIMERS to popup_get_selection. | ||
| 9 | (xdialog_show): Pass 1 for DO_TIMERS to popup_get_selection. | ||
| 10 | Use an unwind-protect to pop down the dialog box. | ||
| 11 | (xdialog_show_unwind): New subroutine implements that. | ||
| 12 | |||
| 13 | * xdisp.c (row_containing_pos): Change exit test using last_y. | ||
| 14 | (try_window_id): Abort if row_containing_pos returns null. | ||
| 15 | |||
| 16 | * lread.c (load_error_handler): New function. | ||
| 17 | (Fload): Handle errors in Fsubstitute_in_file_name. | ||
| 18 | Don't expect Fsignal to return. | ||
| 19 | |||
| 20 | * Errors and throws work right with interrupt blocking. | ||
| 21 | * eval.c (struct catchtag): New elt interrupt_input_blocked. | ||
| 22 | (unwind_to_catch): Restore interrupt_input_blocked from saved value. | ||
| 23 | (internal_catch, Fcondition_case, internal_condition_case) | ||
| 24 | (internal_condition_case_1, internal_condition_case_2): Save it. | ||
| 25 | (Fsignal): Don't do TOTALLY_UNBLOCK_INPUT. | ||
| 26 | |||
| 27 | * editfns.c (Fformat): Add parens. | ||
| 28 | |||
| 29 | * dired.c (file_name_completion): Fix that change. | ||
| 30 | Delete special quit-handling code; just use QUIT. | ||
| 31 | |||
| 32 | 2002-12-21 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change) | ||
| 33 | |||
| 34 | * dired.c (file_name_completion): Close directory on error | ||
| 35 | just as in directory_files_internal. | ||
| 36 | |||
| 1 | 2002-12-19 David Kastrup <David.Kastrup@t-online.de> | 37 | 2002-12-19 David Kastrup <David.Kastrup@t-online.de> |
| 2 | 38 | ||
| 3 | * window.c (Fset_window_configuration): Set old_point to correct | 39 | * window.c (Fset_window_configuration): Set old_point to correct |
| 4 | value when new_current_buffer == current_buffer. | 40 | value when new_current_buffer == current_buffer. |
| 5 | 41 | ||
| 6 | 2002-12-17 Ben Key <bkey1@tampabay.rr.com> | 42 | 2002-12-17 Ben Key <bkey1@tampabay.rr.com> |
| 43 | |||
| 7 | * Revisited my earlier fix for the following entry in | 44 | * Revisited my earlier fix for the following entry in |
| 8 | etc/PROBLEMS: | 45 | etc/PROBLEMS: |
| 9 | "Emacs built on Windows 9x/ME crashes at startup on Windows XP, | 46 | "Emacs built on Windows 9x/ME crashes at startup on Windows XP, |
| @@ -153,11 +190,11 @@ | |||
| 153 | 190 | ||
| 154 | * s/sol2-8: Removed. (Not necessary.) | 191 | * s/sol2-8: Removed. (Not necessary.) |
| 155 | 192 | ||
| 156 | 2002-12-09 Kai Gro,A_(Bjohann <kai.grossjohann@uni-duisburg.de> | 193 | 2002-12-09 Matthew Swift <swift@alum.mit.edu> |
| 157 | 194 | ||
| 158 | * editfns.c (Fformat): Handle precision in string conversion | 195 | * editfns.c (Fformat): Handle precision in string conversion |
| 159 | specifiers like libc functions do (ie, print at most that many | 196 | specifiers like libc functions do (ie, print at most that many |
| 160 | characters). From Matthew Swift <swift@alum.mit.edu>. | 197 | characters). |
| 161 | 198 | ||
| 162 | 2002-12-08 Richard M. Stallman <rms@gnu.org> | 199 | 2002-12-08 Richard M. Stallman <rms@gnu.org> |
| 163 | 200 | ||
| @@ -180,7 +217,7 @@ | |||
| 180 | while blocking on select. | 217 | while blocking on select. |
| 181 | 218 | ||
| 182 | * mac.c (sys_read): Use sys_select to test for input first | 219 | * mac.c (sys_read): Use sys_select to test for input first |
| 183 | before calling read to allow C-g to break. | 220 | before calling read, to allow C-g to break. |
| 184 | 221 | ||
| 185 | 2002-12-07 Richard M. Stallman <rms@gnu.org> | 222 | 2002-12-07 Richard M. Stallman <rms@gnu.org> |
| 186 | 223 | ||
diff --git a/src/xmenu.c b/src/xmenu.c index 81b9716c08e..196b38334d0 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -112,7 +112,7 @@ extern void process_expose_from_menu (); | |||
| 112 | extern XtAppContext Xt_app_con; | 112 | extern XtAppContext Xt_app_con; |
| 113 | 113 | ||
| 114 | static Lisp_Object xdialog_show (); | 114 | static Lisp_Object xdialog_show (); |
| 115 | void popup_get_selection (); | 115 | static void popup_get_selection (); |
| 116 | 116 | ||
| 117 | /* Define HAVE_BOXES if menus can handle radio and toggle buttons. */ | 117 | /* Define HAVE_BOXES if menus can handle radio and toggle buttons. */ |
| 118 | 118 | ||
| @@ -132,6 +132,8 @@ static void single_menu_item P_ ((Lisp_Object, Lisp_Object, Lisp_Object *, | |||
| 132 | int, int, int *)); | 132 | int, int, int *)); |
| 133 | static void list_of_panes P_ ((Lisp_Object)); | 133 | static void list_of_panes P_ ((Lisp_Object)); |
| 134 | static void list_of_items P_ ((Lisp_Object)); | 134 | static void list_of_items P_ ((Lisp_Object)); |
| 135 | |||
| 136 | extern EMACS_TIME timer_check P_ ((int)); | ||
| 135 | 137 | ||
| 136 | /* This holds a Lisp vector that holds the results of decoding | 138 | /* This holds a Lisp vector that holds the results of decoding |
| 137 | the keymaps or alist-of-alists that specify a menu. | 139 | the keymaps or alist-of-alists that specify a menu. |
| @@ -1015,31 +1017,44 @@ on the left of the dialog box and all following items on the right. | |||
| 1015 | 1017 | ||
| 1016 | #ifdef USE_X_TOOLKIT | 1018 | #ifdef USE_X_TOOLKIT |
| 1017 | 1019 | ||
| 1020 | /* Define a queue to save up for later unreading | ||
| 1021 | all X events that don't pertain to the menu. */ | ||
| 1022 | struct event_queue | ||
| 1023 | { | ||
| 1024 | XEvent event; | ||
| 1025 | struct event_queue *next; | ||
| 1026 | }; | ||
| 1027 | |||
| 1028 | /* It is ok that this queue is a static variable, | ||
| 1029 | because init_menu_items won't allow the menu mechanism | ||
| 1030 | to be entered recursively. */ | ||
| 1031 | static struct event_queue *popup_get_selection_queue; | ||
| 1032 | |||
| 1033 | static Lisp_Object popup_get_selection_unwind (); | ||
| 1034 | |||
| 1018 | /* Loop in Xt until the menu pulldown or dialog popup has been | 1035 | /* Loop in Xt until the menu pulldown or dialog popup has been |
| 1019 | popped down (deactivated). This is used for x-popup-menu | 1036 | popped down (deactivated). This is used for x-popup-menu |
| 1020 | and x-popup-dialog; it is not used for the menu bar any more. | 1037 | and x-popup-dialog; it is not used for the menu bar. |
| 1038 | |||
| 1039 | If DO_TIMERS is nonzero, run timers. | ||
| 1021 | 1040 | ||
| 1022 | NOTE: All calls to popup_get_selection should be protected | 1041 | NOTE: All calls to popup_get_selection should be protected |
| 1023 | with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ | 1042 | with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ |
| 1024 | 1043 | ||
| 1025 | void | 1044 | static void |
| 1026 | popup_get_selection (initial_event, dpyinfo, id) | 1045 | popup_get_selection (initial_event, dpyinfo, id, do_timers) |
| 1027 | XEvent *initial_event; | 1046 | XEvent *initial_event; |
| 1028 | struct x_display_info *dpyinfo; | 1047 | struct x_display_info *dpyinfo; |
| 1029 | LWLIB_ID id; | 1048 | LWLIB_ID id; |
| 1049 | int do_timers; | ||
| 1030 | { | 1050 | { |
| 1031 | XEvent event; | 1051 | XEvent event; |
| 1032 | |||
| 1033 | /* Define a queue to save up for later unreading | ||
| 1034 | all X events that don't pertain to the menu. */ | ||
| 1035 | struct event_queue | ||
| 1036 | { | ||
| 1037 | XEvent event; | ||
| 1038 | struct event_queue *next; | ||
| 1039 | }; | ||
| 1040 | |||
| 1041 | struct event_queue *queue = NULL; | ||
| 1042 | struct event_queue *queue_tmp; | 1052 | struct event_queue *queue_tmp; |
| 1053 | int count = SPECPDL_INDEX (); | ||
| 1054 | |||
| 1055 | popup_get_selection_queue = NULL; | ||
| 1056 | |||
| 1057 | record_unwind_protect (popup_get_selection_unwind, Qnil); | ||
| 1043 | 1058 | ||
| 1044 | if (initial_event) | 1059 | if (initial_event) |
| 1045 | event = *initial_event; | 1060 | event = *initial_event; |
| @@ -1100,23 +1115,38 @@ popup_get_selection (initial_event, dpyinfo, id) | |||
| 1100 | { | 1115 | { |
| 1101 | queue_tmp = (struct event_queue *) xmalloc (sizeof *queue_tmp); | 1116 | queue_tmp = (struct event_queue *) xmalloc (sizeof *queue_tmp); |
| 1102 | queue_tmp->event = event; | 1117 | queue_tmp->event = event; |
| 1103 | queue_tmp->next = queue; | 1118 | queue_tmp->next = popup_get_selection_queue; |
| 1104 | queue = queue_tmp; | 1119 | popup_get_selection_queue = queue_tmp; |
| 1105 | } | 1120 | } |
| 1106 | else | 1121 | else |
| 1107 | XtDispatchEvent (&event); | 1122 | XtDispatchEvent (&event); |
| 1108 | 1123 | ||
| 1109 | if (!popup_activated ()) | 1124 | /* If the event deactivated the menu, we are finished. */ |
| 1125 | if (!popup_activated_flag) | ||
| 1110 | break; | 1126 | break; |
| 1127 | |||
| 1128 | /* If we have no events to run, consider timers. */ | ||
| 1129 | if (do_timers && !XtAppPending (Xt_app_con)) | ||
| 1130 | timer_check (1); | ||
| 1131 | |||
| 1111 | XtAppNextEvent (Xt_app_con, &event); | 1132 | XtAppNextEvent (Xt_app_con, &event); |
| 1112 | } | 1133 | } |
| 1113 | 1134 | ||
| 1114 | /* Unread any events that we got but did not handle. */ | 1135 | unbind_to (count, Qnil); |
| 1115 | while (queue != NULL) | 1136 | } |
| 1137 | |||
| 1138 | /* Unread any events that popup_get_selection read but did not handle. */ | ||
| 1139 | |||
| 1140 | static Lisp_Object | ||
| 1141 | popup_get_selection_unwind (ignore) | ||
| 1142 | Lisp_Object ignore; | ||
| 1143 | { | ||
| 1144 | while (popup_get_selection_queue != NULL) | ||
| 1116 | { | 1145 | { |
| 1117 | queue_tmp = queue; | 1146 | struct event_queue *queue_tmp; |
| 1147 | queue_tmp = popup_get_selection_queue; | ||
| 1118 | XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event); | 1148 | XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event); |
| 1119 | queue = queue_tmp->next; | 1149 | popup_get_selection_queue = queue_tmp->next; |
| 1120 | xfree ((char *)queue_tmp); | 1150 | xfree ((char *)queue_tmp); |
| 1121 | /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ | 1151 | /* Cause these events to get read as soon as we UNBLOCK_INPUT. */ |
| 1122 | interrupt_input_pending = 1; | 1152 | interrupt_input_pending = 1; |
| @@ -2304,7 +2334,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error) | |||
| 2304 | popup_activated_flag = 1; | 2334 | popup_activated_flag = 1; |
| 2305 | 2335 | ||
| 2306 | /* Process events that apply to the menu. */ | 2336 | /* Process events that apply to the menu. */ |
| 2307 | popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id); | 2337 | popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 0); |
| 2308 | 2338 | ||
| 2309 | /* fp turned off the following statement and wrote a comment | 2339 | /* fp turned off the following statement and wrote a comment |
| 2310 | that it is unnecessary--that the menu has already disappeared. | 2340 | that it is unnecessary--that the menu has already disappeared. |
| @@ -2386,6 +2416,22 @@ dialog_selection_callback (widget, id, client_data) | |||
| 2386 | popup_activated_flag = 0; | 2416 | popup_activated_flag = 0; |
| 2387 | } | 2417 | } |
| 2388 | 2418 | ||
| 2419 | /* ARG is the LWLIB ID of the dialog box, represented | ||
| 2420 | as a Lisp object as (HIGHPART . LOWPART). */ | ||
| 2421 | |||
| 2422 | Lisp_Object | ||
| 2423 | xdialog_show_unwind (arg) | ||
| 2424 | Lisp_Object arg; | ||
| 2425 | { | ||
| 2426 | LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID) | ||
| 2427 | | XINT (XCDR (arg))); | ||
| 2428 | BLOCK_INPUT; | ||
| 2429 | lw_destroy_all_widgets (id); | ||
| 2430 | UNBLOCK_INPUT; | ||
| 2431 | popup_activated_flag = 0; | ||
| 2432 | return Qnil; | ||
| 2433 | } | ||
| 2434 | |||
| 2389 | static char * button_names [] = { | 2435 | static char * button_names [] = { |
| 2390 | "button1", "button2", "button3", "button4", "button5", | 2436 | "button1", "button2", "button3", "button4", "button5", |
| 2391 | "button6", "button7", "button8", "button9", "button10" }; | 2437 | "button6", "button7", "button8", "button9", "button10" }; |
| @@ -2399,7 +2445,6 @@ xdialog_show (f, keymaps, title, error) | |||
| 2399 | { | 2445 | { |
| 2400 | int i, nb_buttons=0; | 2446 | int i, nb_buttons=0; |
| 2401 | LWLIB_ID dialog_id; | 2447 | LWLIB_ID dialog_id; |
| 2402 | Widget menu; | ||
| 2403 | char dialog_name[6]; | 2448 | char dialog_name[6]; |
| 2404 | 2449 | ||
| 2405 | widget_value *wv, *first_wv = 0, *prev_wv = 0; | 2450 | widget_value *wv, *first_wv = 0, *prev_wv = 0; |
| @@ -2511,9 +2556,9 @@ xdialog_show (f, keymaps, title, error) | |||
| 2511 | 2556 | ||
| 2512 | /* Actually create the dialog. */ | 2557 | /* Actually create the dialog. */ |
| 2513 | dialog_id = widget_id_tick++; | 2558 | dialog_id = widget_id_tick++; |
| 2514 | menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, | 2559 | lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv, |
| 2515 | f->output_data.x->widget, 1, 0, | 2560 | f->output_data.x->widget, 1, 0, |
| 2516 | dialog_selection_callback, 0, 0); | 2561 | dialog_selection_callback, 0, 0); |
| 2517 | lw_modify_all_widgets (dialog_id, first_wv->contents, True); | 2562 | lw_modify_all_widgets (dialog_id, first_wv->contents, True); |
| 2518 | /* Free the widget_value objects we used to specify the contents. */ | 2563 | /* Free the widget_value objects we used to specify the contents. */ |
| 2519 | free_menubar_widget_value_tree (first_wv); | 2564 | free_menubar_widget_value_tree (first_wv); |
| @@ -2521,17 +2566,26 @@ xdialog_show (f, keymaps, title, error) | |||
| 2521 | /* No selection has been chosen yet. */ | 2566 | /* No selection has been chosen yet. */ |
| 2522 | menu_item_selection = 0; | 2567 | menu_item_selection = 0; |
| 2523 | 2568 | ||
| 2524 | /* Display the menu. */ | 2569 | /* Display the dialog box. */ |
| 2525 | lw_pop_up_all_widgets (dialog_id); | 2570 | lw_pop_up_all_widgets (dialog_id); |
| 2526 | popup_activated_flag = 1; | 2571 | popup_activated_flag = 1; |
| 2527 | 2572 | ||
| 2528 | /* Process events that apply to the menu. */ | 2573 | /* Process events that apply to the dialog box. |
| 2529 | popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id); | 2574 | Also handle timers. */ |
| 2575 | { | ||
| 2576 | int count = SPECPDL_INDEX (); | ||
| 2530 | 2577 | ||
| 2531 | lw_destroy_all_widgets (dialog_id); | 2578 | /* xdialog_show_unwind is responsible for popping the dialog box down. */ |
| 2579 | record_unwind_protect (xdialog_show_unwind, | ||
| 2580 | Fcons (make_number (dialog_id >> (4 * sizeof (LWLIB_ID))), | ||
| 2581 | make_number (dialog_id & ~(-1 << (4 * sizeof (LWLIB_ID)))))); | ||
| 2532 | 2582 | ||
| 2533 | /* Find the selected item, and its pane, to return | 2583 | popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), dialog_id, 1); |
| 2534 | the proper value. */ | 2584 | |
| 2585 | unbind_to (count, Qnil); | ||
| 2586 | } | ||
| 2587 | |||
| 2588 | /* Find the selected item and pane, and return the corresponding value. */ | ||
| 2535 | if (menu_item_selection != 0) | 2589 | if (menu_item_selection != 0) |
| 2536 | { | 2590 | { |
| 2537 | Lisp_Object prefix; | 2591 | Lisp_Object prefix; |