comparison src/xmenu.c @ 58215:8f529503ae83

* 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.
author Jan Djärv <jan.h.d@swipnet.se>
date Sun, 14 Nov 2004 10:55:45 +0000
parents 54c649507b74
children 7f6d41c2adbe
comparison
equal deleted inserted replaced
58214:aaad85fd645c 58215:8f529503ae83
2425 2425
2426 if (xg_crazy_callback_abort) return; 2426 if (xg_crazy_callback_abort) return;
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
2430 static GtkWidget *current_menu;
2431
2432 static Lisp_Object 2430 static Lisp_Object
2433 pop_down_menu (dummy) 2431 pop_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
2447 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 2443 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2448 menu pops down. 2444 menu pops down.
2488 2484
2489 /* Display the menu. */ 2485 /* Display the menu. */
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. */
2498 popup_activated_flag = 1; 2494 popup_activated_flag = 1;
2499 /* Process events that apply to the menu. */ 2495 /* Process events that apply to the menu. */
2923 0); 2919 0);
2924 2920
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);
2933 2928
2934 /* Process events that apply to the menu. */ 2929 /* Process events that apply to the menu. */
3215 Fcons (make_number (pane), Qnil))); 3210 Fcons (make_number (pane), Qnil)));
3216 show_help_echo (help_string ? build_string (help_string) : Qnil, 3211 show_help_echo (help_string ? build_string (help_string) : Qnil,
3217 Qnil, menu_object, make_number (item), 1); 3212 Qnil, menu_object, make_number (item), 1);
3218 } 3213 }
3219 3214
3220 static XMenu *current_menu;
3221
3222 static Lisp_Object 3215 static Lisp_Object
3223 pop_down_menu (frame) 3216 pop_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.
3241 If it has actually moved in, we will get an EnterNotify. */ 3234 If it has actually moved in, we will get an EnterNotify. */
3242 x_mouse_leave (FRAME_X_DISPLAY_INFO (f)); 3235 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
3265 char **error; 3258 char **error;
3266 { 3259 {
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;
3274 int i, j; 3267 int i, j;
3275 int maxwidth; 3268 int maxwidth;
3467 3460
3468 #ifndef MSDOS 3461 #ifndef MSDOS
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);
3482 3475
3483 switch (status) 3476 switch (status)