aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Djärv2004-11-12 10:34:36 +0000
committerJan Djärv2004-11-12 10:34:36 +0000
commitf1d1cd24db8ab975bbe9bf0c4260bd8025e8bd75 (patch)
tree19b13198ef853149844b60e7fe0f388d8123bca0
parentdf00f4364c61cb4d813a158d6f7d4f31e1ea4adf (diff)
downloademacs-f1d1cd24db8ab975bbe9bf0c4260bd8025e8bd75.tar.gz
emacs-f1d1cd24db8ab975bbe9bf0c4260bd8025e8bd75.zip
(pop_down_menu): New function.
(popup_get_selection, popup_widget_loop): Unwind protect to pop_down_menu. (popup_widget_loop): Add argument widget. (create_and_show_popup_menu, create_and_show_dialog): Pass new argument widget to popup_widget_loop.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xmenu.c44
2 files changed, 45 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b680abe8d4f..89002eaadd1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -10,6 +10,12 @@
10 x_menu_wait_for_event is called by XMenuActivate. 10 x_menu_wait_for_event is called by XMenuActivate.
11 (create_and_show_popup_menu): Pass 1 for do_timers to 11 (create_and_show_popup_menu): Pass 1 for do_timers to
12 popup_get_selection. 12 popup_get_selection.
13 (pop_down_menu): New function.
14 (popup_get_selection, popup_widget_loop): Unwind protect to
15 pop_down_menu.
16 (popup_widget_loop): Add argument widget.
17 (create_and_show_popup_menu, create_and_show_dialog): Pass new
18 argument widget to popup_widget_loop.
13 19
142004-11-10 Stefan Monnier <monnier@iro.umontreal.ca> 202004-11-10 Stefan Monnier <monnier@iro.umontreal.ca>
15 21
diff --git a/src/xmenu.c b/src/xmenu.c
index d8ab2eb58aa..d7551cd7e45 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1132,7 +1132,7 @@ x_menu_wait_for_event (void *data)
1132 1132
1133 while ( 1133 while (
1134#ifdef USE_X_TOOLKIT 1134#ifdef USE_X_TOOLKIT
1135 XtAppPending (Xt_app_con) 1135 ! XtAppPending (Xt_app_con)
1136#elif defined USE_GTK 1136#elif defined USE_GTK
1137 ! gtk_events_pending () 1137 ! gtk_events_pending ()
1138#else 1138#else
@@ -1171,6 +1171,15 @@ x_menu_wait_for_event (void *data)
1171 1171
1172#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 1172#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
1173 1173
1174#ifdef USE_X_TOOLKIT
1175
1176static Lisp_Object
1177pop_down_menu (dummy)
1178 int dummy;
1179{
1180 popup_activated_flag = 0;
1181}
1182
1174/* Loop in Xt until the menu pulldown or dialog popup has been 1183/* Loop in Xt until the menu pulldown or dialog popup has been
1175 popped down (deactivated). This is used for x-popup-menu 1184 popped down (deactivated). This is used for x-popup-menu
1176 and x-popup-dialog; it is not used for the menu bar. 1185 and x-popup-dialog; it is not used for the menu bar.
@@ -1180,7 +1189,6 @@ x_menu_wait_for_event (void *data)
1180 NOTE: All calls to popup_get_selection should be protected 1189 NOTE: All calls to popup_get_selection should be protected
1181 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */ 1190 with BLOCK_INPUT, UNBLOCK_INPUT wrappers. */
1182 1191
1183#ifdef USE_X_TOOLKIT
1184static void 1192static void
1185popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress) 1193popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1186 XEvent *initial_event; 1194 XEvent *initial_event;
@@ -1191,6 +1199,9 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1191{ 1199{
1192 XEvent event; 1200 XEvent event;
1193 1201
1202 int specpdl_count = SPECPDL_INDEX ();
1203 record_unwind_protect (pop_down_menu, Qnil);
1204
1194 while (popup_activated_flag) 1205 while (popup_activated_flag)
1195 { 1206 {
1196 if (initial_event) 1207 if (initial_event)
@@ -1240,6 +1251,8 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1240 1251
1241 x_dispatch_event (&event, event.xany.display); 1252 x_dispatch_event (&event, event.xany.display);
1242 } 1253 }
1254
1255 unbind_to (specpdl_count, Qnil);
1243} 1256}
1244 1257
1245#endif /* USE_X_TOOLKIT */ 1258#endif /* USE_X_TOOLKIT */
@@ -1247,10 +1260,29 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1247#ifdef USE_GTK 1260#ifdef USE_GTK
1248/* Loop util popup_activated_flag is set to zero in a callback. 1261/* Loop util popup_activated_flag is set to zero in a callback.
1249 Used for popup menus and dialogs. */ 1262 Used for popup menus and dialogs. */
1263static GtkWidget *current_menu;
1264
1265static Lisp_Object
1266pop_down_menu (dummy)
1267 int dummy;
1268{
1269 if (current_menu)
1270 {
1271 gtk_widget_unmap (current_menu);
1272 current_menu = 0;
1273 popup_activated_flag = 0;
1274 }
1275}
1276
1250static void 1277static void
1251popup_widget_loop (do_timers) 1278popup_widget_loop (do_timers, widget)
1252 int do_timers; 1279 int do_timers;
1280 GtkWidget *widget;
1253{ 1281{
1282 int specpdl_count = SPECPDL_INDEX ();
1283 current_menu = widget;
1284 record_unwind_protect (pop_down_menu, Qnil);
1285
1254 ++popup_activated_flag; 1286 ++popup_activated_flag;
1255 1287
1256 /* Process events in the Gtk event loop until done. */ 1288 /* Process events in the Gtk event loop until done. */
@@ -1259,6 +1291,8 @@ popup_widget_loop (do_timers)
1259 if (do_timers) x_menu_wait_for_event (0); 1291 if (do_timers) x_menu_wait_for_event (0);
1260 gtk_main_iteration (); 1292 gtk_main_iteration ();
1261 } 1293 }
1294
1295 unbind_to (specpdl_count, Qnil);
1262} 1296}
1263#endif 1297#endif
1264 1298
@@ -2456,7 +2490,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2456 two. show_help_echo uses this to detect popup menus. */ 2490 two. show_help_echo uses this to detect popup menus. */
2457 popup_activated_flag = 1; 2491 popup_activated_flag = 1;
2458 /* Process events that apply to the menu. */ 2492 /* Process events that apply to the menu. */
2459 popup_widget_loop (1); 2493 popup_widget_loop (1, 0);
2460 2494
2461 gtk_widget_destroy (menu); 2495 gtk_widget_destroy (menu);
2462 2496
@@ -2865,7 +2899,7 @@ create_and_show_dialog (f, first_wv)
2865 gtk_widget_show_all (menu); 2899 gtk_widget_show_all (menu);
2866 2900
2867 /* Process events that apply to the menu. */ 2901 /* Process events that apply to the menu. */
2868 popup_widget_loop (1); 2902 popup_widget_loop (1, menu);
2869 2903
2870 gtk_widget_destroy (menu); 2904 gtk_widget_destroy (menu);
2871 } 2905 }