0
|
1 /* General GUI code -- X-specific. (menubars, scrollbars, toolbars, dialogs)
|
|
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4 Copyright (C) 1995 Sun Microsystems, Inc.
|
259
|
5 Copyright (C) 1998 Free Software Foundation, Inc.
|
0
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
|
29 #include "console-x.h"
|
|
30 #ifdef LWLIB_USES_MOTIF
|
|
31 #include <Xm/Xm.h> /* for XmVersion */
|
|
32 #endif
|
|
33 #include "gui-x.h"
|
|
34 #include "buffer.h"
|
|
35 #include "device.h"
|
|
36 #include "frame.h"
|
231
|
37 #include "gui.h"
|
0
|
38 #include "opaque.h"
|
|
39
|
|
40 #ifdef HAVE_POPUPS
|
|
41 Lisp_Object Qmenu_no_selection_hook;
|
|
42 #endif
|
|
43
|
|
44 /* we need a unique id for each popup menu, dialog box, and scrollbar */
|
|
45 static unsigned int lwlib_id_tick;
|
|
46
|
|
47 LWLIB_ID new_lwlib_id (void);
|
|
48 LWLIB_ID
|
|
49 new_lwlib_id (void)
|
|
50 {
|
|
51 return ++lwlib_id_tick;
|
|
52 }
|
|
53
|
|
54 widget_value *
|
|
55 xmalloc_widget_value (void)
|
|
56 {
|
|
57 widget_value *tmp = malloc_widget_value ();
|
|
58 if (!tmp) memory_full ();
|
|
59 return tmp;
|
|
60 }
|
|
61
|
|
62
|
|
63 #ifdef HAVE_POPUPS
|
|
64 static Lisp_Object mark_popup_data (Lisp_Object obj,
|
|
65 void (*markobj) (Lisp_Object));
|
|
66 DEFINE_LRECORD_IMPLEMENTATION ("popup-data", popup_data,
|
|
67 mark_popup_data, internal_object_printer,
|
|
68 0, 0, 0, struct popup_data);
|
|
69
|
|
70 struct mark_widget_value_closure
|
|
71 {
|
|
72 void (*markobj) (Lisp_Object);
|
|
73 };
|
|
74
|
|
75 static int
|
|
76 mark_widget_value_mapper (widget_value *val, void *closure)
|
|
77 {
|
|
78 Lisp_Object markee;
|
|
79
|
|
80 struct mark_widget_value_closure *cl =
|
|
81 (struct mark_widget_value_closure *) closure;
|
|
82 if (val->call_data)
|
|
83 {
|
|
84 VOID_TO_LISP (markee, val->call_data);
|
|
85 (cl->markobj) (markee);
|
|
86 }
|
|
87
|
175
|
88 if (val->accel)
|
|
89 {
|
|
90 VOID_TO_LISP (markee, val->accel);
|
|
91 (cl->markobj) (markee);
|
|
92 }
|
0
|
93 return 0;
|
|
94 }
|
|
95
|
|
96 static Lisp_Object
|
|
97 mark_popup_data (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
98 {
|
|
99 struct popup_data *data = (struct popup_data *) XPOPUP_DATA (obj);
|
|
100
|
|
101 /* Now mark the callbacks and such that are hidden in the lwlib
|
|
102 call-data */
|
|
103
|
|
104 if (data->id)
|
|
105 {
|
|
106 struct mark_widget_value_closure closure;
|
|
107
|
|
108 closure.markobj = markobj;
|
|
109 lw_map_widget_values (data->id, mark_widget_value_mapper, &closure);
|
|
110 }
|
173
|
111
|
|
112 return data->last_menubar_buffer;
|
0
|
113 }
|
|
114
|
|
115 /* This is like FRAME_MENUBAR_DATA (f), but contains an alist of
|
|
116 (id . popup-data) for GCPRO'ing the callbacks of the popup menus
|
|
117 and dialog boxes. */
|
|
118 static Lisp_Object Vpopup_callbacks;
|
|
119
|
|
120 void
|
|
121 gcpro_popup_callbacks (LWLIB_ID id)
|
|
122 {
|
|
123 struct popup_data *pdata;
|
|
124 Lisp_Object lid = make_int (id);
|
|
125 Lisp_Object lpdata = Qnil;
|
|
126
|
|
127 assert (NILP (assq_no_quit (lid, Vpopup_callbacks)));
|
185
|
128 pdata = alloc_lcrecord_type (struct popup_data, lrecord_popup_data);
|
0
|
129 pdata->id = id;
|
|
130 pdata->last_menubar_buffer = Qnil;
|
|
131 pdata->menubar_contents_up_to_date = 0;
|
|
132 XSETPOPUP_DATA (lpdata, pdata);
|
|
133 Vpopup_callbacks = Fcons (Fcons (lid, lpdata), Vpopup_callbacks);
|
|
134 }
|
|
135
|
|
136 void
|
|
137 ungcpro_popup_callbacks (LWLIB_ID id)
|
|
138 {
|
|
139 Lisp_Object lid = make_int (id);
|
|
140 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks);
|
|
141 assert (!NILP (this));
|
|
142 Vpopup_callbacks = delq_no_quit (this, Vpopup_callbacks);
|
|
143 }
|
|
144
|
|
145 int
|
|
146 popup_handled_p (LWLIB_ID id)
|
|
147 {
|
173
|
148 return NILP (assq_no_quit (make_int (id), Vpopup_callbacks));
|
0
|
149 }
|
|
150
|
|
151 /* menu_item_descriptor_to_widget_value() et al. mallocs a
|
|
152 widget_value, but then may signal lisp errors. If an error does
|
|
153 not occur, the opaque ptr we have here has had its pointer set to 0
|
|
154 to tell us not to do anything. Otherwise we free the widget value.
|
|
155 (This has nothing to do with GC, it's just about not dropping
|
|
156 pointers to malloc'd data when errors happen.) */
|
|
157
|
|
158 Lisp_Object
|
|
159 widget_value_unwind (Lisp_Object closure)
|
|
160 {
|
|
161 widget_value *wv = (widget_value *) get_opaque_ptr (closure);
|
|
162 free_opaque_ptr (closure);
|
|
163 if (wv)
|
|
164 free_widget_value (wv);
|
|
165 return Qnil;
|
|
166 }
|
|
167
|
|
168 #if 0
|
|
169 static void
|
|
170 print_widget_value (widget_value *wv, int depth)
|
|
171 {
|
|
172 /* !!#### This function has not been Mule-ized */
|
|
173 char d [200];
|
|
174 int i;
|
|
175 for (i = 0; i < depth; i++) d[i] = ' ';
|
|
176 d[depth]=0;
|
|
177 /* #### - print type field */
|
|
178 printf ("%sname: %s\n", d, (wv->name ? wv->name : "(null)"));
|
|
179 if (wv->value) printf ("%svalue: %s\n", d, wv->value);
|
|
180 if (wv->key) printf ("%skey: %s\n", d, wv->key);
|
|
181 printf ("%senabled: %d\n", d, wv->enabled);
|
|
182 if (wv->contents)
|
|
183 {
|
|
184 printf ("\n%scontents: \n", d);
|
|
185 print_widget_value (wv->contents, depth + 5);
|
|
186 }
|
|
187 if (wv->next)
|
|
188 {
|
|
189 printf ("\n");
|
|
190 print_widget_value (wv->next, depth);
|
|
191 }
|
|
192 }
|
|
193 #endif
|
|
194
|
|
195 /* This recursively calls free_widget_value() on the tree of widgets.
|
|
196 It must free all data that was malloc'ed for these widget_values.
|
|
197
|
|
198 It used to be that emacs only allocated new storage for the `key' slot.
|
|
199 All other slots are pointers into the data of Lisp_Strings, and must be
|
|
200 left alone. */
|
|
201 void
|
|
202 free_popup_widget_value_tree (widget_value *wv)
|
|
203 {
|
|
204 if (! wv) return;
|
|
205 if (wv->key) xfree (wv->key);
|
|
206 if (wv->value) xfree (wv->value);
|
|
207
|
|
208 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
|
|
209
|
|
210 if (wv->contents && (wv->contents != (widget_value*)1))
|
|
211 {
|
|
212 free_popup_widget_value_tree (wv->contents);
|
|
213 wv->contents = (widget_value *) 0xDEADBEEF;
|
|
214 }
|
|
215 if (wv->next)
|
|
216 {
|
|
217 free_popup_widget_value_tree (wv->next);
|
|
218 wv->next = (widget_value *) 0xDEADBEEF;
|
|
219 }
|
|
220 free_widget_value (wv);
|
|
221 }
|
|
222
|
|
223 /* The following is actually called from somewhere within XtDispatchEvent(),
|
|
224 called from XtAppProcessEvent() in event-Xt.c */
|
|
225
|
|
226 void
|
|
227 popup_selection_callback (Widget widget, LWLIB_ID ignored_id,
|
|
228 XtPointer client_data)
|
|
229 {
|
|
230 Lisp_Object fn, arg;
|
|
231 Lisp_Object data;
|
|
232 Lisp_Object frame = Qnil;
|
|
233 struct device *d = get_device_from_display (XtDisplay (widget));
|
|
234 struct frame *f = x_any_widget_or_parent_to_frame (d, widget);
|
|
235
|
175
|
236 /* set in lwlib to the time stamp associated with the most recent menu
|
|
237 operation */
|
|
238 extern Time x_focus_timestamp_really_sucks_fix_me_better;
|
|
239
|
0
|
240 if (!f)
|
|
241 return;
|
|
242 if (((EMACS_INT) client_data) == 0)
|
|
243 return;
|
|
244 VOID_TO_LISP (data, client_data);
|
|
245 XSETFRAME (frame, f);
|
|
246
|
|
247 #if 0
|
|
248 /* #### What the hell? I can't understand why this call is here,
|
|
249 and doing it is really courting disaster in the new event
|
|
250 model, since popup_selection_callback is called from
|
|
251 within next_event_internal() and Faccept_process_output()
|
|
252 itself calls next_event_internal(). --Ben */
|
|
253
|
|
254 /* Flush the X and process input */
|
|
255 Faccept_process_output (Qnil, Qnil, Qnil);
|
|
256 #endif
|
|
257
|
|
258 if (((EMACS_INT) client_data) == -1)
|
|
259 {
|
|
260 fn = Qrun_hooks;
|
|
261 arg = Qmenu_no_selection_hook;
|
|
262 }
|
|
263 else if (SYMBOLP (data))
|
|
264 {
|
|
265 fn = Qcall_interactively;
|
|
266 arg = data;
|
|
267 }
|
|
268 else if (CONSP (data))
|
|
269 {
|
|
270 fn = Qeval;
|
|
271 arg = data;
|
|
272 }
|
|
273 else
|
|
274 {
|
|
275 fn = Qeval;
|
|
276 arg = list3 (Qsignal,
|
|
277 list2 (Qquote, Qerror),
|
|
278 list2 (Qquote, list2 (build_translated_string
|
|
279 ("illegal popup callback"),
|
|
280 data)));
|
|
281 }
|
|
282
|
|
283 /* This is the timestamp used for asserting focus so we need to get an
|
|
284 up-to-date value event if no events has been dispatched to emacs
|
|
285 */
|
179
|
286 #if defined(HAVE_MENUBARS)
|
175
|
287 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better;
|
177
|
288 #else
|
|
289 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d);
|
|
290 #endif
|
0
|
291 signal_special_Xt_user_event (frame, fn, arg);
|
|
292 }
|
|
293
|
|
294 #if 1
|
|
295 /* Eval the activep slot of the menu item */
|
|
296 # define wv_set_evalable_slot(slot,form) \
|
|
297 do { Lisp_Object _f_ = (form); \
|
|
298 slot = (NILP (_f_) ? 0 : \
|
|
299 EQ (_f_, Qt) ? 1 : \
|
|
300 !NILP (Feval (_f_))); \
|
|
301 } while (0)
|
|
302 #else
|
|
303 /* Treat the activep slot of the menu item as a boolean */
|
|
304 # define wv_set_evalable_slot(slot,form) \
|
|
305 slot = (!NILP ((form)))
|
|
306 #endif
|
|
307
|
|
308 char *
|
|
309 menu_separator_style (CONST char *s)
|
|
310 {
|
|
311 CONST char *p;
|
|
312 char first;
|
|
313
|
|
314 if (!s || s[0] == '\0')
|
|
315 return NULL;
|
|
316 first = s[0];
|
|
317 if (first != '-' && first != '=')
|
|
318 return NULL;
|
|
319 for (p = s; *p == first; p++);
|
|
320
|
|
321 /* #### - cannot currently specify a separator tag "--!tag" and a
|
|
322 separator style "--:style" at the same time. */
|
|
323 /* #### - Also, the motif menubar code doesn't deal with the
|
|
324 double etched style yet, so it's not good to get into the habit of
|
|
325 using "===" in menubars to get double-etched lines */
|
|
326 if (*p == '!' || *p == '\0')
|
|
327 return ((first == '-')
|
|
328 ? NULL /* single etched is the default */
|
|
329 : xstrdup ("shadowDoubleEtchedIn"));
|
|
330 else if (*p == ':')
|
|
331 return xstrdup (p+1);
|
173
|
332
|
0
|
333 return NULL;
|
|
334 }
|
|
335
|
175
|
336 /* set menu accelerator key to first underlined character in menu name */
|
|
337
|
|
338 Lisp_Object
|
|
339 menu_name_to_accelerator (char *name)
|
|
340 {
|
|
341 while (*name) {
|
|
342 if (*name=='%') {
|
|
343 ++name;
|
|
344 if (!(*name))
|
|
345 return Qnil;
|
|
346 if (*name=='_'&&*(name+1))
|
|
347 return make_char (tolower(*(name+1)));
|
|
348 }
|
|
349 ++name;
|
|
350 }
|
|
351 return Qnil;
|
|
352 }
|
|
353
|
0
|
354 /* This does the dirty work. gc_currently_forbidden is 1 when this is called.
|
|
355 */
|
|
356
|
|
357 int
|
|
358 button_item_to_widget_value (Lisp_Object desc, widget_value *wv,
|
|
359 int allow_text_field_p, int no_keys_p)
|
|
360 {
|
|
361 /* !!#### This function has not been Mule-ized */
|
|
362 /* This function cannot GC because gc_currently_forbidden is set when
|
|
363 it's called */
|
2
|
364 Lisp_Object name = Qnil;
|
|
365 Lisp_Object callback = Qnil;
|
|
366 Lisp_Object suffix = Qnil;
|
|
367 Lisp_Object active_p = Qt;
|
|
368 Lisp_Object include_p = Qt;
|
0
|
369 Lisp_Object selected_p = Qnil;
|
2
|
370 Lisp_Object keys = Qnil;
|
|
371 Lisp_Object style = Qnil;
|
0
|
372 Lisp_Object config_tag = Qnil;
|
175
|
373 Lisp_Object accel = Qnil;
|
173
|
374 int length = XVECTOR_LENGTH (desc);
|
|
375 Lisp_Object *contents = XVECTOR_DATA (desc);
|
0
|
376 int plist_p;
|
|
377 int selected_spec = 0, included_spec = 0;
|
|
378
|
259
|
379 if (length < 2)
|
|
380 signal_simple_error ("button descriptors must be at least 2 long", desc);
|
0
|
381
|
259
|
382 /* length 2: [ "name" callback ]
|
|
383 length 3: [ "name" callback active-p ]
|
0
|
384 length 4: [ "name" callback active-p suffix ]
|
|
385 or [ "name" callback keyword value ]
|
|
386 length 5+: [ "name" callback [ keyword value ]+ ]
|
|
387 */
|
259
|
388 plist_p = (length >= 5 || (length > 2 && KEYWORDP (contents [2])));
|
0
|
389
|
259
|
390 if (!plist_p && length > 2)
|
0
|
391 /* the old way */
|
|
392 {
|
|
393 name = contents [0];
|
|
394 callback = contents [1];
|
|
395 active_p = contents [2];
|
|
396 if (length == 4)
|
|
397 suffix = contents [3];
|
|
398 }
|
|
399 else
|
|
400 {
|
|
401 /* the new way */
|
|
402 int i;
|
|
403 if (length & 1)
|
|
404 signal_simple_error (
|
|
405 "button descriptor has an odd number of keywords and values",
|
|
406 desc);
|
|
407
|
|
408 name = contents [0];
|
|
409 callback = contents [1];
|
|
410 for (i = 2; i < length;)
|
|
411 {
|
|
412 Lisp_Object key = contents [i++];
|
|
413 Lisp_Object val = contents [i++];
|
|
414 if (!KEYWORDP (key))
|
|
415 signal_simple_error_2 ("not a keyword", key, desc);
|
|
416
|
2
|
417 if (EQ (key, Q_active)) active_p = val;
|
|
418 else if (EQ (key, Q_suffix)) suffix = val;
|
|
419 else if (EQ (key, Q_keys)) keys = val;
|
|
420 else if (EQ (key, Q_style)) style = val;
|
0
|
421 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1;
|
2
|
422 else if (EQ (key, Q_included)) include_p = val, included_spec = 1;
|
0
|
423 else if (EQ (key, Q_config)) config_tag = val;
|
175
|
424 else if (EQ (key, Q_accelerator))
|
|
425 {
|
|
426 if ( SYMBOLP (val)
|
|
427 || CHARP (val))
|
|
428 accel = val;
|
|
429 else
|
|
430 signal_simple_error ("bad keyboard accelerator", val);
|
|
431 }
|
0
|
432 else if (EQ (key, Q_filter))
|
|
433 signal_simple_error(":filter keyword not permitted on leaf nodes", desc);
|
173
|
434 else
|
0
|
435 signal_simple_error_2 ("unknown menu item keyword", key, desc);
|
|
436 }
|
|
437 }
|
|
438
|
|
439 #ifdef HAVE_MENUBARS
|
|
440 if ((!NILP (config_tag) && NILP (Fmemq (config_tag, Vmenubar_configuration)))
|
|
441 || (included_spec && NILP (Feval (include_p))))
|
|
442 {
|
|
443 /* the include specification says to ignore this item. */
|
|
444 return 0;
|
|
445 }
|
16
|
446 #endif /* HAVE_MENUBARS */
|
0
|
447
|
|
448 CHECK_STRING (name);
|
14
|
449 wv->name = (char *) XSTRING_DATA (name);
|
0
|
450
|
175
|
451 if (NILP (accel))
|
|
452 accel = menu_name_to_accelerator (wv->name);
|
|
453 wv->accel = LISP_TO_VOID (accel);
|
185
|
454
|
0
|
455 if (!NILP (suffix))
|
|
456 {
|
|
457 CONST char *const_bogosity;
|
259
|
458 Lisp_Object suffix2;
|
|
459
|
|
460 /* Shortcut to avoid evaluating suffix each time */
|
|
461 if (STRINGP (suffix))
|
|
462 suffix2 = suffix;
|
|
463 else
|
|
464 {
|
|
465 suffix2 = Feval (suffix);
|
|
466 CHECK_STRING (suffix2);
|
|
467 }
|
|
468
|
|
469 GET_C_STRING_FILENAME_DATA_ALLOCA (suffix2, const_bogosity);
|
0
|
470 wv->value = (char *) const_bogosity;
|
|
471 wv->value = xstrdup (wv->value);
|
|
472 }
|
|
473
|
|
474 wv_set_evalable_slot (wv->enabled, active_p);
|
|
475 wv_set_evalable_slot (wv->selected, selected_p);
|
|
476
|
|
477 wv->call_data = LISP_TO_VOID (callback);
|
|
478
|
|
479 if (no_keys_p
|
|
480 #ifdef HAVE_MENUBARS
|
|
481 || !menubar_show_keybindings
|
|
482 #endif
|
|
483 )
|
|
484 wv->key = 0;
|
|
485 else if (!NILP (keys)) /* Use this string to generate key bindings */
|
|
486 {
|
|
487 CHECK_STRING (keys);
|
|
488 keys = Fsubstitute_command_keys (keys);
|
14
|
489 if (XSTRING_LENGTH (keys) > 0)
|
|
490 wv->key = xstrdup ((char *) XSTRING_DATA (keys));
|
0
|
491 else
|
|
492 wv->key = 0;
|
|
493 }
|
|
494 else if (SYMBOLP (callback)) /* Show the binding of this command. */
|
|
495 {
|
|
496 char buf [1024];
|
|
497 /* #### Warning, dependency here on current_buffer and point */
|
|
498 where_is_to_char (callback, buf);
|
|
499 if (buf [0])
|
|
500 wv->key = xstrdup (buf);
|
|
501 else
|
|
502 wv->key = 0;
|
|
503 }
|
|
504
|
|
505 CHECK_SYMBOL (style);
|
|
506 if (NILP (style))
|
|
507 {
|
|
508 /* If the callback is nil, treat this item like unselectable text.
|
|
509 This way, dashes will show up as a separator. */
|
|
510 if (!wv->enabled)
|
|
511 wv->type = BUTTON_TYPE;
|
|
512 if (separator_string_p (wv->name))
|
|
513 {
|
|
514 wv->type = SEPARATOR_TYPE;
|
|
515 wv->value = menu_separator_style (wv->name);
|
|
516 }
|
|
517 else
|
|
518 {
|
|
519 #if 0
|
|
520 /* #### - this is generally desirable for menubars, but it breaks
|
|
521 a package that uses dialog boxes and next_command_event magic
|
|
522 to use the callback slot in dialog buttons for data instead of
|
|
523 a real callback.
|
|
524
|
|
525 Code is data, right? The beauty of LISP abuse. --Stig */
|
|
526 if (NILP (callback))
|
|
527 wv->type = TEXT_TYPE;
|
|
528 else
|
|
529 #endif
|
|
530 wv->type = BUTTON_TYPE;
|
|
531 }
|
|
532 }
|
|
533 else if (EQ (style, Qbutton))
|
|
534 wv->type = BUTTON_TYPE;
|
|
535 else if (EQ (style, Qtoggle))
|
|
536 wv->type = TOGGLE_TYPE;
|
|
537 else if (EQ (style, Qradio))
|
|
538 wv->type = RADIO_TYPE;
|
|
539 else if (EQ (style, Qtext))
|
|
540 {
|
|
541 wv->type = TEXT_TYPE;
|
|
542 #if 0
|
|
543 wv->value = wv->name;
|
|
544 wv->name = "value";
|
173
|
545 #endif
|
0
|
546 }
|
|
547 else
|
|
548 signal_simple_error_2 ("unknown style", style, desc);
|
|
549
|
|
550 if (!allow_text_field_p && (wv->type == TEXT_TYPE))
|
|
551 signal_simple_error ("text field not allowed in this context", desc);
|
|
552
|
|
553 if (selected_spec && EQ (style, Qtext))
|
|
554 signal_simple_error (
|
|
555 ":selected only makes sense with :style toggle, radio or button",
|
|
556 desc);
|
|
557 return 1;
|
|
558 }
|
|
559
|
|
560 #endif /* HAVE_POPUPS */
|
|
561
|
|
562 /* This is a kludge to make sure emacs can only link against a version of
|
|
563 lwlib that was compiled in the right way. Emacs references symbols which
|
|
564 correspond to the way it thinks lwlib was compiled, and if lwlib wasn't
|
|
565 compiled in that way, then somewhat meaningful link errors will result.
|
|
566 The alternatives to this range from obscure link errors, to obscure
|
|
567 runtime errors that look a lot like bugs.
|
|
568 */
|
|
569
|
|
570 static void
|
|
571 sanity_check_lwlib (void)
|
|
572 {
|
|
573 #define MACROLET(v) { extern int v; v = 1; }
|
|
574
|
|
575 #if (XlibSpecificationRelease == 4)
|
|
576 MACROLET (lwlib_uses_x11r4);
|
|
577 #elif (XlibSpecificationRelease == 5)
|
|
578 MACROLET (lwlib_uses_x11r5);
|
|
579 #elif (XlibSpecificationRelease == 6)
|
|
580 MACROLET (lwlib_uses_x11r6);
|
|
581 #else
|
|
582 MACROLET (lwlib_uses_unknown_x11);
|
|
583 #endif
|
|
584 #ifdef LWLIB_USES_MOTIF
|
|
585 MACROLET (lwlib_uses_motif);
|
|
586 #else
|
|
587 MACROLET (lwlib_does_not_use_motif);
|
|
588 #endif
|
|
589 #if (XmVersion >= 1002)
|
|
590 MACROLET (lwlib_uses_motif_1_2);
|
|
591 #else
|
|
592 MACROLET (lwlib_does_not_use_motif_1_2);
|
|
593 #endif
|
|
594 #ifdef LWLIB_MENUBARS_LUCID
|
|
595 MACROLET (lwlib_menubars_lucid);
|
|
596 #elif defined (HAVE_MENUBARS)
|
|
597 MACROLET (lwlib_menubars_motif);
|
|
598 #endif
|
|
599 #ifdef LWLIB_SCROLLBARS_LUCID
|
|
600 MACROLET (lwlib_scrollbars_lucid);
|
|
601 #elif defined (LWLIB_SCROLLBARS_MOTIF)
|
|
602 MACROLET (lwlib_scrollbars_motif);
|
|
603 #elif defined (HAVE_SCROLLBARS)
|
|
604 MACROLET (lwlib_scrollbars_athena);
|
|
605 #endif
|
|
606 #ifdef LWLIB_DIALOGS_MOTIF
|
|
607 MACROLET (lwlib_dialogs_motif);
|
|
608 #elif defined (HAVE_DIALOGS)
|
|
609 MACROLET (lwlib_dialogs_athena);
|
|
610 #endif
|
|
611
|
|
612 #undef MACROLET
|
|
613 }
|
|
614
|
|
615 void
|
|
616 syms_of_gui_x (void)
|
|
617 {
|
|
618 #ifdef HAVE_POPUPS
|
|
619 defsymbol (&Qmenu_no_selection_hook, "menu-no-selection-hook");
|
|
620 #endif
|
|
621 }
|
|
622
|
|
623 void
|
|
624 vars_of_gui_x (void)
|
|
625 {
|
|
626 lwlib_id_tick = (1<<16); /* start big, to not conflict with Energize */
|
|
627
|
|
628 #ifdef HAVE_POPUPS
|
|
629 popup_up_p = 0;
|
|
630
|
|
631 Vpopup_callbacks = Qnil;
|
|
632 staticpro (&Vpopup_callbacks);
|
|
633
|
|
634 #if 0
|
|
635 /* This DEFVAR_LISP is just for the benefit of make-docfile. */
|
|
636 /* #### misnamed */
|
|
637 DEFVAR_LISP ("menu-no-selection-hook", &Vmenu_no_selection_hook /*
|
|
638 Function or functions to call when a menu or dialog box is dismissed
|
|
639 without a selection having been made.
|
|
640 */ );
|
|
641 #endif
|
|
642 Fset (Qmenu_no_selection_hook, Qnil);
|
|
643 #endif /* HAVE_POPUPS */
|
|
644
|
|
645 /* this makes only safe calls as in emacs.c */
|
|
646 sanity_check_lwlib ();
|
|
647 }
|