comparison src/w32menu.c @ 15276:07341673efa6

Include buffer.h. (set_frame_menubar): Make sure input is unblocked when we call create_menu_items. Switch temporarily to proper buffer, bind inhibit-quit to t, and run the same hooks as in smenu.c. (syms_of_win32menu): Initialize and staticpro Qdebug_on_next_call.
author Richard M. Stallman <rms@gnu.org>
date Tue, 21 May 1996 18:09:43 +0000
parents 5a9c77df2706
children 481b7874a1e9
comparison
equal deleted inserted replaced
15275:d57bb52c0242 15276:07341673efa6
28 #include "termhooks.h" 28 #include "termhooks.h"
29 #include "frame.h" 29 #include "frame.h"
30 #include "window.h" 30 #include "window.h"
31 #include "keyboard.h" 31 #include "keyboard.h"
32 #include "blockinput.h" 32 #include "blockinput.h"
33 #include "buffer.h"
33 34
34 /* This may include sys/types.h, and that somehow loses 35 /* This may include sys/types.h, and that somehow loses
35 if this is not done before the other system files. */ 36 if this is not done before the other system files. */
36 #include "w32term.h" 37 #include "w32term.h"
37 38
51 Lisp_Object menu_items; 52 Lisp_Object menu_items;
52 int menu_items_allocated; 53 int menu_items_allocated;
53 int menu_items_used; 54 int menu_items_used;
54 } menu_map; 55 } menu_map;
55 56
57 Lisp_Object Qdebug_on_next_call;
58
56 extern Lisp_Object Qmenu_enable; 59 extern Lisp_Object Qmenu_enable;
57 extern Lisp_Object Qmenu_bar; 60 extern Lisp_Object Qmenu_bar;
61
62 extern Lisp_Object Voverriding_local_map;
63 extern Lisp_Object Voverriding_local_map_menu_flag;
64
65 extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
66
67 extern Lisp_Object Qmenu_bar_update_hook;
58 68
59 static Lisp_Object win32_dialog_show (); 69 static Lisp_Object win32_dialog_show ();
60 static Lisp_Object win32menu_show (); 70 static Lisp_Object win32menu_show ();
61 71
62 static HMENU keymap_panes (); 72 static HMENU keymap_panes ();
1382 Lisp_Object tail, items; 1392 Lisp_Object tail, items;
1383 HMENU hmenu; 1393 HMENU hmenu;
1384 int i; 1394 int i;
1385 struct gcpro gcpro1; 1395 struct gcpro gcpro1;
1386 menu_map mm; 1396 menu_map mm;
1397 int count = specpdl_ptr - specpdl;
1398
1399 struct buffer *prev = current_buffer;
1400 Lisp_Object buffer;
1401
1402 buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
1403 specbind (Qinhibit_quit, Qt);
1404 /* Don't let the debugger step into this code
1405 because it is not reentrant. */
1406 specbind (Qdebug_on_next_call, Qnil);
1407
1408 record_unwind_protect (Fstore_match_data, Fmatch_data ());
1409 if (NILP (Voverriding_local_map_menu_flag))
1410 {
1411 specbind (Qoverriding_terminal_local_map, Qnil);
1412 specbind (Qoverriding_local_map, Qnil);
1413 }
1414
1415 set_buffer_internal_1 (XBUFFER (buffer));
1416
1417 /* Run the Lucid hook. */
1418 call1 (Vrun_hooks, Qactivate_menubar_hook);
1419 /* If it has changed current-menubar from previous value,
1420 really recompute the menubar from the value. */
1421 if (! NILP (Vlucid_menu_bar_dirty_flag))
1422 call0 (Qrecompute_lucid_menubar);
1423 safe_run_hooks (Qmenu_bar_update_hook);
1387 1424
1388 BLOCK_INPUT; 1425 BLOCK_INPUT;
1389 1426
1390 GCPRO1 (items); 1427 GCPRO1 (items);
1391 1428
1392 if (NILP (items = FRAME_MENU_BAR_ITEMS (f))) 1429 items = FRAME_MENU_BAR_ITEMS (f);
1430 if (NILP (items))
1393 items = FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 1431 items = FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
1394 1432
1395 hmenu = CreateMenu (); 1433 hmenu = CreateMenu ();
1396 1434
1397 if (!hmenu) goto error; 1435 if (!hmenu) goto error;
1398 1436
1399 discard_menu_items (&mm); 1437 discard_menu_items (&mm);
1438 UNBLOCK_INPUT;
1400 1439
1401 for (i = 0; i < XVECTOR (items)->size; i += 4) 1440 for (i = 0; i < XVECTOR (items)->size; i += 4)
1402 { 1441 {
1403 Lisp_Object string; 1442 Lisp_Object string;
1404 int keymaps; 1443 int keymaps;
1407 1446
1408 string = XVECTOR (items)->contents[i + 1]; 1447 string = XVECTOR (items)->contents[i + 1];
1409 if (NILP (string)) 1448 if (NILP (string))
1410 break; 1449 break;
1411 1450
1451 /* Input must not be blocked here
1452 because we call general Lisp code and internal_condition_case_1. */
1412 new_hmenu = create_menu_items (&mm, 1453 new_hmenu = create_menu_items (&mm,
1413 XVECTOR (items)->contents[i + 2], 1454 XVECTOR (items)->contents[i + 2],
1414 0); 1455 0);
1415 1456
1416 if (!new_hmenu) 1457 if (!new_hmenu)
1417 continue; 1458 continue;
1418 1459
1460 BLOCK_INPUT;
1419 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu, 1461 AppendMenu (hmenu, MF_POPUP, (UINT)new_hmenu,
1420 (char *) XSTRING (string)->data); 1462 (char *) XSTRING (string)->data);
1421 } 1463 UNBLOCK_INPUT;
1422 1464 }
1465
1466 BLOCK_INPUT;
1423 { 1467 {
1424 HMENU old = GetMenu (FRAME_WIN32_WINDOW (f)); 1468 HMENU old = GetMenu (FRAME_WIN32_WINDOW (f));
1425 SetMenu (FRAME_WIN32_WINDOW (f), hmenu); 1469 SetMenu (FRAME_WIN32_WINDOW (f), hmenu);
1426 DestroyMenu (old); 1470 DestroyMenu (old);
1427 } 1471 }
1428 1472
1429 error: 1473 error:
1474 set_buffer_internal_1 (prev);
1430 UNGCPRO; 1475 UNGCPRO;
1431 UNBLOCK_INPUT; 1476 UNBLOCK_INPUT;
1477 unbind_to (count, Qnil);
1432 } 1478 }
1433 1479
1434 void 1480 void
1435 free_frame_menubar (f) 1481 free_frame_menubar (f)
1436 FRAME_PTR f; 1482 FRAME_PTR f;
1911 } 1957 }
1912 #endif 1958 #endif
1913 1959
1914 syms_of_win32menu () 1960 syms_of_win32menu ()
1915 { 1961 {
1962 Qdebug_on_next_call = intern ("debug-on-next-call");
1963 staticpro (&Qdebug_on_next_call);
1964
1916 defsubr (&Sx_popup_menu); 1965 defsubr (&Sx_popup_menu);
1917 defsubr (&Sx_popup_dialog); 1966 defsubr (&Sx_popup_dialog);
1918 } 1967 }