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