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