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