428
|
1 /* Device functions for X windows.
|
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
442
|
24 /* 7-8-00 !!#### This file needs definite Mule review. */
|
|
25
|
428
|
26 /* Original authors: Jamie Zawinski and the FSF */
|
|
27 /* Rewritten by Ben Wing and Chuck Thompson. */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
|
32 #include "console-x.h"
|
|
33 #include "xintrinsicp.h" /* CoreP.h needs this */
|
|
34 #include <X11/CoreP.h> /* Numerous places access the fields of
|
|
35 a core widget directly. We could
|
|
36 use XtGetValues(), but ... */
|
|
37 #include "xgccache.h"
|
|
38 #include <X11/Shell.h>
|
|
39 #include "xmu.h"
|
|
40 #include "glyphs-x.h"
|
|
41 #include "objects-x.h"
|
|
42
|
|
43 #include "buffer.h"
|
|
44 #include "elhash.h"
|
|
45 #include "events.h"
|
|
46 #include "faces.h"
|
|
47 #include "frame.h"
|
|
48 #include "redisplay.h"
|
|
49 #include "sysdep.h"
|
|
50 #include "window.h"
|
|
51
|
|
52 #include "sysfile.h"
|
|
53 #include "systime.h"
|
|
54
|
442
|
55 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
|
440
|
56 #include "sysdll.h"
|
442
|
57 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */
|
440
|
58
|
428
|
59 #ifdef HAVE_OFFIX_DND
|
|
60 #include "offix.h"
|
|
61 #endif
|
|
62
|
|
63 Lisp_Object Vdefault_x_device;
|
|
64 #if defined(MULE) && (defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET))
|
|
65 Lisp_Object Vx_app_defaults_directory;
|
|
66 #endif
|
|
67
|
|
68 /* Qdisplay in general.c */
|
|
69 Lisp_Object Qx_error;
|
|
70 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win;
|
|
71
|
|
72 /* The application class of Emacs. */
|
|
73 Lisp_Object Vx_emacs_application_class;
|
|
74
|
|
75 Lisp_Object Vx_initial_argv_list; /* #### ugh! */
|
|
76
|
|
77 static XrmOptionDescRec emacs_options[] =
|
|
78 {
|
|
79 {"-geometry", ".geometry", XrmoptionSepArg, NULL},
|
|
80 {"-iconic", ".iconic", XrmoptionNoArg, "yes"},
|
|
81
|
|
82 {"-internal-border-width", "*EmacsFrame.internalBorderWidth", XrmoptionSepArg, NULL},
|
|
83 {"-ib", "*EmacsFrame.internalBorderWidth", XrmoptionSepArg, NULL},
|
|
84 {"-scrollbar-width", "*EmacsFrame.scrollBarWidth", XrmoptionSepArg, NULL},
|
|
85 {"-scrollbar-height", "*EmacsFrame.scrollBarHeight", XrmoptionSepArg, NULL},
|
|
86
|
|
87 {"-privatecolormap", ".privateColormap", XrmoptionNoArg, "yes"},
|
|
88 {"-visual", ".EmacsVisual", XrmoptionSepArg, NULL},
|
|
89
|
|
90 /* #### Beware! If the type of the shell changes, update this. */
|
|
91 {"-T", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
|
92 {"-wn", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
|
93 {"-title", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
|
94
|
|
95 {"-iconname", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL},
|
|
96 {"-in", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL},
|
|
97 {"-mc", "*pointerColor", XrmoptionSepArg, NULL},
|
|
98 {"-cr", "*cursorColor", XrmoptionSepArg, NULL},
|
|
99 {"-fontset", "*FontSet", XrmoptionSepArg, NULL},
|
|
100 };
|
|
101
|
|
102 /* Functions to synchronize mirroring resources and specifiers */
|
|
103 int in_resource_setting;
|
|
104
|
|
105 /************************************************************************/
|
|
106 /* helper functions */
|
|
107 /************************************************************************/
|
|
108
|
|
109 /* JH 97/11/25 removed the static declaration because I need it during setup in event-Xt... */
|
|
110 struct device * get_device_from_display_1 (Display *dpy);
|
|
111 struct device *
|
|
112 get_device_from_display_1 (Display *dpy)
|
|
113 {
|
|
114 Lisp_Object devcons, concons;
|
|
115
|
|
116 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
117 {
|
|
118 struct device *d = XDEVICE (XCAR (devcons));
|
|
119 if (DEVICE_X_P (d) && DEVICE_X_DISPLAY (d) == dpy)
|
|
120 return d;
|
|
121 }
|
|
122
|
|
123 return 0;
|
|
124 }
|
|
125
|
|
126 struct device *
|
|
127 get_device_from_display (Display *dpy)
|
|
128 {
|
|
129 struct device *d = get_device_from_display_1 (dpy);
|
|
130
|
|
131 #if !defined(INFODOCK)
|
|
132 # define FALLBACK_RESOURCE_NAME "xemacs"
|
|
133 # else
|
|
134 # define FALLBACK_RESOURCE_NAME "infodock"
|
|
135 #endif
|
|
136
|
|
137 if (!d) {
|
|
138 /* This isn't one of our displays. Let's crash? */
|
|
139 stderr_out
|
|
140 ("\n%s: Fatal X Condition. Asked about display we don't own: \"%s\"\n",
|
|
141 (STRINGP (Vinvocation_name) ?
|
|
142 (char *) XSTRING_DATA (Vinvocation_name) : FALLBACK_RESOURCE_NAME),
|
|
143 DisplayString (dpy) ? DisplayString (dpy) : "???");
|
|
144 abort();
|
|
145 }
|
|
146
|
|
147 #undef FALLBACK_RESOURCE_NAME
|
|
148
|
|
149 return d;
|
|
150 }
|
|
151
|
|
152 struct device *
|
|
153 decode_x_device (Lisp_Object device)
|
|
154 {
|
|
155 XSETDEVICE (device, decode_device (device));
|
|
156 CHECK_X_DEVICE (device);
|
|
157 return XDEVICE (device);
|
|
158 }
|
|
159
|
|
160 static Display *
|
|
161 get_x_display (Lisp_Object device)
|
|
162 {
|
|
163 return DEVICE_X_DISPLAY (decode_x_device (device));
|
|
164 }
|
|
165
|
|
166
|
|
167 /************************************************************************/
|
|
168 /* initializing an X connection */
|
|
169 /************************************************************************/
|
|
170
|
756
|
171 static struct device *device_being_initialized = NULL;
|
|
172
|
428
|
173 static void
|
|
174 allocate_x_device_struct (struct device *d)
|
|
175 {
|
|
176 d->device_data = xnew_and_zero (struct x_device);
|
|
177 }
|
|
178
|
|
179 static void
|
|
180 Xatoms_of_device_x (struct device *d)
|
|
181 {
|
|
182 Display *D = DEVICE_X_DISPLAY (d);
|
|
183
|
|
184 DEVICE_XATOM_WM_PROTOCOLS (d) = XInternAtom (D, "WM_PROTOCOLS", False);
|
|
185 DEVICE_XATOM_WM_DELETE_WINDOW(d) = XInternAtom (D, "WM_DELETE_WINDOW",False);
|
|
186 DEVICE_XATOM_WM_SAVE_YOURSELF(d) = XInternAtom (D, "WM_SAVE_YOURSELF",False);
|
|
187 DEVICE_XATOM_WM_TAKE_FOCUS (d) = XInternAtom (D, "WM_TAKE_FOCUS", False);
|
|
188 DEVICE_XATOM_WM_STATE (d) = XInternAtom (D, "WM_STATE", False);
|
|
189 }
|
|
190
|
|
191 static void
|
|
192 sanity_check_geometry_resource (Display *dpy)
|
|
193 {
|
|
194 char *app_name, *app_class, *s;
|
|
195 char buf1 [255], buf2 [255];
|
|
196 char *type;
|
|
197 XrmValue value;
|
|
198 XtGetApplicationNameAndClass (dpy, &app_name, &app_class);
|
|
199 strcpy (buf1, app_name);
|
|
200 strcpy (buf2, app_class);
|
|
201 for (s = buf1; *s; s++) if (*s == '.') *s = '_';
|
|
202 strcat (buf1, "._no_._such_._resource_.geometry");
|
|
203 strcat (buf2, "._no_._such_._resource_.Geometry");
|
|
204 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
|
|
205 {
|
|
206 warn_when_safe (Qgeometry, Qerror,
|
|
207 "\n"
|
|
208 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n"
|
|
209 "specified in the resource database. Specifying \"*geometry\" will make\n"
|
|
210 "XEmacs (and most other X programs) malfunction in obscure ways. (i.e.\n"
|
|
211 "the Xt or Xm libraries will probably crash, which is a very bad thing.)\n"
|
|
212 "You should always use \".geometry\" or \"*EmacsFrame.geometry\" instead.\n",
|
|
213 app_name, (char *) value.addr,
|
|
214 app_class, (char *) value.addr);
|
|
215 suppress_early_error_handler_backtrace = 1;
|
563
|
216 syntax_error ("Invalid geometry resource", Qunbound);
|
428
|
217 }
|
|
218 }
|
|
219
|
|
220 static void
|
|
221 x_init_device_class (struct device *d)
|
|
222 {
|
|
223 if (DEVICE_X_DEPTH(d) > 2)
|
|
224 {
|
|
225 switch (DEVICE_X_VISUAL(d)->class)
|
|
226 {
|
|
227 case StaticGray:
|
|
228 case GrayScale:
|
|
229 DEVICE_CLASS (d) = Qgrayscale;
|
|
230 break;
|
|
231 default:
|
|
232 DEVICE_CLASS (d) = Qcolor;
|
|
233 }
|
|
234 }
|
|
235 else
|
|
236 DEVICE_CLASS (d) = Qmono;
|
|
237 }
|
|
238
|
|
239 /*
|
|
240 * Figure out what application name to use for xemacs
|
|
241 *
|
|
242 * Since we have decomposed XtOpenDisplay into XOpenDisplay and
|
|
243 * XtDisplayInitialize, we no longer get this for free.
|
|
244 *
|
|
245 * If there is a `-name' argument in argv, use that.
|
|
246 * Otherwise use the last component of argv[0].
|
|
247 *
|
|
248 * I have removed the gratuitous use of getenv("RESOURCE_NAME")
|
|
249 * which was in X11R5, but left the matching of any prefix of `-name'.
|
|
250 * Finally, if all else fails, return `xemacs', as it is more
|
|
251 * appropriate (X11R5 returns `main').
|
|
252 */
|
442
|
253 static Extbyte *
|
|
254 compute_x_app_name (int argc, Extbyte **argv)
|
428
|
255 {
|
|
256 int i;
|
442
|
257 Extbyte *ptr;
|
428
|
258
|
|
259 for (i = 1; i < argc - 1; i++)
|
|
260 if (!strncmp(argv[i], "-name", max (2, strlen (argv[1]))))
|
|
261 return argv[i+1];
|
|
262
|
|
263 if (argc > 0 && argv[0] && *argv[0])
|
|
264 return (ptr = strrchr (argv[0], '/')) ? ++ptr : argv[0];
|
|
265
|
|
266 return "xemacs";
|
|
267 }
|
|
268
|
|
269 /*
|
|
270 * This function figures out whether the user has any resources of the
|
|
271 * form "XEmacs.foo" or "XEmacs*foo".
|
|
272 *
|
|
273 * Currently we only consult the display's global resources; to look
|
|
274 * for screen specific resources, we would need to also consult:
|
|
275 * xdefs = XScreenResourceString(ScreenOfDisplay(dpy, scrno));
|
|
276 */
|
|
277 static int
|
|
278 have_xemacs_resources_in_xrdb (Display *dpy)
|
|
279 {
|
|
280 char *xdefs, *key;
|
|
281 int len;
|
|
282
|
|
283 #ifdef INFODOCK
|
|
284 key = "InfoDock";
|
|
285 #else
|
|
286 key = "XEmacs";
|
|
287 #endif
|
|
288 len = strlen (key);
|
|
289
|
|
290 if (!dpy)
|
|
291 return 0;
|
|
292
|
|
293 xdefs = XResourceManagerString (dpy); /* don't free - owned by X */
|
|
294 while (xdefs && *xdefs)
|
|
295 {
|
|
296 if (strncmp (xdefs, key, len) == 0 &&
|
|
297 (xdefs[len] == '*' || xdefs[len] == '.'))
|
|
298 return 1;
|
|
299
|
|
300 while (*xdefs && *xdefs++ != '\n') /* find start of next entry.. */
|
|
301 ;
|
|
302 }
|
|
303
|
|
304 return 0;
|
|
305 }
|
|
306
|
|
307 /* Only the characters [-_A-Za-z0-9] are allowed in the individual
|
|
308 components of a resource. Convert invalid characters to `-' */
|
|
309
|
|
310 static char valid_resource_char_p[256];
|
|
311
|
647
|
312 /* #### not just char * here; may be fixed in my Mule ws */
|
428
|
313 static void
|
665
|
314 validify_resource_component (char *str, Bytecount len)
|
428
|
315 {
|
|
316 for (; len; len--, str++)
|
|
317 if (!valid_resource_char_p[(unsigned char) (*str)])
|
|
318 *str = '-';
|
|
319 }
|
|
320
|
|
321 static void
|
|
322 Dynarr_add_validified_lisp_string (char_dynarr *cda, Lisp_Object str)
|
|
323 {
|
|
324 Bytecount len = XSTRING_LENGTH (str);
|
|
325 Dynarr_add_many (cda, (char *) XSTRING_DATA (str), len);
|
|
326 validify_resource_component (Dynarr_atp (cda, Dynarr_length (cda) - len), len);
|
|
327 }
|
|
328
|
|
329 #if 0
|
|
330 /* compare visual info for qsorting */
|
|
331 static int
|
|
332 x_comp_visual_info (const void *elem1, const void *elem2)
|
|
333 {
|
|
334 XVisualInfo *left, *right;
|
|
335
|
|
336 left = (XVisualInfo *)elem1;
|
|
337 right = (XVisualInfo *)elem2;
|
|
338
|
|
339 if ( left == NULL )
|
|
340 return -1;
|
|
341 if ( right == NULL )
|
|
342 return 1;
|
|
343
|
|
344 if ( left->depth > right->depth ) {
|
|
345 return 1;
|
|
346 }
|
|
347 else if ( left->depth == right->depth ) {
|
|
348 if ( left->colormap_size > right->colormap_size )
|
|
349 return 1;
|
|
350 if ( left->class > right->class )
|
|
351 return 1;
|
|
352 else if ( left->class < right->class )
|
|
353 return -1;
|
|
354 else
|
|
355 return 0;
|
|
356 }
|
|
357 else {
|
|
358 return -1;
|
|
359 }
|
|
360
|
|
361 }
|
|
362 #endif /* if 0 */
|
|
363
|
|
364 #define XXX_IMAGE_LIBRARY_IS_SOMEWHAT_BROKEN
|
|
365 static Visual *
|
|
366 x_try_best_visual_class (Screen *screen, int scrnum, int visual_class)
|
|
367 {
|
|
368 Display *dpy = DisplayOfScreen (screen);
|
|
369 XVisualInfo vi_in;
|
|
370 XVisualInfo *vi_out = NULL;
|
|
371 int out_count;
|
|
372
|
|
373 vi_in.class = visual_class;
|
|
374 vi_in.screen = scrnum;
|
|
375 vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask),
|
|
376 &vi_in, &out_count);
|
|
377 if ( vi_out )
|
|
378 {
|
|
379 int i, best;
|
|
380 Visual *visual;
|
|
381 for (i = 0, best = 0; i < out_count; i++)
|
|
382 /* It's better if it's deeper, or if it's the same depth with
|
|
383 more cells (does that ever happen? Well, it could...)
|
|
384 NOTE: don't allow pseudo color to get larger than 8! */
|
|
385 if (((vi_out [i].depth > vi_out [best].depth) ||
|
|
386 ((vi_out [i].depth == vi_out [best].depth) &&
|
|
387 (vi_out [i].colormap_size > vi_out [best].colormap_size)))
|
|
388 #ifdef XXX_IMAGE_LIBRARY_IS_SOMEWHAT_BROKEN
|
|
389 /* For now, the image library doesn't like PseudoColor visuals
|
|
390 of depths other than 1 or 8. Depths greater than 8 only occur
|
|
391 on machines which have TrueColor anyway, so probably we'll end
|
|
392 up using that (it is the one that `Best' would pick) but if a
|
|
393 PseudoColor visual is explicitly specified, pick the 8 bit one.
|
|
394 */
|
|
395 && (visual_class != PseudoColor ||
|
|
396 vi_out [i].depth == 1 ||
|
|
397 vi_out [i].depth == 8)
|
|
398 #endif
|
|
399
|
|
400 /* SGI has 30-bit deep visuals. Ignore them.
|
|
401 (We only have 24-bit data anyway.)
|
|
402 */
|
|
403 && (vi_out [i].depth <= 24)
|
|
404 )
|
|
405 best = i;
|
|
406 visual = vi_out[best].visual;
|
|
407 XFree ((char *) vi_out);
|
|
408 return visual;
|
|
409 }
|
|
410 else
|
|
411 return 0;
|
|
412 }
|
|
413
|
|
414 static int
|
|
415 x_get_visual_depth (Display *dpy, Visual *visual)
|
|
416 {
|
|
417 XVisualInfo vi_in;
|
|
418 XVisualInfo *vi_out;
|
|
419 int out_count, d;
|
|
420
|
|
421 vi_in.visualid = XVisualIDFromVisual (visual);
|
|
422 vi_out = XGetVisualInfo (dpy, /*VisualScreenMask|*/VisualIDMask,
|
|
423 &vi_in, &out_count);
|
|
424 if (! vi_out) abort ();
|
|
425 d = vi_out [0].depth;
|
|
426 XFree ((char *) vi_out);
|
|
427 return d;
|
|
428 }
|
|
429
|
|
430 static Visual *
|
|
431 x_try_best_visual (Display *dpy, int scrnum)
|
|
432 {
|
|
433 Visual *visual = NULL;
|
|
434 Screen *screen = ScreenOfDisplay (dpy, scrnum);
|
|
435 if ((visual = x_try_best_visual_class (screen, scrnum, TrueColor))
|
|
436 && x_get_visual_depth (dpy, visual) >= 16 )
|
|
437 return visual;
|
|
438 if ((visual = x_try_best_visual_class (screen, scrnum, PseudoColor)))
|
|
439 return visual;
|
|
440 if ((visual = x_try_best_visual_class (screen, scrnum, TrueColor)))
|
|
441 return visual;
|
|
442 #ifdef DIRECTCOLOR_WORKS
|
|
443 if ((visual = x_try_best_visual_class (screen, scrnum, DirectColor)))
|
|
444 return visual;
|
|
445 #endif
|
|
446
|
|
447 visual = DefaultVisualOfScreen (screen);
|
|
448 if ( x_get_visual_depth (dpy, visual) >= 8 )
|
|
449 return visual;
|
|
450
|
|
451 if ((visual = x_try_best_visual_class (screen, scrnum, StaticGray)))
|
|
452 return visual;
|
|
453 if ((visual = x_try_best_visual_class (screen, scrnum, GrayScale)))
|
|
454 return visual;
|
|
455 return DefaultVisualOfScreen (screen);
|
|
456 }
|
|
457
|
|
458
|
|
459 static void
|
|
460 x_init_device (struct device *d, Lisp_Object props)
|
|
461 {
|
|
462 Lisp_Object display;
|
|
463 Lisp_Object device;
|
|
464 Display *dpy;
|
|
465 Widget app_shell;
|
|
466 int argc;
|
442
|
467 Extbyte **argv;
|
|
468 const char *app_class;
|
|
469 const char *app_name;
|
|
470 const char *disp_name;
|
428
|
471 Visual *visual = NULL;
|
|
472 int depth = 8; /* shut up the compiler */
|
|
473 Colormap cmap;
|
|
474 int screen;
|
|
475 /* */
|
|
476 int best_visual_found = 0;
|
|
477
|
442
|
478 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
|
440
|
479 /*
|
|
480 * In order to avoid the lossage with flat Athena widgets dynamically
|
|
481 * linking to one of the ThreeD variants, using the dynamic symbol helpers
|
|
482 * to look for symbols that shouldn't be there and refusing to run if they
|
|
483 * are seems a less toxic idea than having XEmacs crash when we try and
|
|
484 * use a subclass of a widget that has changed size.
|
|
485 *
|
|
486 * It's ugly, I know, and not going to work everywhere. It seems better to
|
|
487 * do our damnedest to try and tell the user what to expect rather than
|
|
488 * simply blow up though.
|
|
489 *
|
|
490 * All the ThreeD variants I have access to define the following function
|
|
491 * symbols in the shared library. The flat Xaw library does not define them:
|
|
492 *
|
|
493 * Xaw3dComputeBottomShadowRGB
|
|
494 * Xaw3dComputeTopShadowRGB
|
|
495 *
|
|
496 * So far only Linux has shown this problem. This seems to be portable to
|
|
497 * all the distributions (certainly all the ones I checked - Debian and
|
|
498 * Redhat)
|
|
499 *
|
|
500 * This will only work, sadly, with dlopen() -- the other dynamic linkers
|
|
501 * are simply not capable of doing what is needed. :/
|
|
502 */
|
|
503
|
|
504 {
|
|
505 /* Get a dll handle to the main process. */
|
|
506 dll_handle xaw_dll_handle = dll_open (NULL);
|
|
507
|
|
508 /* Did that fail? If so, continue without error.
|
|
509 * We could die here but, well, that's unfriendly and all -- plus I feel
|
|
510 * better about some crashing somewhere rather than preventing a perfectly
|
|
511 * good configuration working just because dll_open failed.
|
|
512 */
|
|
513 if (xaw_dll_handle != NULL)
|
|
514 {
|
|
515 /* Look for the Xaw3d function */
|
|
516 dll_func xaw_function_handle =
|
|
517 dll_function (xaw_dll_handle, "Xaw3dComputeTopShadowRGB");
|
|
518
|
|
519 /* If we found it, warn the user in big, nasty, unfriendly letters */
|
|
520 if (xaw_function_handle != NULL)
|
|
521 {
|
|
522 warn_when_safe (Qdevice, Qerror, "\n"
|
|
523 "It seems that XEmacs is built dynamically linked to the flat Athena widget\n"
|
|
524 "library but it finds a 3D Athena variant with the same name at runtime.\n"
|
|
525 "\n"
|
|
526 "This WILL cause your XEmacs process to dump core at some point.\n"
|
|
527 "You should not continue to use this binary without resolving this issue.\n"
|
|
528 "\n"
|
|
529 "This can be solved with the xaw-wrappers package under Debian\n"
|
|
530 "(register XEmacs as incompatible with all 3d widget sets, see\n"
|
|
531 "update-xaw-wrappers(8) and .../doc/xaw-wrappers/README.packagers). It\n"
|
|
532 "can be verified by checking the runtime path in /etc/ld.so.conf and by\n"
|
|
533 "using `ldd /path/to/xemacs' under other Linux distributions. One\n"
|
|
534 "solution is to use LD_PRELOAD or LD_LIBRARY_PATH to force ld.so to\n"
|
|
535 "load the flat Athena widget library instead of the aliased 3D widget\n"
|
|
536 "library (see ld.so(8) for use of these environment variables).\n\n"
|
|
537 );
|
|
538
|
|
539 }
|
|
540
|
|
541 /* Otherwise release the handle to the library
|
|
542 * No error catch here; I can't think of a way to recover anyhow.
|
|
543 */
|
|
544 dll_close (xaw_dll_handle);
|
|
545 }
|
|
546 }
|
442
|
547 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */
|
440
|
548
|
|
549
|
428
|
550 XSETDEVICE (device, d);
|
|
551 display = DEVICE_CONNECTION (d);
|
|
552
|
|
553 allocate_x_device_struct (d);
|
|
554
|
|
555 make_argc_argv (Vx_initial_argv_list, &argc, &argv);
|
|
556
|
442
|
557 LISP_STRING_TO_EXTERNAL (display, disp_name, Qctext);
|
428
|
558
|
|
559 /*
|
|
560 * Break apart the old XtOpenDisplay call into XOpenDisplay and
|
|
561 * XtDisplayInitialize so we can figure out whether there
|
|
562 * are any XEmacs resources in the resource database before
|
|
563 * we initialize Xt. This is so we can automagically support
|
|
564 * both `Emacs' and `XEmacs' application classes.
|
|
565 */
|
|
566 slow_down_interrupts ();
|
|
567 /* May not be needed but XtOpenDisplay could not deal with signals here. */
|
756
|
568 device_being_initialized = d;
|
428
|
569 dpy = DEVICE_X_DISPLAY (d) = XOpenDisplay (disp_name);
|
756
|
570 device_being_initialized = NULL;
|
428
|
571 speed_up_interrupts ();
|
|
572
|
|
573 if (dpy == 0)
|
|
574 {
|
|
575 suppress_early_error_handler_backtrace = 1;
|
563
|
576 gui_error ("X server not responding\n", display);
|
428
|
577 }
|
|
578
|
|
579 if (STRINGP (Vx_emacs_application_class) &&
|
|
580 XSTRING_LENGTH (Vx_emacs_application_class) > 0)
|
442
|
581 LISP_STRING_TO_EXTERNAL (Vx_emacs_application_class, app_class, Qctext);
|
428
|
582 else
|
|
583 {
|
|
584 app_class = (NILP (Vx_emacs_application_class) &&
|
|
585 have_xemacs_resources_in_xrdb (dpy))
|
|
586 #ifdef INFODOCK
|
|
587 ? "InfoDock"
|
|
588 #else
|
|
589 ? "XEmacs"
|
|
590 #endif
|
|
591 : "Emacs";
|
|
592 /* need to update Vx_emacs_application_class: */
|
|
593 Vx_emacs_application_class = build_string (app_class);
|
|
594 }
|
|
595
|
|
596 slow_down_interrupts ();
|
|
597 /* May not be needed but XtOpenDisplay could not deal with signals here.
|
|
598 Yuck. */
|
|
599 XtDisplayInitialize (Xt_app_con, dpy, compute_x_app_name (argc, argv),
|
|
600 app_class, emacs_options,
|
442
|
601 XtNumber (emacs_options), &argc, (char **) argv);
|
428
|
602 speed_up_interrupts ();
|
|
603
|
|
604 screen = DefaultScreen (dpy);
|
|
605 if (NILP (Vdefault_x_device))
|
|
606 Vdefault_x_device = device;
|
|
607
|
|
608 #ifdef MULE
|
|
609 #if defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET)
|
|
610 {
|
|
611 /* Read in locale-specific resources from
|
|
612 data-directory/app-defaults/$LANG/Emacs.
|
|
613 This is in addition to the standard app-defaults files, and
|
|
614 does not override resources defined elsewhere */
|
442
|
615 const char *data_dir;
|
428
|
616 char *path;
|
|
617 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */
|
442
|
618 const char *locale = XrmLocaleOfDatabase (db);
|
428
|
619
|
|
620 if (STRINGP (Vx_app_defaults_directory) &&
|
|
621 XSTRING_LENGTH (Vx_app_defaults_directory) > 0)
|
|
622 {
|
442
|
623 LISP_STRING_TO_EXTERNAL (Vx_app_defaults_directory, data_dir, Qfile_name);
|
428
|
624 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7);
|
|
625 sprintf (path, "%s%s/Emacs", data_dir, locale);
|
|
626 if (!access (path, R_OK))
|
|
627 XrmCombineFileDatabase (path, &db, False);
|
|
628 }
|
|
629 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0)
|
|
630 {
|
442
|
631 LISP_STRING_TO_EXTERNAL (Vdata_directory, data_dir, Qfile_name);
|
428
|
632 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7);
|
|
633 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale);
|
|
634 if (!access (path, R_OK))
|
|
635 XrmCombineFileDatabase (path, &db, False);
|
|
636 }
|
|
637 }
|
|
638 #endif /* LWLIB_MENUBARS_MOTIF or HAVE_XIM USE_XFONTSET */
|
|
639 #endif /* MULE */
|
|
640
|
|
641 if (NILP (DEVICE_NAME (d)))
|
|
642 DEVICE_NAME (d) = display;
|
|
643
|
|
644 /* We're going to modify the string in-place, so be a nice XEmacs */
|
|
645 DEVICE_NAME (d) = Fcopy_sequence (DEVICE_NAME (d));
|
|
646 /* colons and periods can't appear in individual elements of resource
|
|
647 strings */
|
|
648
|
|
649 XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class);
|
|
650 /* search for a matching visual if requested by the user, or setup the display default */
|
|
651 {
|
|
652 int resource_name_length = max (sizeof (".emacsVisual"),
|
|
653 sizeof (".privateColormap"));
|
|
654 char *buf1 = alloca_array (char, strlen (app_name) + resource_name_length);
|
|
655 char *buf2 = alloca_array (char, strlen (app_class) + resource_name_length);
|
|
656 char *type;
|
|
657 XrmValue value;
|
|
658
|
|
659 sprintf (buf1, "%s.emacsVisual", app_name);
|
|
660 sprintf (buf2, "%s.EmacsVisual", app_class);
|
|
661 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
|
|
662 {
|
|
663 int cnt = 0;
|
|
664 int vis_class = PseudoColor;
|
|
665 XVisualInfo vinfo;
|
|
666 char *str = (char*) value.addr;
|
|
667
|
|
668 #define CHECK_VIS_CLASS(visual_class) \
|
|
669 else if (memcmp (str, #visual_class, sizeof (#visual_class) - 1) == 0) \
|
|
670 cnt = sizeof (#visual_class) - 1, vis_class = visual_class
|
|
671
|
|
672 if (1)
|
|
673 ;
|
|
674 CHECK_VIS_CLASS (StaticGray);
|
|
675 CHECK_VIS_CLASS (StaticColor);
|
|
676 CHECK_VIS_CLASS (TrueColor);
|
|
677 CHECK_VIS_CLASS (GrayScale);
|
|
678 CHECK_VIS_CLASS (PseudoColor);
|
|
679 CHECK_VIS_CLASS (DirectColor);
|
|
680
|
|
681 if (cnt)
|
|
682 {
|
|
683 depth = atoi (str + cnt);
|
|
684 if (depth == 0)
|
|
685 {
|
|
686 stderr_out ("Invalid Depth specification in %s... ignoring...\n", str);
|
|
687 }
|
|
688 else
|
|
689 {
|
|
690 if (XMatchVisualInfo (dpy, screen, depth, vis_class, &vinfo))
|
|
691 {
|
|
692 visual = vinfo.visual;
|
|
693 }
|
|
694 else
|
|
695 {
|
|
696 stderr_out ("Can't match the requested visual %s... using defaults\n", str);
|
|
697 }
|
|
698 }
|
|
699 }
|
|
700 else
|
|
701 {
|
|
702 stderr_out( "Invalid Visual specification in %s... ignoring.\n", str);
|
|
703 }
|
|
704 }
|
|
705 if (visual == NULL)
|
|
706 {
|
|
707 /*
|
|
708 visual = DefaultVisual(dpy, screen);
|
|
709 depth = DefaultDepth(dpy, screen);
|
|
710 */
|
|
711 visual = x_try_best_visual (dpy, screen);
|
|
712 depth = x_get_visual_depth (dpy, visual);
|
|
713 best_visual_found = (visual != DefaultVisual (dpy, screen));
|
|
714 }
|
|
715
|
|
716 /* If we've got the same visual as the default and it's PseudoColor,
|
|
717 check to see if the user specified that we need a private colormap */
|
|
718 if (visual == DefaultVisual (dpy, screen))
|
|
719 {
|
|
720 sprintf (buf1, "%s.privateColormap", app_name);
|
|
721 sprintf (buf2, "%s.PrivateColormap", app_class);
|
|
722 if ((visual->class == PseudoColor) &&
|
|
723 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True))
|
|
724 {
|
|
725 cmap = XCopyColormapAndFree (dpy, DefaultColormap (dpy, screen));
|
|
726 }
|
|
727 else
|
|
728 {
|
|
729 cmap = DefaultColormap (dpy, screen);
|
|
730 }
|
|
731 }
|
|
732 else
|
|
733 {
|
|
734 if ( best_visual_found )
|
|
735 {
|
|
736 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone);
|
|
737 }
|
|
738 else
|
|
739 {
|
|
740 /* We have to create a matching colormap anyway...
|
440
|
741 #### think about using standard colormaps (need the Xmu libs?) */
|
428
|
742 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
|
|
743 XInstallColormap(dpy, cmap);
|
|
744 }
|
|
745 }
|
|
746 }
|
|
747
|
|
748 DEVICE_X_VISUAL (d) = visual;
|
|
749 DEVICE_X_COLORMAP (d) = cmap;
|
|
750 DEVICE_X_DEPTH (d) = depth;
|
|
751 validify_resource_component ((char *) XSTRING_DATA (DEVICE_NAME (d)),
|
|
752 XSTRING_LENGTH (DEVICE_NAME (d)));
|
|
753
|
|
754 {
|
|
755 Arg al[3];
|
|
756 XtSetArg (al[0], XtNvisual, visual);
|
|
757 XtSetArg (al[1], XtNdepth, depth);
|
|
758 XtSetArg (al[2], XtNcolormap, cmap);
|
|
759
|
|
760 app_shell = XtAppCreateShell (NULL, app_class,
|
|
761 applicationShellWidgetClass,
|
|
762 dpy, al, countof (al));
|
|
763 }
|
|
764
|
|
765 DEVICE_XT_APP_SHELL (d) = app_shell;
|
|
766
|
|
767 #ifdef HAVE_XIM
|
|
768 XIM_init_device(d);
|
|
769 #endif /* HAVE_XIM */
|
|
770
|
|
771 /* Realize the app_shell so that its window exists for GC creation purposes,
|
|
772 and set it to the size of the root window for child placement purposes */
|
|
773 {
|
|
774 Arg al[5];
|
|
775 XtSetArg (al[0], XtNmappedWhenManaged, False);
|
|
776 XtSetArg (al[1], XtNx, 0);
|
|
777 XtSetArg (al[2], XtNy, 0);
|
|
778 XtSetArg (al[3], XtNwidth, WidthOfScreen (ScreenOfDisplay (dpy, screen)));
|
|
779 XtSetArg (al[4], XtNheight, HeightOfScreen (ScreenOfDisplay (dpy, screen)));
|
|
780 XtSetValues (app_shell, al, countof (al));
|
|
781 XtRealizeWidget (app_shell);
|
|
782 }
|
|
783
|
|
784 #ifdef HAVE_WMCOMMAND
|
|
785 {
|
|
786 int new_argc;
|
442
|
787 Extbyte **new_argv;
|
428
|
788 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv);
|
442
|
789 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell),
|
|
790 (char **) new_argv, new_argc);
|
428
|
791 free_argc_argv (new_argv);
|
|
792 }
|
|
793 #endif /* HAVE_WMCOMMAND */
|
|
794
|
|
795
|
|
796 #ifdef HAVE_OFFIX_DND
|
|
797 DndInitialize ( app_shell );
|
|
798 #endif
|
|
799
|
|
800 Vx_initial_argv_list = make_arg_list (argc, argv);
|
|
801 free_argc_argv (argv);
|
|
802
|
|
803 DEVICE_X_WM_COMMAND_FRAME (d) = Qnil;
|
|
804
|
|
805 sanity_check_geometry_resource (dpy);
|
|
806
|
|
807 /* In event-Xt.c */
|
|
808 x_init_modifier_mapping (d);
|
|
809
|
|
810 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (dpy);
|
|
811 init_baud_rate (d);
|
|
812 init_one_device (d);
|
|
813
|
|
814 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell));
|
|
815 DEVICE_X_GRAY_PIXMAP (d) = None;
|
|
816 Xatoms_of_device_x (d);
|
440
|
817 Xatoms_of_select_x (d);
|
428
|
818 Xatoms_of_objects_x (d);
|
|
819 x_init_device_class (d);
|
|
820
|
|
821 /* Run the elisp side of the X device initialization. */
|
|
822 call0 (Qinit_pre_x_win);
|
|
823 }
|
|
824
|
|
825 static void
|
|
826 x_finish_init_device (struct device *d, Lisp_Object props)
|
|
827 {
|
|
828 call0 (Qinit_post_x_win);
|
|
829 }
|
|
830
|
|
831 static void
|
|
832 x_mark_device (struct device *d)
|
|
833 {
|
|
834 mark_object (DEVICE_X_WM_COMMAND_FRAME (d));
|
|
835 mark_object (DEVICE_X_DATA (d)->x_keysym_map_hash_table);
|
|
836 }
|
|
837
|
|
838
|
|
839 /************************************************************************/
|
|
840 /* closing an X connection */
|
|
841 /************************************************************************/
|
|
842
|
|
843 static void
|
|
844 free_x_device_struct (struct device *d)
|
|
845 {
|
|
846 xfree (d->device_data);
|
|
847 }
|
|
848
|
|
849 static void
|
|
850 x_delete_device (struct device *d)
|
|
851 {
|
|
852 Lisp_Object device;
|
|
853 Display *display;
|
|
854 #ifdef FREE_CHECKING
|
|
855 extern void (*__free_hook) (void *);
|
|
856 int checking_free;
|
|
857 #endif
|
|
858
|
|
859 XSETDEVICE (device, d);
|
|
860 display = DEVICE_X_DISPLAY (d);
|
|
861
|
|
862 if (display)
|
|
863 {
|
|
864 #ifdef FREE_CHECKING
|
|
865 checking_free = (__free_hook != 0);
|
|
866
|
|
867 /* Disable strict free checking, to avoid bug in X library */
|
|
868 if (checking_free)
|
|
869 disable_strict_free_check ();
|
|
870 #endif
|
|
871
|
|
872 free_gc_cache (DEVICE_X_GC_CACHE (d));
|
|
873 if (DEVICE_X_DATA (d)->x_modifier_keymap)
|
|
874 XFreeModifiermap (DEVICE_X_DATA (d)->x_modifier_keymap);
|
|
875 if (DEVICE_X_DATA (d)->x_keysym_map)
|
|
876 XFree ((char *) DEVICE_X_DATA (d)->x_keysym_map);
|
|
877
|
|
878 if (DEVICE_XT_APP_SHELL (d))
|
|
879 {
|
|
880 XtDestroyWidget (DEVICE_XT_APP_SHELL (d));
|
|
881 DEVICE_XT_APP_SHELL (d) = NULL;
|
|
882 }
|
|
883
|
|
884 XtCloseDisplay (display);
|
|
885 DEVICE_X_DISPLAY (d) = 0;
|
|
886 #ifdef FREE_CHECKING
|
|
887 if (checking_free)
|
|
888 enable_strict_free_check ();
|
|
889 #endif
|
|
890 }
|
|
891
|
|
892 if (EQ (device, Vdefault_x_device))
|
|
893 {
|
|
894 Lisp_Object devcons, concons;
|
|
895 /* #### handle deleting last X device */
|
|
896 Vdefault_x_device = Qnil;
|
|
897 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
898 {
|
|
899 if (DEVICE_X_P (XDEVICE (XCAR (devcons))) &&
|
|
900 !EQ (device, XCAR (devcons)))
|
|
901 {
|
|
902 Vdefault_x_device = XCAR (devcons);
|
|
903 goto double_break;
|
|
904 }
|
|
905 }
|
|
906 }
|
|
907 double_break:
|
|
908 free_x_device_struct (d);
|
|
909 }
|
|
910
|
|
911
|
|
912 /************************************************************************/
|
|
913 /* handle X errors */
|
|
914 /************************************************************************/
|
|
915
|
442
|
916 const char *
|
428
|
917 x_event_name (int event_type)
|
|
918 {
|
442
|
919 static const char *events[] =
|
428
|
920 {
|
|
921 "0: ERROR!",
|
|
922 "1: REPLY",
|
|
923 "KeyPress",
|
|
924 "KeyRelease",
|
|
925 "ButtonPress",
|
|
926 "ButtonRelease",
|
|
927 "MotionNotify",
|
|
928 "EnterNotify",
|
|
929 "LeaveNotify",
|
|
930 "FocusIn",
|
|
931 "FocusOut",
|
|
932 "KeymapNotify",
|
|
933 "Expose",
|
|
934 "GraphicsExpose",
|
|
935 "NoExpose",
|
|
936 "VisibilityNotify",
|
|
937 "CreateNotify",
|
|
938 "DestroyNotify",
|
|
939 "UnmapNotify",
|
|
940 "MapNotify",
|
|
941 "MapRequest",
|
|
942 "ReparentNotify",
|
|
943 "ConfigureNotify",
|
|
944 "ConfigureRequest",
|
|
945 "GravityNotify",
|
|
946 "ResizeRequest",
|
|
947 "CirculateNotify",
|
|
948 "CirculateRequest",
|
|
949 "PropertyNotify",
|
|
950 "SelectionClear",
|
|
951 "SelectionRequest",
|
|
952 "SelectionNotify",
|
|
953 "ColormapNotify",
|
|
954 "ClientMessage",
|
|
955 "MappingNotify",
|
|
956 "LASTEvent"
|
|
957 };
|
|
958
|
|
959 if (event_type < 0 || event_type >= countof (events))
|
|
960 return NULL;
|
|
961 return events [event_type];
|
|
962 }
|
|
963
|
|
964 /* Handling errors.
|
|
965
|
|
966 If an X error occurs which we are not expecting, we have no alternative
|
|
967 but to print it to stderr. It would be nice to stuff it into a pop-up
|
|
968 buffer, or to print it in the minibuffer, but that's not possible, because
|
|
969 one is not allowed to do any I/O on the display connection from an error
|
|
970 handler. The guts of Xlib expect these functions to either return or exit.
|
|
971
|
|
972 However, there are occasions when we might expect an error to reasonably
|
|
973 occur. The interface to this is as follows:
|
|
974
|
|
975 Before calling some X routine which may error, call
|
|
976 expect_x_error (dpy);
|
|
977
|
|
978 Just after calling the X routine, call either:
|
|
979
|
|
980 x_error_occurred_p (dpy);
|
|
981
|
|
982 to ask whether an error happened (and was ignored), or:
|
|
983
|
|
984 signal_if_x_error (dpy, resumable_p);
|
|
985
|
|
986 which will call Fsignal() with args appropriate to the X error, if there
|
|
987 was one. (Resumable_p is whether the debugger should be allowed to
|
|
988 continue from the call to signal.)
|
|
989
|
|
990 You must call one of these two routines immediately after calling the X
|
|
991 routine; think of them as bookends like BLOCK_INPUT and UNBLOCK_INPUT.
|
|
992 */
|
|
993
|
|
994 static int error_expected;
|
|
995 static int error_occurred;
|
|
996 static XErrorEvent last_error;
|
|
997
|
|
998 /* OVERKILL! */
|
|
999
|
|
1000 #ifdef EXTERNAL_WIDGET
|
|
1001 static Lisp_Object
|
|
1002 x_error_handler_do_enqueue (Lisp_Object frame)
|
|
1003 {
|
|
1004 enqueue_magic_eval_event (io_error_delete_frame, frame);
|
|
1005 return Qt;
|
|
1006 }
|
|
1007
|
|
1008 static Lisp_Object
|
|
1009 x_error_handler_error (Lisp_Object data, Lisp_Object dummy)
|
|
1010 {
|
|
1011 return Qnil;
|
|
1012 }
|
|
1013 #endif /* EXTERNAL_WIDGET */
|
|
1014
|
|
1015 int
|
|
1016 x_error_handler (Display *disp, XErrorEvent *event)
|
|
1017 {
|
|
1018 if (error_expected)
|
|
1019 {
|
|
1020 error_expected = 0;
|
|
1021 error_occurred = 1;
|
|
1022 last_error = *event;
|
|
1023 }
|
|
1024 else
|
|
1025 {
|
|
1026 #ifdef EXTERNAL_WIDGET
|
|
1027 struct frame *f;
|
|
1028 struct device *d = get_device_from_display (disp);
|
|
1029
|
|
1030 if ((event->error_code == BadWindow ||
|
|
1031 event->error_code == BadDrawable)
|
|
1032 && ((f = x_any_window_to_frame (d, event->resourceid)) != 0))
|
|
1033 {
|
|
1034 Lisp_Object frame;
|
|
1035
|
|
1036 /* one of the windows comprising one of our frames has died.
|
|
1037 This occurs particularly with ExternalShell frames when the
|
|
1038 client that owns the ExternalShell's window dies.
|
|
1039
|
|
1040 We cannot do any I/O on the display connection so we need
|
|
1041 to enqueue an eval event so that the deletion happens
|
|
1042 later.
|
|
1043
|
|
1044 Furthermore, we need to trap any errors (out-of-memory) that
|
|
1045 may occur when Fenqueue_eval_event is called.
|
|
1046 */
|
|
1047
|
|
1048 if (f->being_deleted)
|
|
1049 return 0;
|
|
1050 XSETFRAME (frame, f);
|
|
1051 if (!NILP (condition_case_1 (Qerror, x_error_handler_do_enqueue,
|
|
1052 frame, x_error_handler_error, Qnil)))
|
|
1053 {
|
|
1054 f->being_deleted = 1;
|
|
1055 f->visible = 0;
|
|
1056 }
|
|
1057 return 0;
|
|
1058 }
|
|
1059 #endif /* EXTERNAL_WIDGET */
|
|
1060
|
|
1061 stderr_out ("\n%s: ",
|
|
1062 (STRINGP (Vinvocation_name)
|
|
1063 ? (char *) XSTRING_DATA (Vinvocation_name)
|
|
1064 : "xemacs"));
|
|
1065 XmuPrintDefaultErrorMessage (disp, event, stderr);
|
|
1066 }
|
|
1067 return 0;
|
|
1068 }
|
|
1069
|
|
1070 void
|
|
1071 expect_x_error (Display *dpy)
|
|
1072 {
|
|
1073 assert (!error_expected);
|
|
1074 XSync (dpy, 0); /* handle pending errors before setting flag */
|
|
1075 error_expected = 1;
|
|
1076 error_occurred = 0;
|
|
1077 }
|
|
1078
|
|
1079 int
|
|
1080 x_error_occurred_p (Display *dpy)
|
|
1081 {
|
|
1082 int val;
|
|
1083 XSync (dpy, 0); /* handle pending errors before setting flag */
|
|
1084 val = error_occurred;
|
|
1085 error_expected = 0;
|
|
1086 error_occurred = 0;
|
|
1087 return val;
|
|
1088 }
|
|
1089
|
|
1090 int
|
|
1091 signal_if_x_error (Display *dpy, int resumable_p)
|
|
1092 {
|
|
1093 char buf[1024];
|
|
1094 Lisp_Object data;
|
|
1095 if (! x_error_occurred_p (dpy))
|
|
1096 return 0;
|
|
1097 data = Qnil;
|
|
1098 sprintf (buf, "0x%X", (unsigned int) last_error.resourceid);
|
|
1099 data = Fcons (build_string (buf), data);
|
|
1100 {
|
|
1101 char num [32];
|
|
1102 sprintf (num, "%d", last_error.request_code);
|
|
1103 XGetErrorDatabaseText (last_error.display, "XRequest", num, "",
|
|
1104 buf, sizeof (buf));
|
|
1105 if (! *buf)
|
|
1106 sprintf (buf, "Request-%d", last_error.request_code);
|
|
1107 data = Fcons (build_string (buf), data);
|
|
1108 }
|
|
1109 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf));
|
|
1110 data = Fcons (build_string (buf), data);
|
|
1111 again:
|
|
1112 Fsignal (Qx_error, data);
|
|
1113 if (! resumable_p) goto again;
|
|
1114 return 1;
|
|
1115 }
|
|
1116
|
|
1117 int
|
|
1118 x_IO_error_handler (Display *disp)
|
|
1119 {
|
|
1120 /* This function can GC */
|
|
1121 Lisp_Object dev;
|
|
1122 struct device *d = get_device_from_display_1 (disp);
|
|
1123
|
756
|
1124 if (!d)
|
|
1125 d = device_being_initialized;
|
|
1126
|
428
|
1127 assert (d != NULL);
|
|
1128 XSETDEVICE (dev, d);
|
|
1129
|
|
1130 if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
|
|
1131 {
|
|
1132 /* We're going down. */
|
|
1133 stderr_out
|
|
1134 ("\n%s: Fatal I/O Error %d (%s) on display connection \"%s\"\n",
|
|
1135 (STRINGP (Vinvocation_name) ?
|
|
1136 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"),
|
|
1137 errno, strerror (errno), DisplayString (disp));
|
|
1138 stderr_out
|
|
1139 (" after %lu requests (%lu known processed) with %d events remaining.\n",
|
|
1140 NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
|
|
1141 QLength (disp));
|
|
1142 /* assert (!_Xdebug); */
|
|
1143 }
|
|
1144 else
|
|
1145 {
|
|
1146 warn_when_safe
|
|
1147 (Qx, Qcritical,
|
|
1148 "I/O Error %d (%s) on display connection\n"
|
|
1149 " \"%s\" after after %lu requests (%lu known processed)\n"
|
|
1150 " with %d events remaining.\n"
|
|
1151 " Throwing to top level.\n",
|
|
1152 errno, strerror (errno), DisplayString (disp),
|
|
1153 NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
|
|
1154 QLength (disp));
|
|
1155 }
|
|
1156
|
|
1157 /* According to X specs, we should not return from this function, or
|
|
1158 Xlib might just decide to exit(). So we mark the offending
|
|
1159 console for deletion and throw to top level. */
|
|
1160 if (d)
|
|
1161 enqueue_magic_eval_event (io_error_delete_device, dev);
|
|
1162 DEVICE_X_BEING_DELETED (d) = 1;
|
|
1163 Fthrow (Qtop_level, Qnil);
|
|
1164
|
|
1165 return 0; /* not reached */
|
|
1166 }
|
|
1167
|
|
1168 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /*
|
|
1169 With a true arg, make the connection to the X server synchronous.
|
|
1170 With false, make it asynchronous. Synchronous connections are much slower,
|
|
1171 but are useful for debugging. (If you get X errors, make the connection
|
|
1172 synchronous, and use a debugger to set a breakpoint on `x_error_handler'.
|
|
1173 Your backtrace of the C stack will now be useful. In asynchronous mode,
|
|
1174 the stack above `x_error_handler' isn't helpful because of buffering.)
|
|
1175 If DEVICE is not specified, the selected device is assumed.
|
|
1176
|
|
1177 Calling this function is the same as calling the C function `XSynchronize',
|
|
1178 or starting the program with the `-sync' command line argument.
|
|
1179 */
|
|
1180 (arg, device))
|
|
1181 {
|
|
1182 struct device *d = decode_x_device (device);
|
|
1183
|
|
1184 XSynchronize (DEVICE_X_DISPLAY (d), !NILP (arg));
|
|
1185
|
|
1186 if (!NILP (arg))
|
|
1187 message ("X connection is synchronous");
|
|
1188 else
|
|
1189 message ("X connection is asynchronous");
|
|
1190
|
|
1191 return arg;
|
|
1192 }
|
|
1193
|
|
1194
|
|
1195 /************************************************************************/
|
|
1196 /* X resources */
|
|
1197 /************************************************************************/
|
|
1198
|
|
1199 #if 0 /* bah humbug. The whole "widget == resource" stuff is such
|
|
1200 a crock of shit that I'm just going to ignore it all. */
|
|
1201
|
|
1202 /* If widget is NULL, we are retrieving device or global face data. */
|
|
1203
|
|
1204 static void
|
|
1205 construct_name_list (Display *display, Widget widget, char *fake_name,
|
|
1206 char *fake_class, char *name, char *class)
|
|
1207 {
|
|
1208 char *stack [100][2];
|
|
1209 Widget this;
|
|
1210 int count = 0;
|
|
1211 char *name_tail, *class_tail;
|
|
1212
|
|
1213 if (widget)
|
|
1214 {
|
|
1215 for (this = widget; this; this = XtParent (this))
|
|
1216 {
|
|
1217 stack [count][0] = this->core.name;
|
|
1218 stack [count][1] = XtClass (this)->core_class.class_name;
|
|
1219 count++;
|
|
1220 }
|
|
1221 count--;
|
|
1222 }
|
|
1223 else if (fake_name && fake_class)
|
|
1224 {
|
|
1225 stack [count][0] = fake_name;
|
|
1226 stack [count][1] = fake_class;
|
|
1227 count++;
|
|
1228 }
|
|
1229
|
|
1230 /* The root widget is an application shell; resource lookups use the
|
|
1231 specified application name and application class in preference to
|
|
1232 the name/class of that widget (which is argv[0] / "ApplicationShell").
|
|
1233 Generally the app name and class will be argv[0] / "Emacs" but
|
|
1234 the former can be set via the -name command-line option, and the
|
|
1235 latter can be set by changing `x-emacs-application-class' in
|
|
1236 lisp/term/x-win.el.
|
|
1237 */
|
|
1238 XtGetApplicationNameAndClass (display,
|
|
1239 &stack [count][0],
|
|
1240 &stack [count][1]);
|
|
1241
|
|
1242 name [0] = 0;
|
|
1243 class [0] = 0;
|
|
1244
|
|
1245 name_tail = name;
|
|
1246 class_tail = class;
|
|
1247 for (; count >= 0; count--)
|
|
1248 {
|
|
1249 strcat (name_tail, stack [count][0]);
|
|
1250 for (; *name_tail; name_tail++)
|
|
1251 if (*name_tail == '.') *name_tail = '_';
|
|
1252 strcat (name_tail, ".");
|
|
1253 name_tail++;
|
|
1254
|
|
1255 strcat (class_tail, stack [count][1]);
|
|
1256 for (; *class_tail; class_tail++)
|
|
1257 if (*class_tail == '.') *class_tail = '_';
|
|
1258 strcat (class_tail, ".");
|
|
1259 class_tail++;
|
|
1260 }
|
|
1261 }
|
|
1262
|
|
1263 #endif /* 0 */
|
|
1264
|
442
|
1265 /* strcasecmp() is not sufficiently portable or standard,
|
|
1266 and it's easier just to write our own. */
|
|
1267 static int
|
|
1268 ascii_strcasecmp (const char *s1, const char *s2)
|
|
1269 {
|
|
1270 while (1)
|
|
1271 {
|
|
1272 char c1 = *s1++;
|
|
1273 char c2 = *s2++;
|
|
1274 if (c1 >= 'A' && c1 <= 'Z') c1 += 'a' - 'A';
|
|
1275 if (c2 >= 'A' && c2 <= 'Z') c2 += 'a' - 'A';
|
|
1276 if (c1 != c2) return c1 - c2;
|
|
1277 if (c1 == '\0') return 0;
|
|
1278 }
|
|
1279 }
|
|
1280
|
428
|
1281 static char_dynarr *name_char_dynarr;
|
|
1282 static char_dynarr *class_char_dynarr;
|
|
1283
|
|
1284 /* Given a locale and device specification from x-get-resource or
|
|
1285 x-get-resource-prefix, return the resource prefix and display to
|
|
1286 fetch the resource on. */
|
|
1287
|
|
1288 static void
|
|
1289 x_get_resource_prefix (Lisp_Object locale, Lisp_Object device,
|
|
1290 Display **display_out, char_dynarr *name,
|
|
1291 char_dynarr *class)
|
|
1292 {
|
|
1293 if (NILP (locale))
|
|
1294 locale = Qglobal;
|
|
1295 if (NILP (Fvalid_specifier_locale_p (locale)))
|
563
|
1296 invalid_argument ("Invalid locale", locale);
|
428
|
1297 if (WINDOWP (locale))
|
|
1298 /* #### I can't come up with any coherent way of naming windows.
|
|
1299 By relative position? That seems tricky because windows
|
|
1300 can change position, be split, etc. By order of creation?
|
|
1301 That seems less than useful. */
|
563
|
1302 signal_error (Qunimplemented,
|
|
1303 "Windows currently can't be resourced", locale);
|
428
|
1304
|
|
1305 if (!NILP (device) && !DEVICEP (device))
|
|
1306 CHECK_DEVICE (device);
|
|
1307 if (DEVICEP (device) && !DEVICE_X_P (XDEVICE (device)))
|
|
1308 device = Qnil;
|
|
1309 if (NILP (device))
|
|
1310 {
|
|
1311 device = DFW_DEVICE (locale);
|
|
1312 if (DEVICEP (device) && !DEVICE_X_P (XDEVICE (device)))
|
|
1313 device = Qnil;
|
|
1314 if (NILP (device))
|
|
1315 device = Vdefault_x_device;
|
|
1316 if (NILP (device))
|
|
1317 {
|
|
1318 *display_out = 0;
|
|
1319 return;
|
|
1320 }
|
|
1321 }
|
|
1322
|
|
1323 *display_out = DEVICE_X_DISPLAY (XDEVICE (device));
|
|
1324
|
|
1325 {
|
|
1326 char *appname, *appclass;
|
|
1327 int name_len, class_len;
|
|
1328 XtGetApplicationNameAndClass (*display_out, &appname, &appclass);
|
|
1329 name_len = strlen (appname);
|
|
1330 class_len = strlen (appclass);
|
|
1331 Dynarr_add_many (name , appname, name_len);
|
|
1332 Dynarr_add_many (class, appclass, class_len);
|
|
1333 validify_resource_component (Dynarr_atp (name, 0), name_len);
|
|
1334 validify_resource_component (Dynarr_atp (class, 0), class_len);
|
|
1335 }
|
|
1336
|
|
1337 if (EQ (locale, Qglobal))
|
|
1338 return;
|
|
1339 if (BUFFERP (locale))
|
|
1340 {
|
|
1341 Dynarr_add_literal_string (name, ".buffer.");
|
|
1342 /* we know buffer is live; otherwise we got an error above. */
|
|
1343 Dynarr_add_validified_lisp_string (name, Fbuffer_name (locale));
|
|
1344 Dynarr_add_literal_string (class, ".EmacsLocaleType.EmacsBuffer");
|
|
1345 }
|
|
1346 else if (FRAMEP (locale))
|
|
1347 {
|
|
1348 Dynarr_add_literal_string (name, ".frame.");
|
|
1349 /* we know frame is live; otherwise we got an error above. */
|
|
1350 Dynarr_add_validified_lisp_string (name, Fframe_name (locale));
|
|
1351 Dynarr_add_literal_string (class, ".EmacsLocaleType.EmacsFrame");
|
|
1352 }
|
|
1353 else
|
|
1354 {
|
|
1355 assert (DEVICEP (locale));
|
|
1356 Dynarr_add_literal_string (name, ".device.");
|
|
1357 /* we know device is live; otherwise we got an error above. */
|
|
1358 Dynarr_add_validified_lisp_string (name, Fdevice_name (locale));
|
|
1359 Dynarr_add_literal_string (class, ".EmacsLocaleType.EmacsDevice");
|
|
1360 }
|
|
1361 return;
|
|
1362 }
|
|
1363
|
|
1364 DEFUN ("x-get-resource", Fx_get_resource, 3, 6, 0, /*
|
|
1365 Retrieve an X resource from the resource manager.
|
|
1366
|
|
1367 The first arg is the name of the resource to retrieve, such as "font".
|
|
1368 The second arg is the class of the resource to retrieve, such as "Font".
|
|
1369 The third arg must be one of the symbols 'string, 'integer, 'natnum, or
|
|
1370 'boolean, specifying the type of object that the database is searched for.
|
|
1371 The fourth arg is the locale to search for the resources on, and can
|
|
1372 currently be a buffer, a frame, a device, or 'global. If omitted, it
|
|
1373 defaults to 'global.
|
|
1374 The fifth arg is the device to search for the resources on. (The resource
|
|
1375 database for a particular device is constructed by combining non-device-
|
|
1376 specific resources such as any command-line resources specified and any
|
|
1377 app-defaults files found [or the fallback resources supplied by XEmacs,
|
|
1378 if no app-defaults file is found] with device-specific resources such as
|
|
1379 those supplied using xrdb.) If omitted, it defaults to the device of
|
|
1380 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device),
|
|
1381 and otherwise defaults to the value of `default-x-device'.
|
|
1382 The sixth arg NOERROR, if non-nil, means do not signal an error if a
|
|
1383 bogus resource specification was retrieved (e.g. if a non-integer was
|
|
1384 given when an integer was requested). In this case, a warning is issued
|
442
|
1385 instead, unless NOERROR is t, in which case no warning is issued.
|
428
|
1386
|
|
1387 The resource names passed to this function are looked up relative to the
|
|
1388 locale.
|
|
1389
|
|
1390 If you want to search for a subresource, you just need to specify the
|
|
1391 resource levels in NAME and CLASS. For example, NAME could be
|
|
1392 "modeline.attributeFont", and CLASS "Face.AttributeFont".
|
|
1393
|
|
1394 Specifically,
|
|
1395
|
|
1396 1) If LOCALE is a buffer, a call
|
|
1397
|
|
1398 (x-get-resource "foreground" "Foreground" 'string SOME-BUFFER)
|
|
1399
|
|
1400 is an interface to a C call something like
|
|
1401
|
|
1402 XrmGetResource (db, "xemacs.buffer.BUFFER-NAME.foreground",
|
|
1403 "Emacs.EmacsLocaleType.EmacsBuffer.Foreground",
|
|
1404 "String");
|
|
1405
|
|
1406 2) If LOCALE is a frame, a call
|
|
1407
|
|
1408 (x-get-resource "foreground" "Foreground" 'string SOME-FRAME)
|
|
1409
|
|
1410 is an interface to a C call something like
|
|
1411
|
|
1412 XrmGetResource (db, "xemacs.frame.FRAME-NAME.foreground",
|
|
1413 "Emacs.EmacsLocaleType.EmacsFrame.Foreground",
|
|
1414 "String");
|
|
1415
|
|
1416 3) If LOCALE is a device, a call
|
|
1417
|
|
1418 (x-get-resource "foreground" "Foreground" 'string SOME-DEVICE)
|
|
1419
|
|
1420 is an interface to a C call something like
|
|
1421
|
|
1422 XrmGetResource (db, "xemacs.device.DEVICE-NAME.foreground",
|
|
1423 "Emacs.EmacsLocaleType.EmacsDevice.Foreground",
|
|
1424 "String");
|
|
1425
|
|
1426 4) If LOCALE is 'global, a call
|
|
1427
|
|
1428 (x-get-resource "foreground" "Foreground" 'string 'global)
|
|
1429
|
|
1430 is an interface to a C call something like
|
|
1431
|
|
1432 XrmGetResource (db, "xemacs.foreground",
|
|
1433 "Emacs.Foreground",
|
|
1434 "String");
|
|
1435
|
|
1436 Note that for 'global, no prefix is added other than that of the
|
|
1437 application itself; thus, you can use this locale to retrieve
|
|
1438 arbitrary application resources, if you really want to.
|
|
1439
|
|
1440 The returned value of this function is nil if the queried resource is not
|
|
1441 found. If the third arg is `string', a string is returned, and if it is
|
|
1442 `integer', an integer is returned. If the third arg is `boolean', then the
|
|
1443 returned value is the list (t) for true, (nil) for false, and is nil to
|
430
|
1444 mean ``unspecified''.
|
428
|
1445 */
|
444
|
1446 (name, class, type, locale, device, noerror))
|
428
|
1447 {
|
|
1448 char* name_string, *class_string;
|
|
1449 char *raw_result;
|
|
1450 XrmDatabase db;
|
|
1451 Display *display;
|
578
|
1452 Error_Behavior errb = decode_error_behavior_flag (noerror);
|
428
|
1453
|
|
1454 CHECK_STRING (name);
|
|
1455 CHECK_STRING (class);
|
|
1456 CHECK_SYMBOL (type);
|
|
1457
|
|
1458 Dynarr_reset (name_char_dynarr);
|
|
1459 Dynarr_reset (class_char_dynarr);
|
|
1460
|
|
1461 x_get_resource_prefix (locale, device, &display,
|
|
1462 name_char_dynarr, class_char_dynarr);
|
|
1463 if (!display)
|
|
1464 return Qnil;
|
|
1465
|
|
1466 db = XtDatabase (display);
|
|
1467
|
|
1468 Dynarr_add (name_char_dynarr, '.');
|
|
1469 Dynarr_add_lisp_string (name_char_dynarr, name);
|
|
1470 Dynarr_add (class_char_dynarr, '.');
|
|
1471 Dynarr_add_lisp_string (class_char_dynarr, class);
|
|
1472 Dynarr_add (name_char_dynarr, '\0');
|
|
1473 Dynarr_add (class_char_dynarr, '\0');
|
|
1474
|
|
1475 name_string = Dynarr_atp (name_char_dynarr, 0);
|
|
1476 class_string = Dynarr_atp (class_char_dynarr, 0);
|
|
1477
|
|
1478 {
|
|
1479 XrmValue xrm_value;
|
|
1480 XrmName namelist[100];
|
|
1481 XrmClass classlist[100];
|
|
1482 XrmName *namerest = namelist;
|
|
1483 XrmClass *classrest = classlist;
|
|
1484 XrmRepresentation xrm_type;
|
|
1485 XrmRepresentation string_quark;
|
|
1486 int result;
|
|
1487 XrmStringToNameList (name_string, namelist);
|
|
1488 XrmStringToClassList (class_string, classlist);
|
|
1489 string_quark = XrmStringToQuark ("String");
|
|
1490
|
|
1491 /* ensure that they have the same length */
|
|
1492 while (namerest[0] && classrest[0])
|
|
1493 namerest++, classrest++;
|
|
1494 if (namerest[0] || classrest[0])
|
563
|
1495 {
|
|
1496 maybe_signal_error_2
|
|
1497 (Qstructure_formation_error,
|
|
1498 "class list and name list must be the same length", name, class,
|
|
1499 Qresource, errb);
|
|
1500 return Qnil;
|
|
1501 }
|
428
|
1502 result = XrmQGetResource (db, namelist, classlist, &xrm_type, &xrm_value);
|
|
1503
|
|
1504 if (result != True || xrm_type != string_quark)
|
|
1505 return Qnil;
|
|
1506 raw_result = (char *) xrm_value.addr;
|
|
1507 }
|
|
1508
|
|
1509 if (EQ (type, Qstring))
|
|
1510 return build_string (raw_result);
|
|
1511 else if (EQ (type, Qboolean))
|
|
1512 {
|
442
|
1513 if (!ascii_strcasecmp (raw_result, "off") ||
|
|
1514 !ascii_strcasecmp (raw_result, "false") ||
|
|
1515 !ascii_strcasecmp (raw_result, "no"))
|
428
|
1516 return Fcons (Qnil, Qnil);
|
442
|
1517 if (!ascii_strcasecmp (raw_result, "on") ||
|
|
1518 !ascii_strcasecmp (raw_result, "true") ||
|
|
1519 !ascii_strcasecmp (raw_result, "yes"))
|
428
|
1520 return Fcons (Qt, Qnil);
|
563
|
1521 return maybe_signal_continuable_error_2
|
|
1522 (Qinvalid_operation, "Can't convert to a Boolean",
|
|
1523 build_string (name_string), build_string (raw_result), Qresource,
|
|
1524 errb);
|
428
|
1525 }
|
|
1526 else if (EQ (type, Qinteger) || EQ (type, Qnatnum))
|
|
1527 {
|
|
1528 int i;
|
|
1529 char c;
|
|
1530 if (1 != sscanf (raw_result, "%d%c", &i, &c))
|
563
|
1531 return maybe_signal_continuable_error_2
|
|
1532 (Qinvalid_operation, "Can't convert to an integer",
|
|
1533 build_string (name_string), build_string (raw_result), Qresource,
|
|
1534 errb);
|
428
|
1535 else if (EQ (type, Qnatnum) && i < 0)
|
563
|
1536 return maybe_signal_continuable_error_2
|
|
1537 (Qinvalid_argument, "Invalid numerical value for resource",
|
|
1538 make_int (i), build_string (name_string), Qresource, errb);
|
428
|
1539 else
|
|
1540 return make_int (i);
|
|
1541 }
|
|
1542 else
|
|
1543 {
|
|
1544 return maybe_signal_continuable_error
|
563
|
1545 (Qwrong_type_argument, "Should be string, integer, natnum or boolean",
|
|
1546 type, Qresource, errb);
|
428
|
1547 }
|
|
1548 }
|
|
1549
|
|
1550 DEFUN ("x-get-resource-prefix", Fx_get_resource_prefix, 1, 2, 0, /*
|
|
1551 Return the resource prefix for LOCALE on DEVICE.
|
|
1552 The resource prefix is the strings used to prefix resources if
|
|
1553 the LOCALE and DEVICE arguments were passed to `x-get-resource'.
|
|
1554 The returned value is a cons of a name prefix and a class prefix.
|
|
1555 For example, if LOCALE is a frame, the returned value might be
|
|
1556 \("xemacs.frame.FRAME-NAME" . "Emacs.EmacsLocaleType.EmacsFrame").
|
|
1557 If no valid X device for resourcing can be obtained, this function
|
|
1558 returns nil. (In such a case, `x-get-resource' would always return nil.)
|
|
1559 */
|
|
1560 (locale, device))
|
|
1561 {
|
|
1562 Display *display;
|
|
1563
|
|
1564 Dynarr_reset (name_char_dynarr );
|
|
1565 Dynarr_reset (class_char_dynarr);
|
|
1566
|
|
1567 x_get_resource_prefix (locale, device, &display,
|
|
1568 name_char_dynarr, class_char_dynarr);
|
|
1569 if (!display)
|
|
1570 return Qnil;
|
|
1571
|
665
|
1572 return Fcons (make_string ((Intbyte *) Dynarr_atp (name_char_dynarr, 0),
|
428
|
1573 Dynarr_length (name_char_dynarr)),
|
665
|
1574 make_string ((Intbyte *) Dynarr_atp (class_char_dynarr, 0),
|
428
|
1575 Dynarr_length (class_char_dynarr)));
|
|
1576 }
|
|
1577
|
|
1578 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /*
|
|
1579 Add a resource to the resource database for DEVICE.
|
|
1580 RESOURCE-LINE specifies the resource to add and should be a
|
|
1581 standard resource specification.
|
|
1582 */
|
|
1583 (resource_line, device))
|
|
1584 {
|
|
1585 struct device *d = decode_device (device);
|
|
1586 char *str, *colon_pos;
|
|
1587
|
|
1588 CHECK_STRING (resource_line);
|
|
1589 str = (char *) XSTRING_DATA (resource_line);
|
|
1590 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n'))
|
|
1591 invalid:
|
563
|
1592 syntax_error ("Invalid resource line", resource_line);
|
647
|
1593 if ((int) strspn (str,
|
|
1594 /* Only the following chars are allowed before the colon */
|
|
1595 " \t.*?abcdefghijklmnopqrstuvwxyz"
|
|
1596 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-")
|
|
1597 != colon_pos - str)
|
428
|
1598 goto invalid;
|
|
1599
|
|
1600 if (DEVICE_X_P (d))
|
|
1601 {
|
|
1602 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d));
|
|
1603 XrmPutLineResource (&db, str);
|
|
1604 }
|
|
1605
|
|
1606 return Qnil;
|
|
1607 }
|
|
1608
|
|
1609
|
|
1610 /************************************************************************/
|
|
1611 /* display information functions */
|
|
1612 /************************************************************************/
|
|
1613
|
|
1614 DEFUN ("default-x-device", Fdefault_x_device, 0, 0, 0, /*
|
|
1615 Return the default X device for resourcing.
|
|
1616 This is the first-created X device that still exists.
|
|
1617 */
|
|
1618 ())
|
|
1619 {
|
|
1620 return Vdefault_x_device;
|
|
1621 }
|
|
1622
|
|
1623 DEFUN ("x-display-visual-class", Fx_display_visual_class, 0, 1, 0, /*
|
|
1624 Return the visual class of the X display DEVICE is using.
|
|
1625 This can be altered from the default at startup using the XResource "EmacsVisual".
|
|
1626 The returned value will be one of the symbols `static-gray', `gray-scale',
|
|
1627 `static-color', `pseudo-color', `true-color', or `direct-color'.
|
|
1628 */
|
|
1629 (device))
|
|
1630 {
|
|
1631 Visual *vis = DEVICE_X_VISUAL (decode_x_device (device));
|
|
1632 switch (vis->class)
|
|
1633 {
|
|
1634 case StaticGray: return intern ("static-gray");
|
|
1635 case GrayScale: return intern ("gray-scale");
|
|
1636 case StaticColor: return intern ("static-color");
|
|
1637 case PseudoColor: return intern ("pseudo-color");
|
|
1638 case TrueColor: return intern ("true-color");
|
|
1639 case DirectColor: return intern ("direct-color");
|
|
1640 default:
|
563
|
1641 invalid_state ("display has an unknown visual class", Qunbound);
|
428
|
1642 return Qnil; /* suppress compiler warning */
|
|
1643 }
|
|
1644 }
|
|
1645
|
|
1646 DEFUN ("x-display-visual-depth", Fx_display_visual_depth, 0, 1, 0, /*
|
|
1647 Return the bitplane depth of the visual the X display DEVICE is using.
|
|
1648 */
|
|
1649 (device))
|
|
1650 {
|
|
1651 return make_int (DEVICE_X_DEPTH (decode_x_device (device)));
|
|
1652 }
|
|
1653
|
|
1654 static Lisp_Object
|
|
1655 x_device_system_metrics (struct device *d,
|
|
1656 enum device_metrics m)
|
|
1657 {
|
|
1658 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1659
|
|
1660 switch (m)
|
|
1661 {
|
|
1662 case DM_size_device:
|
|
1663 return Fcons (make_int (DisplayWidth (dpy, DefaultScreen (dpy))),
|
|
1664 make_int (DisplayHeight (dpy, DefaultScreen (dpy))));
|
|
1665 case DM_size_device_mm:
|
|
1666 return Fcons (make_int (DisplayWidthMM (dpy, DefaultScreen (dpy))),
|
|
1667 make_int (DisplayHeightMM (dpy, DefaultScreen (dpy))));
|
|
1668 case DM_num_bit_planes:
|
|
1669 return make_int (DisplayPlanes (dpy, DefaultScreen (dpy)));
|
|
1670 case DM_num_color_cells:
|
|
1671 return make_int (DisplayCells (dpy, DefaultScreen (dpy)));
|
|
1672 default: /* No such device metric property for X devices */
|
|
1673 return Qunbound;
|
|
1674 }
|
|
1675 }
|
|
1676
|
|
1677 DEFUN ("x-server-vendor", Fx_server_vendor, 0, 1, 0, /*
|
|
1678 Return the vendor ID string of the X server DEVICE is on.
|
|
1679 Return the empty string if the vendor ID string cannot be determined.
|
|
1680 */
|
|
1681 (device))
|
|
1682 {
|
|
1683 Display *dpy = get_x_display (device);
|
|
1684 char *vendor = ServerVendor (dpy);
|
|
1685
|
|
1686 return build_string (vendor ? vendor : "");
|
|
1687 }
|
|
1688
|
|
1689 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /*
|
|
1690 Return the version numbers of the X server DEVICE is on.
|
|
1691 The returned value is a list of three integers: the major and minor
|
|
1692 version numbers of the X Protocol in use, and the vendor-specific release
|
|
1693 number. See also `x-server-vendor'.
|
|
1694 */
|
|
1695 (device))
|
|
1696 {
|
|
1697 Display *dpy = get_x_display (device);
|
|
1698
|
|
1699 return list3 (make_int (ProtocolVersion (dpy)),
|
|
1700 make_int (ProtocolRevision (dpy)),
|
|
1701 make_int (VendorRelease (dpy)));
|
|
1702 }
|
|
1703
|
|
1704 DEFUN ("x-valid-keysym-name-p", Fx_valid_keysym_name_p, 1, 1, 0, /*
|
|
1705 Return true if KEYSYM names a keysym that the X library knows about.
|
|
1706 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1707 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
|
1708 */
|
|
1709 (keysym))
|
|
1710 {
|
442
|
1711 const char *keysym_ext;
|
428
|
1712
|
|
1713 CHECK_STRING (keysym);
|
442
|
1714 LISP_STRING_TO_EXTERNAL (keysym, keysym_ext, Qctext);
|
428
|
1715
|
|
1716 return XStringToKeysym (keysym_ext) ? Qt : Qnil;
|
|
1717 }
|
|
1718
|
|
1719 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /*
|
440
|
1720 Return a hash table containing a key for all keysyms on DEVICE.
|
|
1721 DEVICE must be an X11 display device. See `x-keysym-on-keyboard-p'.
|
428
|
1722 */
|
|
1723 (device))
|
|
1724 {
|
|
1725 struct device *d = decode_device (device);
|
|
1726 if (!DEVICE_X_P (d))
|
563
|
1727 gui_error ("Not an X device", device);
|
428
|
1728
|
|
1729 return DEVICE_X_DATA (d)->x_keysym_map_hash_table;
|
|
1730 }
|
|
1731
|
|
1732 DEFUN ("x-keysym-on-keyboard-sans-modifiers-p", Fx_keysym_on_keyboard_sans_modifiers_p,
|
|
1733 1, 2, 0, /*
|
|
1734 Return true if KEYSYM names a key on the keyboard of DEVICE.
|
|
1735 More precisely, return true if pressing a physical key
|
|
1736 on the keyboard of DEVICE without any modifier keys generates KEYSYM.
|
|
1737 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1738 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
|
1739 The keysym name can be provided in two forms:
|
|
1740 - if keysym is a string, it must be the name as known to X windows.
|
|
1741 - if keysym is a symbol, it must be the name as known to XEmacs.
|
|
1742 The two names differ in capitalization and underscoring.
|
|
1743 */
|
|
1744 (keysym, device))
|
|
1745 {
|
|
1746 struct device *d = decode_device (device);
|
|
1747 if (!DEVICE_X_P (d))
|
563
|
1748 gui_error ("Not an X device", device);
|
428
|
1749
|
|
1750 return (EQ (Qsans_modifiers,
|
|
1751 Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ?
|
|
1752 Qt : Qnil);
|
|
1753 }
|
|
1754
|
|
1755
|
|
1756 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /*
|
|
1757 Return true if KEYSYM names a key on the keyboard of DEVICE.
|
|
1758 More precisely, return true if some keystroke (possibly including modifiers)
|
|
1759 on the keyboard of DEVICE keys generates KEYSYM.
|
|
1760 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1761 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
|
1762 The keysym name can be provided in two forms:
|
|
1763 - if keysym is a string, it must be the name as known to X windows.
|
|
1764 - if keysym is a symbol, it must be the name as known to XEmacs.
|
|
1765 The two names differ in capitalization and underscoring.
|
|
1766 */
|
|
1767 (keysym, device))
|
|
1768 {
|
|
1769 struct device *d = decode_device (device);
|
|
1770 if (!DEVICE_X_P (d))
|
563
|
1771 gui_error ("Not an X device", device);
|
428
|
1772
|
|
1773 return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil)) ?
|
|
1774 Qnil : Qt);
|
|
1775 }
|
|
1776
|
|
1777
|
|
1778 /************************************************************************/
|
|
1779 /* grabs and ungrabs */
|
|
1780 /************************************************************************/
|
|
1781
|
|
1782 DEFUN ("x-grab-pointer", Fx_grab_pointer, 0, 3, 0, /*
|
|
1783 Grab the pointer and restrict it to its current window.
|
|
1784 If optional DEVICE argument is nil, the default device will be used.
|
|
1785 If optional CURSOR argument is non-nil, change the pointer shape to that
|
|
1786 until `x-ungrab-pointer' is called (it should be an object returned by the
|
|
1787 `make-cursor-glyph' function).
|
|
1788 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all
|
|
1789 keyboard events during the grab.
|
|
1790 Returns t if the grab is successful, nil otherwise.
|
|
1791 */
|
|
1792 (device, cursor, ignore_keyboard))
|
|
1793 {
|
|
1794 Window w;
|
|
1795 int pointer_mode, result;
|
|
1796 struct device *d = decode_x_device (device);
|
|
1797
|
|
1798 if (!NILP (cursor))
|
|
1799 {
|
|
1800 CHECK_POINTER_GLYPH (cursor);
|
|
1801 cursor = glyph_image_instance (cursor, device, ERROR_ME, 0);
|
|
1802 }
|
|
1803
|
|
1804 if (!NILP (ignore_keyboard))
|
|
1805 pointer_mode = GrabModeSync;
|
|
1806 else
|
|
1807 pointer_mode = GrabModeAsync;
|
|
1808
|
|
1809 w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
|
|
1810
|
|
1811 /* #### Possibly this needs to gcpro the cursor somehow, but it doesn't
|
|
1812 seem to cause a problem if XFreeCursor is called on a cursor in use
|
|
1813 in a grab; I suppose the X server counts the grab as a reference
|
|
1814 and doesn't free it until it exits? */
|
|
1815 result = XGrabPointer (DEVICE_X_DISPLAY (d), w,
|
|
1816 False,
|
|
1817 ButtonMotionMask |
|
|
1818 ButtonPressMask |
|
|
1819 ButtonReleaseMask |
|
|
1820 PointerMotionHintMask,
|
|
1821 GrabModeAsync, /* Keep pointer events flowing */
|
|
1822 pointer_mode, /* Stall keyboard events */
|
|
1823 w, /* Stay in this window */
|
|
1824 (NILP (cursor) ? 0
|
|
1825 : XIMAGE_INSTANCE_X_CURSOR (cursor)),
|
|
1826 CurrentTime);
|
|
1827 return (result == GrabSuccess) ? Qt : Qnil;
|
|
1828 }
|
|
1829
|
|
1830 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, 0, 1, 0, /*
|
|
1831 Release a pointer grab made with `x-grab-pointer'.
|
|
1832 If optional first arg DEVICE is nil the default device is used.
|
|
1833 If it is t the pointer will be released on all X devices.
|
|
1834 */
|
|
1835 (device))
|
|
1836 {
|
|
1837 if (!EQ (device, Qt))
|
|
1838 {
|
|
1839 Display *dpy = get_x_display (device);
|
|
1840 XUngrabPointer (dpy, CurrentTime);
|
|
1841 }
|
|
1842 else
|
|
1843 {
|
|
1844 Lisp_Object devcons, concons;
|
|
1845
|
|
1846 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
1847 {
|
|
1848 struct device *d = XDEVICE (XCAR (devcons));
|
|
1849
|
|
1850 if (DEVICE_X_P (d))
|
|
1851 XUngrabPointer (DEVICE_X_DISPLAY (d), CurrentTime);
|
|
1852 }
|
|
1853 }
|
|
1854
|
|
1855 return Qnil;
|
|
1856 }
|
|
1857
|
|
1858 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, 0, 1, 0, /*
|
|
1859 Grab the keyboard on the given device (defaulting to the selected one).
|
|
1860 So long as the keyboard is grabbed, all keyboard events will be delivered
|
|
1861 to emacs -- it is not possible for other X clients to eavesdrop on them.
|
|
1862 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect).
|
|
1863 Returns t if the grab is successful, nil otherwise.
|
|
1864 */
|
|
1865 (device))
|
|
1866 {
|
|
1867 struct device *d = decode_x_device (device);
|
|
1868 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
|
|
1869 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1870 Status status;
|
|
1871 XSync (dpy, False);
|
|
1872 status = XGrabKeyboard (dpy, w, True,
|
|
1873 /* I don't really understand sync-vs-async
|
|
1874 grabs, but this is what xterm does. */
|
|
1875 GrabModeAsync, GrabModeAsync,
|
|
1876 /* Use the timestamp of the last user action
|
|
1877 read by emacs proper; xterm uses CurrentTime
|
|
1878 but there's a comment that says "wrong"...
|
|
1879 (Despite the name this is the time of the
|
|
1880 last key or mouse event.) */
|
|
1881 DEVICE_X_MOUSE_TIMESTAMP (d));
|
|
1882 if (status == GrabSuccess)
|
|
1883 {
|
|
1884 /* The XUngrabKeyboard should generate a FocusIn back to this
|
|
1885 window but it doesn't unless we explicitly set focus to the
|
|
1886 window first (which should already have it. The net result
|
|
1887 is that without this call when x-ungrab-keyboard is called
|
|
1888 the selected frame ends up not having focus. */
|
|
1889 XSetInputFocus (dpy, w, RevertToParent, DEVICE_X_MOUSE_TIMESTAMP (d));
|
|
1890 return Qt;
|
|
1891 }
|
|
1892 else
|
|
1893 return Qnil;
|
|
1894 }
|
|
1895
|
|
1896 DEFUN ("x-ungrab-keyboard", Fx_ungrab_keyboard, 0, 1, 0, /*
|
|
1897 Release a keyboard grab made with `x-grab-keyboard'.
|
|
1898 */
|
|
1899 (device))
|
|
1900 {
|
|
1901 Display *dpy = get_x_display (device);
|
|
1902 XUngrabKeyboard (dpy, CurrentTime);
|
|
1903 return Qnil;
|
|
1904 }
|
|
1905
|
|
1906 DEFUN ("x-get-font-path", Fx_get_font_path, 0, 1, 0, /*
|
|
1907 Get the X Server's font path.
|
|
1908
|
|
1909 See also `x-set-font-path'.
|
|
1910 */
|
|
1911 (device))
|
|
1912 {
|
|
1913 Display *dpy = get_x_display (device);
|
|
1914 int ndirs_return;
|
442
|
1915 const char **directories = (const char **) XGetFontPath (dpy, &ndirs_return);
|
428
|
1916 Lisp_Object font_path = Qnil;
|
|
1917
|
|
1918 if (!directories)
|
563
|
1919 gui_error ("Can't get X font path", device);
|
428
|
1920
|
|
1921 while (ndirs_return--)
|
|
1922 font_path = Fcons (build_ext_string (directories[ndirs_return],
|
440
|
1923 Qfile_name),
|
|
1924 font_path);
|
428
|
1925
|
|
1926 return font_path;
|
|
1927 }
|
|
1928
|
|
1929 DEFUN ("x-set-font-path", Fx_set_font_path, 1, 2, 0, /*
|
|
1930 Set the X Server's font path to FONT-PATH.
|
|
1931
|
|
1932 There is only one font path per server, not one per client. Use this
|
|
1933 sparingly. It uncaches all of the X server's font information.
|
|
1934
|
|
1935 Font directories should end in the path separator and should contain
|
|
1936 a file called fonts.dir usually created with the program mkfontdir.
|
|
1937
|
|
1938 Setting the FONT-PATH to nil tells the X server to use the default
|
|
1939 font path.
|
|
1940
|
|
1941 See also `x-get-font-path'.
|
|
1942 */
|
|
1943 (font_path, device))
|
|
1944 {
|
|
1945 Display *dpy = get_x_display (device);
|
|
1946 Lisp_Object path_entry;
|
442
|
1947 const char **directories;
|
428
|
1948 int i=0,ndirs=0;
|
|
1949
|
|
1950 EXTERNAL_LIST_LOOP (path_entry, font_path)
|
|
1951 {
|
|
1952 CHECK_STRING (XCAR (path_entry));
|
|
1953 ndirs++;
|
|
1954 }
|
|
1955
|
442
|
1956 directories = alloca_array (const char *, ndirs);
|
428
|
1957
|
|
1958 EXTERNAL_LIST_LOOP (path_entry, font_path)
|
|
1959 {
|
442
|
1960 LISP_STRING_TO_EXTERNAL (XCAR (path_entry), directories[i++], Qfile_name);
|
428
|
1961 }
|
|
1962
|
|
1963 expect_x_error (dpy);
|
|
1964 XSetFontPath (dpy, (char **) directories, ndirs);
|
|
1965 signal_if_x_error (dpy, 1/*resumable_p*/);
|
|
1966
|
|
1967 return Qnil;
|
|
1968 }
|
|
1969
|
|
1970
|
|
1971 /************************************************************************/
|
|
1972 /* initialization */
|
|
1973 /************************************************************************/
|
|
1974
|
|
1975 void
|
|
1976 syms_of_device_x (void)
|
|
1977 {
|
|
1978 DEFSUBR (Fx_debug_mode);
|
|
1979 DEFSUBR (Fx_get_resource);
|
|
1980 DEFSUBR (Fx_get_resource_prefix);
|
|
1981 DEFSUBR (Fx_put_resource);
|
|
1982
|
|
1983 DEFSUBR (Fdefault_x_device);
|
|
1984 DEFSUBR (Fx_display_visual_class);
|
|
1985 DEFSUBR (Fx_display_visual_depth);
|
|
1986 DEFSUBR (Fx_server_vendor);
|
|
1987 DEFSUBR (Fx_server_version);
|
|
1988 DEFSUBR (Fx_valid_keysym_name_p);
|
|
1989 DEFSUBR (Fx_keysym_hash_table);
|
|
1990 DEFSUBR (Fx_keysym_on_keyboard_p);
|
|
1991 DEFSUBR (Fx_keysym_on_keyboard_sans_modifiers_p);
|
|
1992
|
|
1993 DEFSUBR (Fx_grab_pointer);
|
|
1994 DEFSUBR (Fx_ungrab_pointer);
|
|
1995 DEFSUBR (Fx_grab_keyboard);
|
|
1996 DEFSUBR (Fx_ungrab_keyboard);
|
|
1997
|
|
1998 DEFSUBR (Fx_get_font_path);
|
|
1999 DEFSUBR (Fx_set_font_path);
|
|
2000
|
563
|
2001 DEFSYMBOL (Qx_error);
|
|
2002 DEFSYMBOL (Qinit_pre_x_win);
|
|
2003 DEFSYMBOL (Qinit_post_x_win);
|
428
|
2004 }
|
|
2005
|
|
2006 void
|
|
2007 reinit_console_type_create_device_x (void)
|
|
2008 {
|
|
2009 /* Initialize variables to speed up X resource interactions */
|
442
|
2010 const char *valid_resource_chars =
|
428
|
2011 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
2012 while (*valid_resource_chars)
|
|
2013 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1;
|
|
2014
|
|
2015 name_char_dynarr = Dynarr_new (char);
|
|
2016 class_char_dynarr = Dynarr_new (char);
|
|
2017 }
|
|
2018
|
|
2019 void
|
|
2020 console_type_create_device_x (void)
|
|
2021 {
|
|
2022 reinit_console_type_create_device_x ();
|
|
2023 CONSOLE_HAS_METHOD (x, init_device);
|
|
2024 CONSOLE_HAS_METHOD (x, finish_init_device);
|
|
2025 CONSOLE_HAS_METHOD (x, mark_device);
|
|
2026 CONSOLE_HAS_METHOD (x, delete_device);
|
|
2027 CONSOLE_HAS_METHOD (x, device_system_metrics);
|
|
2028 }
|
|
2029
|
|
2030 void
|
|
2031 reinit_vars_of_device_x (void)
|
|
2032 {
|
|
2033 error_expected = 0;
|
|
2034 error_occurred = 0;
|
|
2035
|
|
2036 in_resource_setting = 0;
|
|
2037 }
|
|
2038
|
|
2039 void
|
|
2040 vars_of_device_x (void)
|
|
2041 {
|
|
2042 reinit_vars_of_device_x ();
|
|
2043
|
|
2044 DEFVAR_LISP ("x-emacs-application-class", &Vx_emacs_application_class /*
|
|
2045 The X application class of the XEmacs process.
|
|
2046 This controls, among other things, the name of the `app-defaults' file
|
|
2047 that XEmacs will use. For changes to this variable to take effect, they
|
|
2048 must be made before the connection to the X server is initialized, that is,
|
|
2049 this variable may only be changed before emacs is dumped, or by setting it
|
|
2050 in the file lisp/term/x-win.el.
|
|
2051
|
|
2052 If this variable is nil before the connection to the X server is first
|
|
2053 initialized (which it is by default), the X resource database will be
|
|
2054 consulted and the value will be set according to whether any resources
|
|
2055 are found for the application class `XEmacs'. If the user has set any
|
|
2056 resources for the XEmacs application class, the XEmacs process will use
|
|
2057 the application class `XEmacs'. Otherwise, the XEmacs process will use
|
|
2058 the application class `Emacs' which is backwards compatible to previous
|
|
2059 XEmacs versions but may conflict with resources intended for GNU Emacs.
|
|
2060 */ );
|
|
2061 Vx_emacs_application_class = Qnil;
|
|
2062
|
|
2063 DEFVAR_LISP ("x-initial-argv-list", &Vx_initial_argv_list /*
|
|
2064 You don't want to know.
|
|
2065 This is used during startup to communicate the remaining arguments in
|
|
2066 `command-line-args-left' to the C code, which passes the args to
|
|
2067 the X initialization code, which removes some args, and then the
|
|
2068 args are placed back into `x-initial-arg-list' and thence into
|
|
2069 `command-line-args-left'. Perhaps `command-line-args-left' should
|
|
2070 just reside in C.
|
|
2071 */ );
|
|
2072 Vx_initial_argv_list = Qnil;
|
|
2073
|
|
2074 #if defined(MULE) && (defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET))
|
|
2075 DEFVAR_LISP ("x-app-defaults-directory", &Vx_app_defaults_directory /*
|
|
2076 Used by the Lisp code to communicate to the low level X initialization
|
|
2077 where the localized init files are.
|
|
2078 */ );
|
|
2079 Vx_app_defaults_directory = Qnil;
|
|
2080 #endif
|
|
2081
|
|
2082 Fprovide (Qx);
|
|
2083
|
|
2084 staticpro (&Vdefault_x_device);
|
|
2085 Vdefault_x_device = Qnil;
|
|
2086 }
|