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