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