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