aboutsummaryrefslogtreecommitdiffstats
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorKaroly Lorentey2004-11-22 11:06:39 +0000
committerKaroly Lorentey2004-11-22 11:06:39 +0000
commit71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23 (patch)
tree63f61c3bebc83c114c16f31dd4ac2b9c0fe17c7d /src/xmenu.c
parente417405015c93c81641f5c4a33ec898b5c353772 (diff)
parent83aebfe62204109f19ef7dcca5429c1ddad21c57 (diff)
downloademacs-71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23.tar.gz
emacs-71925ac335f7c3b1fd97fba98cb5b9b4f03a6e23.zip
Merged in changes from CVS trunk.
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-694 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-695 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-696 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-697 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-698 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-699 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-700 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-701 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-702 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-703 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-704 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-705 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-706 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-707 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-708 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-711 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-712 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-713 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-72 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-73 Merge from emacs--cvs-trunk--0 git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-268
Diffstat (limited to 'src/xmenu.c')
-rw-r--r--src/xmenu.c187
1 files changed, 107 insertions, 80 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index 0a83266a482..f50237ea8c8 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -288,7 +288,7 @@ finish_menu_items ()
288 288
289static Lisp_Object 289static Lisp_Object
290unuse_menu_items (dummy) 290unuse_menu_items (dummy)
291 int dummy; 291 Lisp_Object dummy;
292{ 292{
293 return menu_items_inuse = Qnil; 293 return menu_items_inuse = Qnil;
294} 294}
@@ -1118,9 +1118,19 @@ on the left of the dialog box and all following items on the right.
1118 1118
1119#ifndef MSDOS 1119#ifndef MSDOS
1120 1120
1121/* Set menu_items_inuse so no other popup menu or dialog is created. */
1122
1123void
1124x_menu_set_in_use (in_use)
1125 int in_use;
1126{
1127 menu_items_inuse = in_use ? Qt : Qnil;
1128 popup_activated_flag = in_use;
1129}
1130
1121/* Wait for an X event to arrive or for a timer to expire. */ 1131/* Wait for an X event to arrive or for a timer to expire. */
1122 1132
1123static void 1133void
1124x_menu_wait_for_event (void *data) 1134x_menu_wait_for_event (void *data)
1125{ 1135{
1126 extern EMACS_TIME timer_check P_ ((int)); 1136 extern EMACS_TIME timer_check P_ ((int));
@@ -1173,14 +1183,6 @@ x_menu_wait_for_event (void *data)
1173 1183
1174#ifdef USE_X_TOOLKIT 1184#ifdef USE_X_TOOLKIT
1175 1185
1176static Lisp_Object
1177pop_down_menu (dummy)
1178 int dummy;
1179{
1180 popup_activated_flag = 0;
1181 return Qnil;
1182}
1183
1184/* Loop in Xt until the menu pulldown or dialog popup has been 1186/* Loop in Xt until the menu pulldown or dialog popup has been
1185 popped down (deactivated). This is used for x-popup-menu 1187 popped down (deactivated). This is used for x-popup-menu
1186 and x-popup-dialog; it is not used for the menu bar. 1188 and x-popup-dialog; it is not used for the menu bar.
@@ -1200,9 +1202,6 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1200{ 1202{
1201 XEvent event; 1203 XEvent event;
1202 1204
1203 int specpdl_count = SPECPDL_INDEX ();
1204 record_unwind_protect (pop_down_menu, Qnil);
1205
1206 while (popup_activated_flag) 1205 while (popup_activated_flag)
1207 { 1206 {
1208 if (initial_event) 1207 if (initial_event)
@@ -1252,8 +1251,6 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1252 1251
1253 x_dispatch_event (&event, event.xany.display); 1252 x_dispatch_event (&event, event.xany.display);
1254 } 1253 }
1255
1256 unbind_to (specpdl_count, Qnil);
1257} 1254}
1258 1255
1259#endif /* USE_X_TOOLKIT */ 1256#endif /* USE_X_TOOLKIT */
@@ -1261,30 +1258,12 @@ popup_get_selection (initial_event, dpyinfo, id, do_timers, down_on_keypress)
1261#ifdef USE_GTK 1258#ifdef USE_GTK
1262/* Loop util popup_activated_flag is set to zero in a callback. 1259/* Loop util popup_activated_flag is set to zero in a callback.
1263 Used for popup menus and dialogs. */ 1260 Used for popup menus and dialogs. */
1264static GtkWidget *current_menu;
1265
1266static Lisp_Object
1267pop_down_menu (dummy)
1268 int dummy;
1269{
1270 if (current_menu)
1271 {
1272 gtk_widget_unmap (current_menu);
1273 current_menu = 0;
1274 popup_activated_flag = 0;
1275 }
1276 return Qnil;
1277}
1278 1261
1279static void 1262static void
1280popup_widget_loop (do_timers, widget) 1263popup_widget_loop (do_timers, widget)
1281 int do_timers; 1264 int do_timers;
1282 GtkWidget *widget; 1265 GtkWidget *widget;
1283{ 1266{
1284 int specpdl_count = SPECPDL_INDEX ();
1285 current_menu = widget;
1286 record_unwind_protect (pop_down_menu, Qnil);
1287
1288 ++popup_activated_flag; 1267 ++popup_activated_flag;
1289 1268
1290 /* Process events in the Gtk event loop until done. */ 1269 /* Process events in the Gtk event loop until done. */
@@ -1293,8 +1272,6 @@ popup_widget_loop (do_timers, widget)
1293 if (do_timers) x_menu_wait_for_event (0); 1272 if (do_timers) x_menu_wait_for_event (0);
1294 gtk_main_iteration (); 1273 gtk_main_iteration ();
1295 } 1274 }
1296
1297 unbind_to (specpdl_count, Qnil);
1298} 1275}
1299#endif 1276#endif
1300 1277
@@ -2443,6 +2420,19 @@ popup_selection_callback (widget, client_data)
2443 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data; 2420 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data;
2444} 2421}
2445 2422
2423static Lisp_Object
2424pop_down_menu (arg)
2425 Lisp_Object arg;
2426{
2427 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
2428
2429 popup_activated_flag = 0;
2430 BLOCK_INPUT;
2431 gtk_widget_destroy (GTK_WIDGET (p->pointer));
2432 UNBLOCK_INPUT;
2433 return Qnil;
2434}
2435
2446/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 2436/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2447 menu pops down. 2437 menu pops down.
2448 menu_item_selection will be set to the selection. */ 2438 menu_item_selection will be set to the selection. */
@@ -2458,6 +2448,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2458 GtkWidget *menu; 2448 GtkWidget *menu;
2459 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */ 2449 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
2460 struct next_popup_x_y popup_x_y; 2450 struct next_popup_x_y popup_x_y;
2451 int specpdl_count = SPECPDL_INDEX ();
2461 2452
2462 xg_crazy_callback_abort = 1; 2453 xg_crazy_callback_abort = 1;
2463 menu = xg_create_widget ("popup", first_wv->name, f, first_wv, 2454 menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
@@ -2488,13 +2479,15 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2488 gtk_widget_show_all (menu); 2479 gtk_widget_show_all (menu);
2489 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); 2480 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
2490 2481
2482 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2483
2491 /* Set this to one. popup_widget_loop increases it by one, so it becomes 2484 /* Set this to one. popup_widget_loop increases it by one, so it becomes
2492 two. show_help_echo uses this to detect popup menus. */ 2485 two. show_help_echo uses this to detect popup menus. */
2493 popup_activated_flag = 1; 2486 popup_activated_flag = 1;
2494 /* Process events that apply to the menu. */ 2487 /* Process events that apply to the menu. */
2495 popup_widget_loop (1, 0); 2488 popup_widget_loop (1, menu);
2496 2489
2497 gtk_widget_destroy (menu); 2490 unbind_to (specpdl_count, Qnil);
2498 2491
2499 /* Must reset this manually because the button release event is not passed 2492 /* Must reset this manually because the button release event is not passed
2500 to Emacs event loop. */ 2493 to Emacs event loop. */
@@ -2522,6 +2515,24 @@ popup_selection_callback (widget, id, client_data)
2522 menu_item_selection = (Lisp_Object *) client_data; 2515 menu_item_selection = (Lisp_Object *) client_data;
2523} 2516}
2524 2517
2518/* ARG is the LWLIB ID of the dialog box, represented
2519 as a Lisp object as (HIGHPART . LOWPART). */
2520
2521static Lisp_Object
2522pop_down_menu (arg)
2523 Lisp_Object arg;
2524{
2525 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
2526 | XINT (XCDR (arg)));
2527
2528 BLOCK_INPUT;
2529 lw_destroy_all_widgets (id);
2530 UNBLOCK_INPUT;
2531 popup_activated_flag = 0;
2532
2533 return Qnil;
2534}
2535
2525/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 2536/* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
2526 menu pops down. 2537 menu pops down.
2527 menu_item_selection will be set to the selection. */ 2538 menu_item_selection will be set to the selection. */
@@ -2578,15 +2589,19 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2578 /* Display the menu. */ 2589 /* Display the menu. */
2579 lw_popup_menu (menu, (XEvent *) &dummy); 2590 lw_popup_menu (menu, (XEvent *) &dummy);
2580 popup_activated_flag = 1; 2591 popup_activated_flag = 1;
2592
2593 {
2594 int fact = 4 * sizeof (LWLIB_ID);
2595 int specpdl_count = SPECPDL_INDEX ();
2596 record_unwind_protect (pop_down_menu,
2597 Fcons (make_number (menu_id >> (fact)),
2598 make_number (menu_id & ~(-1 << (fact)))));
2581 2599
2582 /* Process events that apply to the menu. */ 2600 /* Process events that apply to the menu. */
2583 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0); 2601 popup_get_selection ((XEvent *) 0, FRAME_X_DISPLAY_INFO (f), menu_id, 1, 0);
2584 2602
2585 /* fp turned off the following statement and wrote a comment 2603 unbind_to (specpdl_count, Qnil);
2586 that it is unnecessary--that the menu has already disappeared. 2604 }
2587 Nowadays the menu disappears ok, all right, but
2588 we need to delete the widgets or multiple ones will pile up. */
2589 lw_destroy_all_widgets (menu_id);
2590} 2605}
2591 2606
2592#endif /* not USE_GTK */ 2607#endif /* not USE_GTK */
@@ -2897,13 +2912,16 @@ create_and_show_dialog (f, first_wv)
2897 2912
2898 if (menu) 2913 if (menu)
2899 { 2914 {
2915 int specpdl_count = SPECPDL_INDEX ();
2916 record_unwind_protect (pop_down_menu, make_save_value (menu, 0));
2917
2900 /* Display the menu. */ 2918 /* Display the menu. */
2901 gtk_widget_show_all (menu); 2919 gtk_widget_show_all (menu);
2902 2920
2903 /* Process events that apply to the menu. */ 2921 /* Process events that apply to the menu. */
2904 popup_widget_loop (1, menu); 2922 popup_widget_loop (1, menu);
2905 2923
2906 gtk_widget_destroy (menu); 2924 unbind_to (specpdl_count, Qnil);
2907 } 2925 }
2908} 2926}
2909 2927
@@ -2926,23 +2944,6 @@ dialog_selection_callback (widget, id, client_data)
2926} 2944}
2927 2945
2928 2946
2929/* ARG is the LWLIB ID of the dialog box, represented
2930 as a Lisp object as (HIGHPART . LOWPART). */
2931
2932Lisp_Object
2933xdialog_show_unwind (arg)
2934 Lisp_Object arg;
2935{
2936 LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
2937 | XINT (XCDR (arg)));
2938 BLOCK_INPUT;
2939 lw_destroy_all_widgets (id);
2940 UNBLOCK_INPUT;
2941 popup_activated_flag = 0;
2942 return Qnil;
2943}
2944
2945
2946/* Pop up the dialog for frame F defined by FIRST_WV and loop until the 2947/* Pop up the dialog for frame F defined by FIRST_WV and loop until the
2947 dialog pops down. 2948 dialog pops down.
2948 menu_item_selection will be set to the selection. */ 2949 menu_item_selection will be set to the selection. */
@@ -2970,7 +2971,7 @@ create_and_show_dialog (f, first_wv)
2970 int fact = 4 * sizeof (LWLIB_ID); 2971 int fact = 4 * sizeof (LWLIB_ID);
2971 2972
2972 /* xdialog_show_unwind is responsible for popping the dialog box down. */ 2973 /* xdialog_show_unwind is responsible for popping the dialog box down. */
2973 record_unwind_protect (xdialog_show_unwind, 2974 record_unwind_protect (pop_down_menu,
2974 Fcons (make_number (dialog_id >> (fact)), 2975 Fcons (make_number (dialog_id >> (fact)),
2975 make_number (dialog_id & ~(-1 << (fact))))); 2976 make_number (dialog_id & ~(-1 << (fact)))));
2976 2977
@@ -3203,6 +3204,41 @@ menu_help_callback (help_string, pane, item)
3203 Qnil, menu_object, make_number (item), 1); 3204 Qnil, menu_object, make_number (item), 1);
3204} 3205}
3205 3206
3207static Lisp_Object
3208pop_down_menu (arg)
3209 Lisp_Object arg;
3210{
3211 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
3212 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
3213
3214 FRAME_PTR f = p1->pointer;
3215 XMenu *menu = p2->pointer;
3216
3217 BLOCK_INPUT;
3218#ifndef MSDOS
3219 XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
3220 XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
3221#endif
3222 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
3223
3224#ifdef HAVE_X_WINDOWS
3225 /* Assume the mouse has moved out of the X window.
3226 If it has actually moved in, we will get an EnterNotify. */
3227 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
3228
3229 /* State that no mouse buttons are now held.
3230 (The oldXMenu code doesn't track this info for us.)
3231 That is not necessarily true, but the fiction leads to reasonable
3232 results, and it is a pain to ask which are actually held now. */
3233 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
3234
3235#endif /* HAVE_X_WINDOWS */
3236
3237 UNBLOCK_INPUT;
3238
3239 return Qnil;
3240}
3241
3206 3242
3207static Lisp_Object 3243static Lisp_Object
3208xmenu_show (f, x, y, for_click, keymaps, title, error) 3244xmenu_show (f, x, y, for_click, keymaps, title, error)
@@ -3224,6 +3260,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3224 int maxwidth; 3260 int maxwidth;
3225 int dummy_int; 3261 int dummy_int;
3226 unsigned int dummy_uint; 3262 unsigned int dummy_uint;
3263 int specpdl_count = SPECPDL_INDEX ();
3227 3264
3228 *error = 0; 3265 *error = 0;
3229 if (menu_items_n_panes == 0) 3266 if (menu_items_n_panes == 0)
@@ -3416,20 +3453,17 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3416#ifndef MSDOS 3453#ifndef MSDOS
3417 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 3454 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
3418#endif 3455#endif
3456
3457 record_unwind_protect (pop_down_menu,
3458 Fcons (make_save_value (f, 0),
3459 make_save_value (menu, 0)));
3419 3460
3420 /* Help display under X won't work because XMenuActivate contains 3461 /* Help display under X won't work because XMenuActivate contains
3421 a loop that doesn't give Emacs a chance to process it. */ 3462 a loop that doesn't give Emacs a chance to process it. */
3422 menu_help_frame = f; 3463 menu_help_frame = f;
3423 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, 3464 status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx,
3424 x, y, ButtonReleaseMask, &datap, 3465 x, y, ButtonReleaseMask, &datap,
3425 menu_help_callback); 3466 menu_help_callback);
3426
3427
3428#ifdef HAVE_X_WINDOWS
3429 /* Assume the mouse has moved out of the X window.
3430 If it has actually moved in, we will get an EnterNotify. */
3431 x_mouse_leave (FRAME_X_DISPLAY_INFO (f));
3432#endif
3433 3467
3434 switch (status) 3468 switch (status)
3435 { 3469 {
@@ -3480,15 +3514,8 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3480 entry = Qnil; 3514 entry = Qnil;
3481 break; 3515 break;
3482 } 3516 }
3483 XMenuDestroy (FRAME_X_DISPLAY (f), menu);
3484 3517
3485#ifdef HAVE_X_WINDOWS 3518 unbind_to (specpdl_count, Qnil);
3486 /* State that no mouse buttons are now held.
3487 (The oldXMenu code doesn't track this info for us.)
3488 That is not necessarily true, but the fiction leads to reasonable
3489 results, and it is a pain to ask which are actually held now. */
3490 FRAME_X_DISPLAY_INFO (f)->grabbed = 0;
3491#endif
3492 3519
3493 return entry; 3520 return entry;
3494} 3521}