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