comparison src/menubar-x.c @ 1346:01c57eb70ae9

[xemacs-hg @ 2003-03-09 02:27:27 by ben] To: xemacs-patches@xemacs.org i.c: Sleep between calls to check for I/O, since these calls are non-blocking. behavior.el: Allow other keywords for forward compatibility. cl-macs.el: Rewrite to eliminate byte-compiler warning when `return' is used without `finally'. cmdloop.el: Avoid truncated error messages for `end-of-file' and the like. cmdloop.el: Avoid char-int error after syncing. files.el: Eliminate byte-compile warnings. printer.el: Fix line-width calculations. #### This used to work. Someone's changes (perhaps by Michael Sperber?) seem to have messed something up. simple.el: Use new clear-left-side functions to avoid messages ending up on the same line as other output. xemacs.mak: Add override for info/ as well when separate source/build dirs. xemacs.mak: Order sections in main build process and add comments. Add additional dependencies to try and prevent later steps from happening when failures in earlier steps have occurred. Makefile.in.in: Order sections in main build process and add comments. Add additional dependencies to try and prevent later steps from happening when failures in earlier steps have occurred. alloc.c: Don't arbitrarily clear Vconfigure_info_directory since it messes up separate build/source dirs. console.c, console.h, device-msw.c, device.c: Add accidentally omitted msprinter console and data descriptions. print.c, console-msw.c: Add clear-left-side functionality to help keep stdio/stderr output from separate sources on separate lines. Generalize the different kinds of debugging output. Add dpa(). profile.c: Add better docs on Unix/Windows differences. regex.c: Fix problems with rel-alloc compilation caused by previous patch. emacs.c: Seg fault rather than abort on Cygwin, since gdb doesn't trap aborts properly. console-gtk-impl.h, console-gtk.h, console-msw.h, console-x-impl.h, console-x.h, dialog-gtk.c, dialog-x.c, event-msw.c, frame-gtk.c, frame-x.c, frameslots.h, glyphs-gtk.c, glyphs-x.c, gui-gtk.c, gui-x.c, inline.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, scrollbar-gtk.c, scrollbar-x.c, ui-gtk.c: Delete popup-data object. Delete menubar_data field from frames, since its usage is frame-specific. Delete menubar-msw.h, gui-x.h, gui-gtk.h. Clean up handling of lwlib callback data GCPRO'ing and add missing GCPRO recomputation in widget code.
author ben
date Sun, 09 Mar 2003 02:27:46 +0000
parents 1b0339b048ce
children 59bf16be00bf
comparison
equal deleted inserted replaced
1345:3b27da507d56 1346:01c57eb70ae9
46 #include "menubar.h" 46 #include "menubar.h"
47 #include "opaque.h" 47 #include "opaque.h"
48 #include "window-impl.h" 48 #include "window-impl.h"
49 49
50 #include "console-x-impl.h" 50 #include "console-x-impl.h"
51 #include "gui-x.h"
52 51
53 #include "EmacsFrame.h" 52 #include "EmacsFrame.h"
54 #include "../lwlib/lwlib.h" 53 #include "../lwlib/lwlib.h"
55 54
56 static int set_frame_menubar (struct frame *f, 55 static int set_frame_menubar (struct frame *f,
57 int deep_p, 56 int deep_p,
58 int first_time_p); 57 int first_time_p);
59
60 #define FRAME_MENUBAR_DATA(frame) ((frame)->menubar_data)
61 #define XFRAME_MENUBAR_DATA(frame) XPOPUP_DATA ((frame)->menubar_data)
62 58
63 #define MENUBAR_TYPE 0 59 #define MENUBAR_TYPE 0
64 #define SUBMENU_TYPE 1 60 #define SUBMENU_TYPE 1
65 #define POPUP_TYPE 2 61 #define POPUP_TYPE 2
66 62
479 replace_widget_value_tree (hack_wv, wv->contents); 475 replace_widget_value_tree (hack_wv, wv->contents);
480 free_popup_widget_value_tree (wv); 476 free_popup_widget_value_tree (wv);
481 /* Now that we've destructively modified part of the widget value 477 /* Now that we've destructively modified part of the widget value
482 hierarchy, our list of protected callbacks will no longer be 478 hierarchy, our list of protected callbacks will no longer be
483 valid, so we need to recompute it. */ 479 valid, so we need to recompute it. */
484 snarf_widget_values_for_gcpro (FRAME_MENUBAR_DATA (f)); 480 gcpro_popup_callbacks (FRAME_X_MENUBAR_ID (f));
485 } 481 }
486 else if (!POPUP_DATAP (FRAME_MENUBAR_DATA (f))) 482 else if (!FRAME_X_MENUBAR_ID (f))
487 return; 483 return;
488 else 484 else
489 { 485 {
490 /* #### - It is necessary to *ALWAYS* call set_frame_menubar() now that 486 /* #### - It is necessary to *ALWAYS* call set_frame_menubar() now that
491 incremental menus are implemented. If a subtree of a menu has been 487 incremental menus are implemented. If a subtree of a menu has been
563 559
564 data = compute_menubar_data (f, menubar, deep_p); 560 data = compute_menubar_data (f, menubar, deep_p);
565 if (!data || (!data->next && !data->contents)) 561 if (!data || (!data->next && !data->contents))
566 abort (); 562 abort ();
567 563
568 if (NILP (FRAME_MENUBAR_DATA (f))) 564 if (!FRAME_X_MENUBAR_ID (f))
569 { 565 FRAME_X_MENUBAR_ID (f) = new_lwlib_id ();
570 struct popup_data *mdata =
571 alloc_lcrecord_type (struct popup_data, &lrecord_popup_data);
572
573 mdata->id = new_lwlib_id ();
574 mdata->last_menubar_buffer = Qnil;
575 mdata->protect_me = Qnil;
576 mdata->menubar_contents_up_to_date = 0;
577 FRAME_MENUBAR_DATA (f) = wrap_popup_data (mdata);
578 }
579 566
580 /***** now store into the menubar widget, creating it if necessary *****/ 567 /***** now store into the menubar widget, creating it if necessary *****/
581 568
582 id = XFRAME_MENUBAR_DATA (f)->id; 569 id = FRAME_X_MENUBAR_ID (f);
583 if (!FRAME_X_MENUBAR_WIDGET (f)) 570 if (!FRAME_X_MENUBAR_WIDGET (f))
584 { 571 {
585 Widget parent = FRAME_X_CONTAINER_WIDGET (f); 572 Widget parent = FRAME_X_CONTAINER_WIDGET (f);
586 573
587 assert (first_time_p); 574 assert (first_time_p);
610 597
611 /* Buried inside of the lwlib data are pointers to Lisp objects that may 598 /* Buried inside of the lwlib data are pointers to Lisp objects that may
612 have been freshly created. They need to be GC-protected, so snarf them 599 have been freshly created. They need to be GC-protected, so snarf them
613 now and record them into the popup-data object associated with the 600 now and record them into the popup-data object associated with the
614 frame. */ 601 frame. */
615 snarf_widget_values_for_gcpro (FRAME_MENUBAR_DATA (f)); 602 gcpro_popup_callbacks (id);
616 603
617 XFRAME_MENUBAR_DATA (f)->menubar_contents_up_to_date = deep_p; 604 FRAME_X_MENUBAR_CONTENTS_UP_TO_DATE (f) = deep_p;
618 XFRAME_MENUBAR_DATA (f)->last_menubar_buffer = 605 FRAME_X_LAST_MENUBAR_BUFFER (f) =
619 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer; 606 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer;
620 return menubar_visible; 607 return menubar_visible;
621 } 608 }
622 609
623 610
719 or if the current buffer has changed, or if the menubar has never 706 or if the current buffer has changed, or if the menubar has never
720 been updated before. 707 been updated before.
721 */ 708 */
722 int menubar_contents_changed = 709 int menubar_contents_changed =
723 (f->menubar_changed 710 (f->menubar_changed
724 || NILP (FRAME_MENUBAR_DATA (f)) 711 || !FRAME_X_MENUBAR_ID (f)
725 || (!EQ (XFRAME_MENUBAR_DATA (f)->last_menubar_buffer, 712 || (!EQ (FRAME_X_LAST_MENUBAR_BUFFER (f),
726 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer))); 713 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer)));
727 714
728 Boolean menubar_was_visible = XtIsManaged (FRAME_X_MENUBAR_WIDGET (f)); 715 Boolean menubar_was_visible = XtIsManaged (FRAME_X_MENUBAR_WIDGET (f));
729 Boolean menubar_will_be_visible = menubar_was_visible; 716 Boolean menubar_will_be_visible = menubar_was_visible;
730 Boolean menubar_visibility_changed; 717 Boolean menubar_visibility_changed;
763 assert (FRAME_X_P (f)); 750 assert (FRAME_X_P (f));
764 751
765 menubar_widget = FRAME_X_MENUBAR_WIDGET (f); 752 menubar_widget = FRAME_X_MENUBAR_WIDGET (f);
766 if (menubar_widget) 753 if (menubar_widget)
767 { 754 {
768 LWLIB_ID id = XFRAME_MENUBAR_DATA (f)->id; 755 LWLIB_ID id = FRAME_X_MENUBAR_ID (f);
769 lw_destroy_all_widgets (id); 756 lw_destroy_all_widgets (id);
770 XFRAME_MENUBAR_DATA (f)->id = 0; 757 ungcpro_popup_callbacks (id);
758 FRAME_X_MENUBAR_ID (f) = 0;
771 } 759 }
772 } 760 }
773 761
774 static void 762 static void
775 x_popup_menu (Lisp_Object menu_desc, Lisp_Object event) 763 x_popup_menu (Lisp_Object menu_desc, Lisp_Object event)
1232 Lisp_Object last = Qnil; 1220 Lisp_Object last = Qnil;
1233 struct gcpro gcpro1; 1221 struct gcpro gcpro1;
1234 Lisp_Object matchp; 1222 Lisp_Object matchp;
1235 1223
1236 widget_value *val; 1224 widget_value *val;
1237 LWLIB_ID id = XPOPUP_DATA (f->menubar_data)->id; 1225 LWLIB_ID id = FRAME_X_MENUBAR_ID (f);
1238 1226
1239 val = lw_get_all_values (id); 1227 val = lw_get_all_values (id);
1240 if (val) 1228 if (val)
1241 { 1229 {
1242 val = val->contents; 1230 val = val->contents;
1321 struct console *con = XCONSOLE (Vselected_console); 1309 struct console *con = XCONSOLE (Vselected_console);
1322 struct frame *f = XFRAME (CONSOLE_SELECTED_FRAME (con)); 1310 struct frame *f = XFRAME (CONSOLE_SELECTED_FRAME (con));
1323 LWLIB_ID id; 1311 LWLIB_ID id;
1324 widget_value *val; 1312 widget_value *val;
1325 1313
1326 if (NILP (f->menubar_data)) 1314 if (!FRAME_X_MENUBAR_ID (f))
1327 invalid_argument ("Frame has no menubar", Qunbound); 1315 invalid_argument ("Frame has no menubar", Qunbound);
1328 1316
1329 id = XPOPUP_DATA (f->menubar_data)->id; 1317 id = FRAME_X_MENUBAR_ID (f);
1330 val = lw_get_all_values (id); 1318 val = lw_get_all_values (id);
1331 val = val->contents; 1319 val = val->contents;
1332 lw_set_menu (FRAME_X_MENUBAR_WIDGET (f), val); 1320 lw_set_menu (FRAME_X_MENUBAR_WIDGET (f), val);
1333 lw_map_menu (CurrentTime); 1321 lw_map_menu (CurrentTime);
1334 1322