comparison src/gui-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 70921960b980
children a8d8f419b459
comparison
equal deleted inserted replaced
1345:3b27da507d56 1346:01c57eb70ae9
37 #include "menubar.h" 37 #include "menubar.h"
38 #include "opaque.h" 38 #include "opaque.h"
39 #include "redisplay.h" 39 #include "redisplay.h"
40 40
41 #include "console-x-impl.h" 41 #include "console-x-impl.h"
42 #include "gui-x.h"
43 42
44 #ifdef LWLIB_USES_MOTIF 43 #ifdef LWLIB_USES_MOTIF
45 #include "xmotif.h" /* for XmVersion */ 44 #include "xmotif.h" /* for XmVersion */
46 #endif 45 #endif
47 46
49 static LWLIB_ID lwlib_id_tick; 48 static LWLIB_ID lwlib_id_tick;
50 49
51 LWLIB_ID 50 LWLIB_ID
52 new_lwlib_id (void) 51 new_lwlib_id (void)
53 { 52 {
54 return ++lwlib_id_tick; 53 lwlib_id_tick++;
54 if (!lwlib_id_tick)
55 lwlib_id_tick++;
56 return lwlib_id_tick;
55 } 57 }
56 58
57 widget_value * 59 widget_value *
58 xmalloc_widget_value (void) 60 xmalloc_widget_value (void)
59 { 61 {
61 if (!tmp) memory_full (); 63 if (!tmp) memory_full ();
62 return tmp; 64 return tmp;
63 } 65 }
64 66
65 67
66 static Lisp_Object 68
67 mark_popup_data (Lisp_Object obj) 69 /* This contains an alist of (id . protect-me) for GCPRO'ing the callbacks
68 { 70 of the popup menus and dialog boxes. */
69 struct popup_data *data = (struct popup_data *) XPOPUP_DATA (obj); 71 static Lisp_Object Vpopup_callbacks;
70 72
71 mark_object (data->last_menubar_buffer); 73 struct widget_value_mapper
72 return data->protect_me; 74 {
73 } 75 Lisp_Object protect_me;
74
75 static const struct memory_description popup_data_description [] = {
76 { XD_LISP_OBJECT, offsetof (struct popup_data, last_menubar_buffer) },
77 { XD_LISP_OBJECT, offsetof (struct popup_data, protect_me) },
78 { XD_END }
79 }; 76 };
80
81 DEFINE_LRECORD_IMPLEMENTATION ("popup-data", popup_data,
82 0, /*dumpable-flag*/
83 mark_popup_data, internal_object_printer,
84 0, 0, 0,
85 popup_data_description,
86 struct popup_data);
87
88 /* This is like FRAME_MENUBAR_DATA (f), but contains an alist of
89 (id . popup-data) for GCPRO'ing the callbacks of the popup menus
90 and dialog boxes. */
91 static Lisp_Object Vpopup_callbacks;
92 77
93 static int 78 static int
94 snarf_widget_value_mapper (widget_value *val, void *closure) 79 snarf_widget_value_mapper (widget_value *val, void *closure)
95 { 80 {
96 struct popup_data *pdata = (struct popup_data *) closure; 81 struct widget_value_mapper *z = (struct widget_value_mapper *) closure;
97 82
98 if (val->call_data) 83 if (val->call_data)
99 pdata->protect_me = Fcons (VOID_TO_LISP (val->call_data), 84 z->protect_me = Fcons (VOID_TO_LISP (val->call_data), z->protect_me);
100 pdata->protect_me);
101 if (val->accel) 85 if (val->accel)
102 pdata->protect_me = Fcons (VOID_TO_LISP (val->accel), 86 z->protect_me = Fcons (VOID_TO_LISP (val->accel), z->protect_me);
103 pdata->protect_me);
104 87
105 return 0; 88 return 0;
106 } 89 }
107 90
108 /* Snarf the callbacks and other Lisp data that are hidden in the lwlib 91 /* Snarf the callbacks and other Lisp data that are hidden in the lwlib
109 call-data and accel and stick them into POPUP-DATA for proper marking. */ 92 call-data and accel associated with id ID and return them for
110 93 proper marking. */
111 void 94
112 snarf_widget_values_for_gcpro (Lisp_Object popup_data) 95 static Lisp_Object
113 { 96 snarf_widget_values_for_gcpro (LWLIB_ID id)
114 struct popup_data *pdata = XPOPUP_DATA (popup_data); 97 {
115 98 struct widget_value_mapper z;
116 free_list (pdata->protect_me); 99
117 pdata->protect_me = Qnil; 100 z.protect_me = Qnil;
118 101 lw_map_widget_values (id, snarf_widget_value_mapper, &z);
119 if (pdata->id) 102 return z.protect_me;
120 lw_map_widget_values (pdata->id, snarf_widget_value_mapper, pdata); 103 }
121 } 104
105 /* Given an lwlib id ID associated with a widget tree, make sure that all
106 Lisp callbacks in the tree are GC-protected. This can be called
107 multiple times on the same widget tree -- this should be done at
108 creation time and each time the tree is modified. */
122 109
123 void 110 void
124 gcpro_popup_callbacks (LWLIB_ID id) 111 gcpro_popup_callbacks (LWLIB_ID id)
125 { 112 {
126 struct popup_data *pdata;
127 Lisp_Object lid = make_int (id); 113 Lisp_Object lid = make_int (id);
128 Lisp_Object lpdata; 114 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks);
129 115
130 assert (NILP (assq_no_quit (lid, Vpopup_callbacks))); 116 if (!NILP (this))
131 pdata = alloc_lcrecord_type (struct popup_data, &lrecord_popup_data); 117 {
132 pdata->id = id; 118 free_list (XCDR (this));
133 pdata->last_menubar_buffer = Qnil; 119 XCDR (this) = snarf_widget_values_for_gcpro (id);
134 pdata->protect_me = Qnil; 120 }
135 pdata->menubar_contents_up_to_date = 0; 121 else
136 lpdata = wrap_popup_data (pdata); 122 Vpopup_callbacks = Fcons (Fcons (lid, snarf_widget_values_for_gcpro (id)),
137 123 Vpopup_callbacks);
138 snarf_widget_values_for_gcpro (lpdata); 124 }
139 125
140 Vpopup_callbacks = Fcons (Fcons (lid, lpdata), Vpopup_callbacks); 126 /* Remove GC-protection from the just-destroyed widget tree associated
141 } 127 with lwlib id ID. */
142 128
143 void 129 void
144 ungcpro_popup_callbacks (LWLIB_ID id) 130 ungcpro_popup_callbacks (LWLIB_ID id)
145 { 131 {
146 struct popup_data *pdata;
147 Lisp_Object lid = make_int (id); 132 Lisp_Object lid = make_int (id);
148 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks); 133 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks);
134
149 assert (!NILP (this)); 135 assert (!NILP (this));
150 pdata = XPOPUP_DATA (XCDR (this)); 136 free_list (XCDR (this));
151 free_list (pdata->protect_me);
152 pdata->protect_me = Qnil;
153 Vpopup_callbacks = delq_no_quit (this, Vpopup_callbacks); 137 Vpopup_callbacks = delq_no_quit (this, Vpopup_callbacks);
154 } 138 }
155 139
156 int 140 int
157 popup_handled_p (LWLIB_ID id) 141 popup_handled_p (LWLIB_ID id)
690 } 674 }
691 675
692 void 676 void
693 syms_of_gui_x (void) 677 syms_of_gui_x (void)
694 { 678 {
695 INIT_LRECORD_IMPLEMENTATION (popup_data);
696 } 679 }
697 680
698 void 681 void
699 reinit_vars_of_gui_x (void) 682 reinit_vars_of_gui_x (void)
700 { 683 {