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