aboutsummaryrefslogtreecommitdiffstats
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorJan Djärv2004-11-14 10:55:45 +0000
committerJan Djärv2004-11-14 10:55:45 +0000
commita130b9017fde7be1abfcab3bd2b74ab0b50bf1a5 (patch)
treeccd5acfb0cb1ebf7fa96475a5a20650b0a680b25 /src/xmenu.c
parent24ca7c5a6fba97df0e29f3de6dd7d5e16b028bf2 (diff)
downloademacs-a130b9017fde7be1abfcab3bd2b74ab0b50bf1a5.tar.gz
emacs-a130b9017fde7be1abfcab3bd2b74ab0b50bf1a5.zip
* xmenu.c (pop_down_menu): Remove global variable current_menu,
extract pointer from arg with XSAVE_VALUE. (create_and_show_popup_menu, create_and_show_dialog, xmenu_show): Construct arg to record_unwind_protect with make_save_value.
Diffstat (limited to 'src/xmenu.c')
-rw-r--r--src/xmenu.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index 38f101ec260..b0d4517c861 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -2427,20 +2427,16 @@ popup_selection_callback (widget, client_data)
2427 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data; 2427 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data;
2428} 2428}
2429 2429
2430static GtkWidget *current_menu;
2431
2432static Lisp_Object 2430static Lisp_Object
2433pop_down_menu (dummy) 2431pop_down_menu (arg)
2434 Lisp_Object dummy; 2432 Lisp_Object arg;
2435{ 2433{
2434 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
2435
2436 popup_activated_flag = 0; 2436 popup_activated_flag = 0;
2437 if (current_menu) 2437 BLOCK_INPUT;
2438 { 2438 gtk_widget_destroy (GTK_WIDGET (p->pointer));
2439 BLOCK_INPUT; 2439 UNBLOCK_INPUT;
2440 gtk_widget_destroy (current_menu);
2441 UNBLOCK_INPUT;
2442 current_menu = 0;
2443 }
2444 return Qnil; 2440 return Qnil;
2445} 2441}
2446 2442
@@ -2490,8 +2486,8 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2490 gtk_widget_show_all (menu); 2486 gtk_widget_show_all (menu);
2491 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); 2487 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
2492 2488
2493 current_menu = menu; 2489 fprintf (stderr, "Unwind: %p\n", menu);
2494 record_unwind_protect (pop_down_menu, Qnil); 2490 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2495 2491
2496 /* Set this to one. popup_widget_loop increases it by one, so it becomes 2492 /* Set this to one. popup_widget_loop increases it by one, so it becomes
2497 two. show_help_echo uses this to detect popup menus. */ 2493 two. show_help_echo uses this to detect popup menus. */
@@ -2925,8 +2921,7 @@ create_and_show_dialog (f, first_wv)
2925 if (menu) 2921 if (menu)
2926 { 2922 {
2927 int specpdl_count = SPECPDL_INDEX (); 2923 int specpdl_count = SPECPDL_INDEX ();
2928 current_menu = menu; 2924 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2929 record_unwind_protect (pop_down_menu, Qnil);
2930 2925
2931 /* Display the menu. */ 2926 /* Display the menu. */
2932 gtk_widget_show_all (menu); 2927 gtk_widget_show_all (menu);
@@ -3217,24 +3212,22 @@ menu_help_callback (help_string, pane, item)
3217 Qnil, menu_object, make_number (item), 1); 3212 Qnil, menu_object, make_number (item), 1);
3218} 3213}
3219 3214
3220static XMenu *current_menu;
3221
3222static Lisp_Object 3215static Lisp_Object
3223pop_down_menu (frame) 3216pop_down_menu (arg)
3224 Lisp_Object frame; 3217 Lisp_Object arg;
3225{ 3218{
3226 struct frame *f = XFRAME (frame); 3219 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
3220 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
3221
3222 FRAME_PTR f = p1->pointer;
3223 XMenu *menu = p2->pointer;
3227 3224
3228 BLOCK_INPUT; 3225 BLOCK_INPUT;
3229 if (current_menu)
3230 {
3231#ifndef MSDOS 3226#ifndef MSDOS
3232 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime); 3227 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
3233 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime); 3228 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
3234#endif 3229#endif
3235 XMenuDestroy (FRAME_X_DISPLAY (f), current_menu); 3230 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
3236 current_menu = 0;
3237 }
3238 3231
3239#ifdef HAVE_X_WINDOWS 3232#ifdef HAVE_X_WINDOWS
3240 /* Assume the mouse has moved out of the X window. 3233 /* Assume the mouse has moved out of the X window.
@@ -3267,7 +3260,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3267 Window root; 3260 Window root;
3268 XMenu *menu; 3261 XMenu *menu;
3269 int pane, selidx, lpane, status; 3262 int pane, selidx, lpane, status;
3270 Lisp_Object entry, pane_prefix, frame; 3263 Lisp_Object entry, pane_prefix;
3271 char *datap; 3264 char *datap;
3272 int ulx, uly, width, height; 3265 int ulx, uly, width, height;
3273 int dispwidth, dispheight; 3266 int dispwidth, dispheight;
@@ -3469,13 +3462,13 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3469 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 3462 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
3470#endif 3463#endif
3471 3464
3472 XSETFRAME (frame, f); 3465 record_unwind_protect (pop_down_menu,
3473 record_unwind_protect (pop_down_menu, frame); 3466 Fcons (make_save_value (f, 0),
3467 make_save_value (menu, 0)));
3474 3468
3475 /* Help display under X won't work because XMenuActivate contains 3469 /* Help display under X won't work because XMenuActivate contains
3476 a loop that doesn't give Emacs a chance to process it. */ 3470 a loop that doesn't give Emacs a chance to process it. */
3477 menu_help_frame = f; 3471 menu_help_frame = f;
3478 current_menu = menu;
3479 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, 3472 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
3480 x, y, ButtonReleaseMask, &datap, 3473 x, y, ButtonReleaseMask, &datap,
3481 menu_help_callback); 3474 menu_help_callback);