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