0
|
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.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
|
24 /* Original authors: Jamie Zawinski and the FSF */
|
|
25 /* Rewritten by Ben Wing and Chuck Thompson. */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "console-x.h"
|
|
31 #include "xintrinsicp.h" /* CoreP.h needs this */
|
|
32 #include <X11/CoreP.h> /* Numerous places access the fields of
|
|
33 a core widget directly. We could
|
165
|
34 use XtGetValues(), but ... */
|
0
|
35 #include "xgccache.h"
|
|
36 #include <X11/Shell.h>
|
|
37 #include "xmu.h"
|
|
38 #include "glyphs-x.h"
|
|
39 #include "objects-x.h"
|
|
40
|
|
41 #include "buffer.h"
|
|
42 #include "events.h"
|
|
43 #include "faces.h"
|
|
44 #include "frame.h"
|
|
45 #include "redisplay.h"
|
|
46 #include "sysdep.h"
|
|
47 #include "window.h"
|
|
48
|
|
49 #include "sysfile.h"
|
|
50 #include "systime.h"
|
|
51
|
197
|
52 #ifdef HAVE_OFFIX_DND
|
|
53 #include "offix.h"
|
|
54 #endif
|
|
55
|
0
|
56 Lisp_Object Vdefault_x_device;
|
|
57
|
|
58 /* Qdisplay in general.c */
|
183
|
59 Lisp_Object Qx_error;
|
0
|
60 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win;
|
|
61
|
167
|
62 /* $B@ZJ"(B, n. Japanese ritual suicide. */
|
|
63 int x_seppuku_on_epipe;
|
|
64
|
0
|
65 /* The application class of Emacs. */
|
|
66 Lisp_Object Vx_emacs_application_class;
|
|
67
|
|
68 Lisp_Object Vx_initial_argv_list; /* #### ugh! */
|
|
69
|
|
70 static XrmOptionDescRec emacs_options[] =
|
|
71 {
|
183
|
72 {"-geometry", ".geometry", XrmoptionSepArg, NULL},
|
185
|
73 {"-iconic", ".iconic", XrmoptionNoArg, "yes"},
|
2
|
74
|
187
|
75 {"-internal-border-width", "*EmacsFrame.internalBorderWidth", XrmoptionSepArg, NULL},
|
|
76 {"-ib", "*EmacsFrame.internalBorderWidth", XrmoptionSepArg, NULL},
|
|
77 {"-scrollbar-width", "*EmacsFrame.scrollBarWidth", XrmoptionSepArg, NULL},
|
|
78 {"-scrollbar-height", "*EmacsFrame.scrollBarHeight", XrmoptionSepArg, NULL},
|
0
|
79
|
219
|
80 {"-privatecolormap", ".privateColormap", XrmoptionNoArg, "yes"},
|
|
81 {"-visual", ".EmacsVisual", XrmoptionSepArg, NULL},
|
|
82
|
0
|
83 /* #### Beware! If the type of the shell changes, update this. */
|
187
|
84 {"-T", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
|
85 {"-wn", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
|
86 {"-title", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL},
|
183
|
87
|
|
88 {"-iconname", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL},
|
187
|
89 {"-in", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL},
|
|
90 {"-mc", "*pointerColor", XrmoptionSepArg, NULL},
|
|
91 {"-cr", "*cursorColor", XrmoptionSepArg, NULL},
|
|
92 {"-fontset", "*FontSet", XrmoptionSepArg, NULL},
|
0
|
93 };
|
|
94
|
|
95 static void validify_resource_string (char *str);
|
|
96
|
|
97 /* Functions to synchronize mirroring resources and specifiers */
|
|
98 int in_resource_setting;
|
|
99 int in_specifier_change_function;
|
|
100
|
|
101
|
|
102 /************************************************************************/
|
|
103 /* helper functions */
|
|
104 /************************************************************************/
|
|
105
|
219
|
106 /* JH 97/11/25 removed the static declaration because I need it during setup in event-Xt... */
|
|
107 struct device *
|
114
|
108 get_device_from_display_1 (Display *dpy)
|
0
|
109 {
|
|
110 Lisp_Object devcons, concons;
|
|
111
|
|
112 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
113 {
|
|
114 struct device *d = XDEVICE (XCAR (devcons));
|
|
115 if (DEVICE_X_P (d) && DEVICE_X_DISPLAY (d) == dpy)
|
|
116 return d;
|
|
117 }
|
|
118
|
114
|
119 return 0;
|
|
120 }
|
|
121
|
|
122 struct device *
|
|
123 get_device_from_display (Display *dpy)
|
|
124 {
|
|
125 struct device *d = get_device_from_display_1 (dpy);
|
0
|
126
|
114
|
127 if (!d) {
|
|
128 /* This isn't one of our displays. Let's crash? */
|
|
129 stderr_out
|
|
130 ("\n%s: Fatal X Condition. Asked about display we don't own: \"%s\"\n",
|
|
131 (STRINGP (Vinvocation_name) ?
|
|
132 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"),
|
|
133 DisplayString (dpy) ? DisplayString (dpy) : "???");
|
|
134 abort();
|
|
135 }
|
|
136
|
|
137 return d;
|
0
|
138 }
|
|
139
|
|
140 struct device *
|
|
141 decode_x_device (Lisp_Object device)
|
|
142 {
|
|
143 XSETDEVICE (device, decode_device (device));
|
|
144 CHECK_X_DEVICE (device);
|
|
145 return XDEVICE (device);
|
|
146 }
|
|
147
|
|
148 Display *
|
|
149 get_x_display (Lisp_Object device)
|
|
150 {
|
|
151 return DEVICE_X_DISPLAY (decode_x_device (device));
|
|
152 }
|
|
153
|
|
154
|
|
155 /************************************************************************/
|
|
156 /* initializing an X connection */
|
|
157 /************************************************************************/
|
|
158
|
|
159 static void
|
|
160 allocate_x_device_struct (struct device *d)
|
|
161 {
|
185
|
162 d->device_data = xnew_and_zero (struct x_device);
|
0
|
163 }
|
|
164
|
|
165 static void
|
|
166 Xatoms_of_device_x (struct device *d)
|
|
167 {
|
149
|
168 Display *D = DEVICE_X_DISPLAY (d);
|
0
|
169
|
149
|
170 DEVICE_XATOM_WM_PROTOCOLS (d) = XInternAtom (D, "WM_PROTOCOLS", False);
|
|
171 DEVICE_XATOM_WM_DELETE_WINDOW(d) = XInternAtom (D, "WM_DELETE_WINDOW",False);
|
|
172 DEVICE_XATOM_WM_SAVE_YOURSELF(d) = XInternAtom (D, "WM_SAVE_YOURSELF",False);
|
|
173 DEVICE_XATOM_WM_TAKE_FOCUS (d) = XInternAtom (D, "WM_TAKE_FOCUS", False);
|
|
174 DEVICE_XATOM_WM_STATE (d) = XInternAtom (D, "WM_STATE", False);
|
0
|
175 }
|
|
176
|
|
177 static void
|
|
178 sanity_check_geometry_resource (Display *dpy)
|
|
179 {
|
|
180 char *app_name, *app_class, *s;
|
|
181 char buf1 [255], buf2 [255];
|
|
182 char *type;
|
|
183 XrmValue value;
|
|
184 XtGetApplicationNameAndClass (dpy, &app_name, &app_class);
|
|
185 strcpy (buf1, app_name);
|
|
186 strcpy (buf2, app_class);
|
|
187 for (s = buf1; *s; s++) if (*s == '.') *s = '_';
|
|
188 strcat (buf1, "._no_._such_._resource_.geometry");
|
|
189 strcat (buf2, "._no_._such_._resource_.Geometry");
|
|
190 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
|
|
191 {
|
|
192 warn_when_safe (Qgeometry, Qerror,
|
|
193 "\n"
|
|
194 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n"
|
|
195 "specified in the resource database. Specifying \"*geometry\" will make\n"
|
|
196 "XEmacs (and most other X programs) malfunction in obscure ways. (i.e.\n"
|
|
197 "the Xt or Xm libraries will probably crash, which is a very bad thing.)\n"
|
|
198 "You should always use \".geometry\" or \"*EmacsFrame.geometry\" instead.\n",
|
|
199 app_name, (char *) value.addr,
|
|
200 app_class, (char *) value.addr);
|
|
201 suppress_early_backtrace = 1;
|
|
202 error ("Invalid geometry resource");
|
|
203 }
|
|
204 }
|
|
205
|
|
206 static void
|
|
207 x_init_device_class (struct device *d)
|
|
208 {
|
219
|
209 if (DEVICE_X_DEPTH(d) > 2)
|
0
|
210 {
|
219
|
211 switch (DEVICE_X_VISUAL(d)->class)
|
0
|
212 {
|
|
213 case StaticGray:
|
|
214 case GrayScale:
|
|
215 DEVICE_CLASS (d) = Qgrayscale;
|
|
216 break;
|
|
217 default:
|
|
218 DEVICE_CLASS (d) = Qcolor;
|
|
219 }
|
|
220 }
|
|
221 else
|
|
222 DEVICE_CLASS (d) = Qmono;
|
|
223 }
|
|
224
|
|
225 static void
|
|
226 x_init_device (struct device *d, Lisp_Object props)
|
|
227 {
|
|
228 Lisp_Object display;
|
|
229 Lisp_Object device;
|
|
230 Display *dpy;
|
219
|
231 Widget app_shell;
|
0
|
232 int argc;
|
|
233 char **argv;
|
219
|
234 CONST char *app_class, *app_name;
|
0
|
235 CONST char *disp_name;
|
219
|
236 Arg xargs[6];
|
|
237 Cardinal numargs;
|
|
238 Visual *visual = NULL;
|
|
239 int depth = 8; /* shut up the compiler */
|
|
240 Colormap cmap;
|
|
241 int screen;
|
0
|
242
|
|
243 XSETDEVICE (device, d);
|
|
244 display = DEVICE_CONNECTION (d);
|
|
245
|
|
246 allocate_x_device_struct (d);
|
|
247
|
|
248 make_argc_argv (Vx_initial_argv_list, &argc, &argv);
|
|
249
|
|
250 if (STRINGP (Vx_emacs_application_class) &&
|
14
|
251 XSTRING_LENGTH (Vx_emacs_application_class) > 0)
|
0
|
252 GET_C_STRING_CTEXT_DATA_ALLOCA (Vx_emacs_application_class, app_class);
|
|
253 else
|
|
254 app_class = "Emacs";
|
|
255
|
|
256 GET_C_STRING_CTEXT_DATA_ALLOCA (display, disp_name);
|
|
257
|
|
258 slow_down_interrupts ();
|
|
259 /* The Xt code can't deal with signals here. Yuck. */
|
|
260 dpy = DEVICE_X_DISPLAY (d) =
|
|
261 XtOpenDisplay (Xt_app_con, disp_name, NULL, app_class, emacs_options,
|
|
262 XtNumber (emacs_options), &argc, argv);
|
|
263 speed_up_interrupts ();
|
|
264
|
|
265 if (dpy == 0)
|
|
266 {
|
|
267 suppress_early_backtrace = 1;
|
|
268 signal_simple_error ("X server not responding\n", display);
|
|
269 }
|
|
270
|
219
|
271 screen = DefaultScreen(dpy);
|
74
|
272 if (NILP (Vdefault_x_device))
|
|
273 Vdefault_x_device = device;
|
|
274
|
70
|
275 #ifdef MULE
|
209
|
276 #if defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET)
|
70
|
277 {
|
|
278 /* Read in locale-specific resources from
|
|
279 data-directory/app-defaults/$LANG/emacs-application-class.
|
|
280 This is in addition to the standard app-defaults files, and
|
|
281 does not override resources defined elsewhere */
|
|
282 CONST char *data_dir;
|
|
283 char path[MAXPATHLEN];
|
|
284 XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */
|
|
285 CONST char *locale = XrmLocaleOfDatabase (db);
|
183
|
286
|
70
|
287 if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0)
|
169
|
288 {
|
|
289 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir);
|
|
290 sprintf (path, "%sapp-defaults/%s/%s", data_dir, locale, app_class);
|
|
291 if (!access (path, R_OK))
|
|
292 XrmCombineFileDatabase (path, &db, False);
|
|
293 }
|
70
|
294 }
|
209
|
295 #endif /* LWLIB_MENUBARS_MOTIF or HAVE_XIM USE_XFONTSET */
|
149
|
296 #endif /* MULE */
|
6
|
297
|
0
|
298 if (NILP (DEVICE_NAME (d)))
|
|
299 DEVICE_NAME (d) = display;
|
|
300
|
|
301 /* We're going to modify the string in-place, so be a nice XEmacs */
|
|
302 DEVICE_NAME (d) = Fcopy_sequence (DEVICE_NAME (d));
|
|
303 /* colons and periods can't appear in individual elements of resource
|
|
304 strings */
|
219
|
305
|
|
306 XtGetApplicationNameAndClass (dpy, &app_name, &app_class);
|
|
307 /* search for a matching visual if requested by the user, or setup the display default */
|
|
308 numargs = 0;
|
|
309 {
|
|
310 char buf1[100],buf2[100];
|
|
311 char *type;
|
|
312 XrmValue value;
|
|
313
|
|
314 sprintf (buf1, "%s.emacsVisual", app_name);
|
|
315 sprintf (buf2, "%s.EmacsVisual", app_class);
|
|
316 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
|
|
317 {
|
|
318 int cnt = 0, vis_class= PseudoColor;
|
|
319 XVisualInfo vinfo;
|
|
320 char *res, *str = (char*)value.addr;
|
|
321
|
|
322 if (strncmp(str, "StaticGray", 10) == 0) cnt = 10, vis_class = StaticGray;
|
|
323 else if (strncmp(str, "StaticColor", 11) == 0) cnt = 11, vis_class = StaticColor;
|
|
324 else if (strncmp(str, "TrueColor", 9) == 0) cnt = 9, vis_class = TrueColor;
|
|
325 else if (strncmp(str, "GrayScale", 9) == 0) cnt = 9, vis_class = GrayScale;
|
|
326 else if (strncmp(str, "PseudoColor", 11) == 0) cnt = 11, vis_class = PseudoColor;
|
|
327 else if (strncmp(str, "DirectColor", 11) == 0) cnt = 11, vis_class = DirectColor;
|
|
328 if (cnt)
|
|
329 {
|
|
330 res = str + cnt;
|
|
331 depth = atoi(res);
|
|
332 if (depth == 0)
|
|
333 {
|
|
334 stderr_out("Invalid Depth specification in %s... ignoring...\n",(char*)str);
|
|
335 }
|
|
336 else
|
|
337 {
|
|
338 if (XMatchVisualInfo(dpy, screen, depth, vis_class, &vinfo))
|
|
339 {
|
|
340 visual = vinfo.visual;
|
|
341 }
|
|
342 else
|
|
343 {
|
|
344 stderr_out("Can't match the requested visual %s... using defaults\n",str);
|
|
345 }
|
|
346 }
|
|
347 }
|
|
348 else
|
|
349 {
|
|
350 stderr_out("Invalid Visual specification in %s... ignoring.\n",(char*)str);
|
|
351 }
|
|
352 }
|
|
353 if (visual == NULL)
|
|
354 {
|
|
355 visual = DefaultVisual(dpy, screen);
|
|
356 depth = DefaultDepth(dpy, screen);
|
|
357 }
|
|
358
|
|
359 /* If we've got the same visual as the default and its PseudoColor, check to see if the user
|
|
360 specified that we need a private colormap */
|
|
361 if (visual == DefaultVisual(dpy, screen))
|
|
362 {
|
|
363 sprintf (buf1, "%s.privateColormap", app_name);
|
|
364 sprintf (buf2, "%s.PrivateColormap", app_class);
|
|
365 if ((visual->class == PseudoColor) &&
|
|
366 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True))
|
|
367 {
|
|
368 cmap = XCopyColormapAndFree(dpy, DefaultColormap(dpy, screen));
|
|
369 }
|
|
370 else
|
|
371 {
|
|
372 cmap = DefaultColormap(dpy, screen);
|
|
373 }
|
|
374 }
|
|
375 else
|
|
376 {
|
|
377 /* We have to create a matching colormap anyway...
|
|
378 ### think about using standard colormaps (need the Xmu libs?) */
|
|
379 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
|
|
380 XInstallColormap(dpy, cmap);
|
|
381 }
|
|
382 }
|
|
383 XtSetArg(xargs[numargs],XtNvisual, visual); numargs++;
|
|
384 XtSetArg(xargs[numargs],XtNdepth, depth); numargs++;
|
|
385 XtSetArg(xargs[numargs],XtNcolormap, cmap); numargs++;
|
|
386 DEVICE_X_VISUAL (d) = visual;
|
|
387 DEVICE_X_COLORMAP (d) = cmap;
|
|
388 DEVICE_X_DEPTH (d) = depth;
|
|
389
|
14
|
390 validify_resource_string ((char *) XSTRING_DATA (DEVICE_NAME (d)));
|
219
|
391 app_shell = XtAppCreateShell (NULL, app_class,
|
|
392 applicationShellWidgetClass,
|
|
393 dpy, xargs, numargs);
|
0
|
394
|
219
|
395 DEVICE_XT_APP_SHELL (d) = app_shell;
|
70
|
396 #ifdef HAVE_XIM
|
|
397 XIM_init_device(d);
|
|
398 #endif /* HAVE_XIM */
|
0
|
399
|
219
|
400 /* Realize the app_shell so that it's window exists for GC creation purposes,
|
|
401 and set it to the size of the root window for child placement purposes */
|
|
402 {
|
|
403 Screen *scrn = ScreenOfDisplay(dpy, screen);
|
|
404 int screen_width, screen_height;
|
|
405 screen_width = WidthOfScreen(scrn);
|
|
406 screen_height = HeightOfScreen(scrn);
|
|
407 numargs = 0;
|
|
408 XtSetArg (xargs[numargs], XtNmappedWhenManaged, False); numargs++;
|
|
409 XtSetArg (xargs[numargs], XtNx, 0); numargs++;
|
|
410 XtSetArg (xargs[numargs], XtNy, 0); numargs++;
|
|
411 XtSetArg (xargs[numargs], XtNwidth, screen_width); numargs++;
|
|
412 XtSetArg (xargs[numargs], XtNheight, screen_height); numargs++;
|
|
413 XtSetValues (app_shell, xargs, numargs);
|
|
414 XtRealizeWidget (app_shell);
|
|
415 }
|
179
|
416 #ifdef HAVE_SESSION
|
177
|
417 {
|
219
|
418 int new_argc;
|
|
419 char **new_argv;
|
|
420 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv);
|
|
421 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), new_argv, new_argc);
|
|
422 free_argc_argv (new_argv);
|
177
|
423 }
|
179
|
424 #endif /* HAVE_SESSION */
|
177
|
425
|
219
|
426
|
197
|
427 #ifdef HAVE_OFFIX_DND
|
219
|
428 DndInitialize ( app_shell );
|
197
|
429 #endif
|
|
430
|
0
|
431 Vx_initial_argv_list = make_arg_list (argc, argv);
|
|
432 free_argc_argv (argv);
|
|
433
|
|
434 DEVICE_X_WM_COMMAND_FRAME (d) = Qnil;
|
|
435
|
|
436 sanity_check_geometry_resource (dpy);
|
|
437
|
|
438 /* In event-Xt.c */
|
|
439 x_init_modifier_mapping (d);
|
|
440
|
|
441 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (dpy);
|
|
442 init_baud_rate (d);
|
|
443 init_one_device (d);
|
|
444
|
219
|
445 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell));
|
0
|
446 DEVICE_X_GRAY_PIXMAP (d) = None;
|
|
447 Xatoms_of_device_x (d);
|
|
448 Xatoms_of_xselect (d);
|
|
449 Xatoms_of_objects_x (d);
|
|
450 x_init_device_class (d);
|
|
451
|
2
|
452 /* Run the elisp side of the X device initialization. */
|
0
|
453 call0 (Qinit_pre_x_win);
|
|
454 }
|
|
455
|
|
456 static void
|
|
457 x_finish_init_device (struct device *d, Lisp_Object props)
|
|
458 {
|
|
459 call0 (Qinit_post_x_win);
|
|
460 }
|
|
461
|
|
462 static void
|
|
463 x_mark_device (struct device *d, void (*markobj) (Lisp_Object))
|
|
464 {
|
187
|
465 ((markobj) (DEVICE_X_WM_COMMAND_FRAME (d)));
|
|
466 ((markobj) (DEVICE_X_DATA (d)->x_keysym_map_hashtable));
|
0
|
467 }
|
|
468
|
|
469
|
|
470 /************************************************************************/
|
|
471 /* closing an X connection */
|
|
472 /************************************************************************/
|
|
473
|
|
474 static void
|
|
475 free_x_device_struct (struct device *d)
|
|
476 {
|
|
477 xfree (d->device_data);
|
|
478 }
|
|
479
|
|
480 static void
|
|
481 x_delete_device (struct device *d)
|
|
482 {
|
|
483 Lisp_Object device;
|
|
484 Display *display;
|
|
485 #ifdef FREE_CHECKING
|
|
486 extern void (*__free_hook)();
|
|
487 int checking_free;
|
|
488 #endif
|
|
489
|
|
490 XSETDEVICE (device, d);
|
|
491 display = DEVICE_X_DISPLAY (d);
|
|
492
|
|
493 if (display)
|
|
494 {
|
|
495 #ifdef FREE_CHECKING
|
|
496 checking_free = (__free_hook != 0);
|
183
|
497
|
0
|
498 /* Disable strict free checking, to avoid bug in X library */
|
|
499 if (checking_free)
|
|
500 disable_strict_free_check ();
|
|
501 #endif
|
|
502
|
|
503 free_gc_cache (DEVICE_X_GC_CACHE (d));
|
|
504 if (DEVICE_X_DATA (d)->x_modifier_keymap)
|
|
505 XFreeModifiermap (DEVICE_X_DATA (d)->x_modifier_keymap);
|
|
506 if (DEVICE_X_DATA (d)->x_keysym_map)
|
|
507 XFree ((char *) DEVICE_X_DATA (d)->x_keysym_map);
|
|
508
|
|
509 XtCloseDisplay (display);
|
|
510 DEVICE_X_DISPLAY (d) = 0;
|
|
511 #ifdef FREE_CHECKING
|
|
512 if (checking_free)
|
|
513 enable_strict_free_check ();
|
|
514 #endif
|
|
515 }
|
183
|
516
|
0
|
517 if (EQ (device, Vdefault_x_device))
|
|
518 {
|
|
519 Lisp_Object devcons, concons;
|
|
520 /* #### handle deleting last X device */
|
|
521 Vdefault_x_device = Qnil;
|
|
522 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
523 {
|
157
|
524 if (DEVICE_X_P (XDEVICE (XCAR (devcons))) &&
|
|
525 !EQ (device, XCAR (devcons)))
|
0
|
526 {
|
|
527 Vdefault_x_device = XCAR (devcons);
|
|
528 goto double_break;
|
|
529 }
|
|
530 }
|
|
531 }
|
|
532 double_break:
|
|
533 free_x_device_struct (d);
|
|
534 }
|
|
535
|
|
536
|
|
537 /************************************************************************/
|
|
538 /* handle X errors */
|
|
539 /************************************************************************/
|
|
540
|
|
541 static CONST char *events[] =
|
|
542 {
|
|
543 "0: ERROR!",
|
|
544 "1: REPLY",
|
|
545 "KeyPress",
|
|
546 "KeyRelease",
|
|
547 "ButtonPress",
|
|
548 "ButtonRelease",
|
|
549 "MotionNotify",
|
|
550 "EnterNotify",
|
|
551 "LeaveNotify",
|
|
552 "FocusIn",
|
|
553 "FocusOut",
|
|
554 "KeymapNotify",
|
|
555 "Expose",
|
|
556 "GraphicsExpose",
|
|
557 "NoExpose",
|
|
558 "VisibilityNotify",
|
|
559 "CreateNotify",
|
|
560 "DestroyNotify",
|
|
561 "UnmapNotify",
|
|
562 "MapNotify",
|
|
563 "MapRequest",
|
|
564 "ReparentNotify",
|
|
565 "ConfigureNotify",
|
|
566 "ConfigureRequest",
|
|
567 "GravityNotify",
|
|
568 "ResizeRequest",
|
|
569 "CirculateNotify",
|
|
570 "CirculateRequest",
|
|
571 "PropertyNotify",
|
|
572 "SelectionClear",
|
|
573 "SelectionRequest",
|
|
574 "SelectionNotify",
|
|
575 "ColormapNotify",
|
|
576 "ClientMessage",
|
|
577 "MappingNotify",
|
|
578 "LASTEvent"
|
|
579 };
|
|
580
|
|
581 CONST char *
|
|
582 x_event_name (int event_type)
|
|
583 {
|
|
584 if (event_type < 0) return 0;
|
|
585 if (event_type >= (sizeof (events) / sizeof (char *))) return 0;
|
|
586 return events [event_type];
|
|
587 }
|
|
588
|
|
589 /* Handling errors.
|
|
590
|
|
591 If an X error occurs which we are not expecting, we have no alternative
|
|
592 but to print it to stderr. It would be nice to stuff it into a pop-up
|
|
593 buffer, or to print it in the minibuffer, but that's not possible, because
|
|
594 one is not allowed to do any I/O on the display connection from an error
|
|
595 handler. The guts of Xlib expect these functions to either return or exit.
|
|
596
|
|
597 However, there are occasions when we might expect an error to reasonably
|
|
598 occur. The interface to this is as follows:
|
|
599
|
|
600 Before calling some X routine which may error, call
|
|
601 expect_x_error (dpy);
|
|
602
|
|
603 Just after calling the X routine, call either:
|
|
604
|
|
605 x_error_occurred_p (dpy);
|
|
606
|
|
607 to ask whether an error happened (and was ignored), or:
|
|
608
|
|
609 signal_if_x_error (dpy, resumable_p);
|
|
610
|
|
611 which will call Fsignal() with args appropriate to the X error, if there
|
|
612 was one. (Resumable_p is whether the debugger should be allowed to
|
|
613 continue from the call to signal.)
|
|
614
|
|
615 You must call one of these two routines immediately after calling the X
|
|
616 routine; think of them as bookends like BLOCK_INPUT and UNBLOCK_INPUT.
|
|
617 */
|
|
618
|
|
619 static int error_expected;
|
|
620 static int error_occurred;
|
|
621 static XErrorEvent last_error;
|
|
622
|
|
623 /* OVERKILL! */
|
|
624
|
|
625 #ifdef EXTERNAL_WIDGET
|
|
626 static Lisp_Object
|
|
627 x_error_handler_do_enqueue (Lisp_Object frame)
|
|
628 {
|
|
629 enqueue_magic_eval_event (io_error_delete_frame, frame);
|
|
630 return Qt;
|
|
631 }
|
|
632
|
|
633 static Lisp_Object
|
|
634 x_error_handler_error (Lisp_Object data, Lisp_Object dummy)
|
|
635 {
|
|
636 return Qnil;
|
|
637 }
|
|
638 #endif /* EXTERNAL_WIDGET */
|
|
639
|
|
640 int
|
|
641 x_error_handler (Display *disp, XErrorEvent *event)
|
|
642 {
|
|
643 if (error_expected)
|
|
644 {
|
|
645 error_expected = 0;
|
|
646 error_occurred = 1;
|
|
647 last_error = *event;
|
|
648 }
|
|
649 else
|
|
650 {
|
|
651 #ifdef EXTERNAL_WIDGET
|
|
652 struct frame *f;
|
|
653 struct device *d = get_device_from_display (disp);
|
|
654
|
|
655 if ((event->error_code == BadWindow ||
|
|
656 event->error_code == BadDrawable)
|
|
657 && ((f = x_any_window_to_frame (d, event->resourceid)) != 0))
|
|
658 {
|
|
659 Lisp_Object frame;
|
|
660
|
|
661 /* one of the windows comprising one of our frames has died.
|
|
662 This occurs particularly with ExternalShell frames when the
|
|
663 client that owns the ExternalShell's window dies.
|
|
664
|
|
665 We cannot do any I/O on the display connection so we need
|
|
666 to enqueue an eval event so that the deletion happens
|
|
667 later.
|
|
668
|
|
669 Furthermore, we need to trap any errors (out-of-memory) that
|
|
670 may occur when Fenqueue_eval_event is called.
|
|
671 */
|
|
672
|
|
673 if (f->being_deleted)
|
|
674 return 0;
|
|
675 XSETFRAME (frame, f);
|
|
676 if (!NILP (condition_case_1 (Qerror, x_error_handler_do_enqueue,
|
|
677 frame, x_error_handler_error, Qnil)))
|
|
678 {
|
|
679 f->being_deleted = 1;
|
|
680 f->visible = 0;
|
|
681 }
|
|
682 return 0;
|
|
683 }
|
|
684 #endif /* EXTERNAL_WIDGET */
|
|
685
|
|
686 stderr_out ("\n%s: ",
|
|
687 (STRINGP (Vinvocation_name)
|
14
|
688 ? (char *) XSTRING_DATA (Vinvocation_name)
|
0
|
689 : "xemacs"));
|
|
690 XmuPrintDefaultErrorMessage (disp, event, stderr);
|
|
691 }
|
|
692 return 0;
|
|
693 }
|
|
694
|
|
695 void
|
|
696 expect_x_error (Display *dpy)
|
|
697 {
|
|
698 assert (!error_expected);
|
|
699 XSync (dpy, 0); /* handle pending errors before setting flag */
|
|
700 error_expected = 1;
|
|
701 error_occurred = 0;
|
|
702 }
|
|
703
|
|
704 int
|
|
705 x_error_occurred_p (Display *dpy)
|
|
706 {
|
|
707 int val;
|
|
708 XSync (dpy, 0); /* handle pending errors before setting flag */
|
|
709 val = error_occurred;
|
|
710 error_expected = 0;
|
|
711 error_occurred = 0;
|
|
712 return val;
|
|
713 }
|
|
714
|
|
715 int
|
|
716 signal_if_x_error (Display *dpy, int resumable_p)
|
|
717 {
|
|
718 char buf[1024];
|
|
719 Lisp_Object data;
|
|
720 if (! x_error_occurred_p (dpy))
|
|
721 return 0;
|
|
722 data = Qnil;
|
|
723 sprintf (buf, "0x%X", (unsigned int) last_error.resourceid);
|
|
724 data = Fcons (build_string (buf), data);
|
|
725 {
|
|
726 char num [32];
|
|
727 sprintf (num, "%d", last_error.request_code);
|
|
728 XGetErrorDatabaseText (last_error.display, "XRequest", num, "",
|
|
729 buf, sizeof (buf));
|
|
730 if (! *buf)
|
|
731 sprintf (buf, "Request-%d", last_error.request_code);
|
|
732 data = Fcons (build_string (buf), data);
|
|
733 }
|
|
734 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf));
|
|
735 data = Fcons (build_string (buf), data);
|
|
736 again:
|
|
737 Fsignal (Qx_error, data);
|
|
738 if (! resumable_p) goto again;
|
|
739 return 1;
|
|
740 }
|
|
741
|
|
742 int
|
|
743 x_IO_error_handler (Display *disp)
|
|
744 {
|
|
745 /* This function can GC */
|
|
746 Lisp_Object dev;
|
114
|
747 struct device *d = get_device_from_display_1 (disp);
|
|
748
|
|
749 if (d)
|
|
750 XSETDEVICE (dev, d);
|
|
751 else
|
|
752 dev = Qnil;
|
0
|
753
|
|
754 if (NILP (find_nonminibuffer_frame_not_on_device (dev)))
|
|
755 {
|
|
756 /* We're going down. */
|
|
757 stderr_out
|
|
758 ("\n%s: Fatal I/O Error %d (%s) on display connection \"%s\"\n",
|
|
759 (STRINGP (Vinvocation_name) ?
|
14
|
760 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"),
|
0
|
761 errno, strerror (errno), DisplayString (disp));
|
|
762 stderr_out
|
|
763 (" after %lu requests (%lu known processed) with %d events remaining.\n",
|
|
764 NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
|
|
765 QLength (disp));
|
|
766 /* assert (!_Xdebug); */
|
|
767 }
|
|
768 else
|
|
769 {
|
|
770 warn_when_safe
|
|
771 (Qx, Qcritical,
|
|
772 "I/O Error %d (%s) on display connection \"%s\"\n"
|
|
773 " after %lu requests (%lu known processed) with "
|
|
774 "%d events remaining.\n",
|
|
775 errno, strerror (errno), DisplayString (disp),
|
|
776 NextRequest (disp) - 1, LastKnownRequestProcessed (disp),
|
|
777 QLength (disp));
|
|
778 }
|
|
779
|
114
|
780 if (d)
|
|
781 enqueue_magic_eval_event (io_error_delete_device, dev);
|
0
|
782
|
167
|
783 /* CvE, July 16, 1996, XEmacs 19.14 */
|
|
784 /* Test for broken pipe error, which indicates X-server has gone down */
|
|
785 if (errno == EPIPE && x_seppuku_on_epipe)
|
|
786 {
|
|
787 /* Most probably X-server has gone down: Avoid infinite loop by just */
|
|
788 /* exiting */
|
|
789 /* slb: This sounds really, really dangerous to do by default, so */
|
|
790 /* I'm adding a guard to avoid doing this as default behavior */
|
|
791 stderr_out( "\n\nXEmacs exiting on broken pipe (errno %d, %s)\n",
|
|
792 errno, strerror(errno));
|
|
793 exit(errno);
|
|
794 }
|
|
795
|
0
|
796 return 0;
|
|
797 }
|
|
798
|
20
|
799 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /*
|
0
|
800 With a true arg, make the connection to the X server synchronous.
|
|
801 With false, make it asynchronous. Synchronous connections are much slower,
|
|
802 but are useful for debugging. (If you get X errors, make the connection
|
|
803 synchronous, and use a debugger to set a breakpoint on `x_error_handler'.
|
|
804 Your backtrace of the C stack will now be useful. In asynchronous mode,
|
|
805 the stack above `x_error_handler' isn't helpful because of buffering.)
|
|
806 If DEVICE is not specified, the selected device is assumed.
|
|
807
|
|
808 Calling this function is the same as calling the C function `XSynchronize',
|
|
809 or starting the program with the `-sync' command line argument.
|
20
|
810 */
|
|
811 (arg, device))
|
0
|
812 {
|
|
813 struct device *d = decode_x_device (device);
|
|
814
|
|
815 XSynchronize (DEVICE_X_DISPLAY (d), !NILP (arg));
|
|
816
|
|
817 if (!NILP (arg))
|
|
818 message ("X connection is synchronous");
|
|
819 else
|
|
820 message ("X connection is asynchronous");
|
|
821
|
|
822 return arg;
|
|
823 }
|
|
824
|
|
825
|
|
826 /************************************************************************/
|
|
827 /* X resources */
|
|
828 /************************************************************************/
|
|
829
|
|
830 #if 0 /* bah humbug. The whole "widget == resource" stuff is such
|
|
831 a crock of shit that I'm just going to ignore it all. */
|
|
832
|
|
833 /* If widget is NULL, we are retrieving device or global face data. */
|
|
834
|
|
835 static void
|
|
836 construct_name_list (Display *display, Widget widget, char *fake_name,
|
|
837 char *fake_class, char *name, char *class)
|
|
838 {
|
|
839 char *stack [100][2];
|
|
840 Widget this;
|
|
841 int count = 0;
|
|
842 char *name_tail, *class_tail;
|
|
843
|
|
844 if (widget)
|
|
845 {
|
|
846 for (this = widget; this; this = XtParent (this))
|
|
847 {
|
|
848 stack [count][0] = this->core.name;
|
|
849 stack [count][1] = XtClass (this)->core_class.class_name;
|
|
850 count++;
|
|
851 }
|
|
852 count--;
|
|
853 }
|
|
854 else if (fake_name && fake_class)
|
|
855 {
|
|
856 stack [count][0] = fake_name;
|
|
857 stack [count][1] = fake_class;
|
|
858 count++;
|
|
859 }
|
|
860
|
|
861 /* The root widget is an application shell; resource lookups use the
|
|
862 specified application name and application class in preference to
|
|
863 the name/class of that widget (which is argv[0] / "ApplicationShell").
|
|
864 Generally the app name and class will be argv[0] / "Emacs" but
|
|
865 the former can be set via the -name command-line option, and the
|
|
866 latter can be set by changing `x-emacs-application-class' in
|
|
867 lisp/term/x-win.el.
|
|
868 */
|
|
869 XtGetApplicationNameAndClass (display,
|
|
870 &stack [count][0],
|
|
871 &stack [count][1]);
|
|
872
|
|
873 name [0] = 0;
|
|
874 class [0] = 0;
|
|
875
|
|
876 name_tail = name;
|
|
877 class_tail = class;
|
|
878 for (; count >= 0; count--)
|
|
879 {
|
|
880 strcat (name_tail, stack [count][0]);
|
|
881 for (; *name_tail; name_tail++)
|
|
882 if (*name_tail == '.') *name_tail = '_';
|
|
883 strcat (name_tail, ".");
|
|
884 name_tail++;
|
|
885
|
|
886 strcat (class_tail, stack [count][1]);
|
|
887 for (; *class_tail; class_tail++)
|
|
888 if (*class_tail == '.') *class_tail = '_';
|
|
889 strcat (class_tail, ".");
|
|
890 class_tail++;
|
|
891 }
|
|
892 }
|
|
893
|
183
|
894 #endif /* 0 */
|
0
|
895
|
|
896 /* Only the characters [-_A-Za-z0-9] are allowed in the individual
|
|
897 sections of a resource. Convert invalid characters to -. */
|
|
898
|
|
899 static void
|
|
900 validify_resource_string (char *str)
|
|
901 {
|
|
902 while (*str)
|
|
903 {
|
|
904 if (!strchr ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
905 "abcdefghijklmnopqrstuvwxyz"
|
|
906 "0123456789-_", *str))
|
|
907 *str = '-';
|
|
908 str++;
|
|
909 }
|
|
910 }
|
|
911
|
|
912 /* Given a locale and device specification from x-get-resource or
|
|
913 x-get-resource-prefix, return the resource prefix and display to
|
|
914 fetch the resource on. */
|
|
915
|
|
916 static void
|
|
917 x_get_resource_prefix (Lisp_Object locale, Lisp_Object device,
|
|
918 Display **display_out, char *name_out,
|
|
919 char *class_out)
|
|
920 {
|
|
921 char *appname, *appclass;
|
|
922
|
|
923 if (NILP (locale))
|
|
924 locale = Qglobal;
|
|
925 if (NILP (Fvalid_specifier_locale_p (locale)))
|
|
926 signal_simple_error ("Invalid locale", locale);
|
|
927 if (WINDOWP (locale))
|
|
928 /* #### I can't come up with any coherent way of naming windows.
|
|
929 By relative position? That seems tricky because windows
|
|
930 can change position, be split, etc. By order of creation?
|
|
931 That seems less than useful. */
|
|
932 signal_simple_error ("Windows currently can't be resourced", locale);
|
|
933
|
|
934 if (!NILP (device) && !DEVICEP (device))
|
|
935 CHECK_DEVICE (device);
|
|
936 if (DEVICEP (device) && !DEVICE_X_P (XDEVICE (device)))
|
|
937 device = Qnil;
|
|
938 if (NILP (device))
|
|
939 {
|
|
940 device = DFW_DEVICE (locale);
|
|
941 if (DEVICEP (device) && !DEVICE_X_P (XDEVICE (device)))
|
|
942 device = Qnil;
|
|
943 if (NILP (device))
|
|
944 device = Vdefault_x_device;
|
|
945 if (NILP (device))
|
|
946 {
|
|
947 *display_out = 0;
|
|
948 return;
|
|
949 }
|
|
950 }
|
|
951
|
|
952 *display_out = DEVICE_X_DISPLAY (XDEVICE (device));
|
|
953
|
|
954 XtGetApplicationNameAndClass (*display_out, &appname, &appclass);
|
|
955 strcpy (name_out, appname);
|
|
956 strcpy (class_out, appclass);
|
|
957 validify_resource_string (name_out);
|
|
958 validify_resource_string (class_out);
|
|
959
|
|
960 if (EQ (locale, Qglobal))
|
|
961 return;
|
|
962 if (BUFFERP (locale))
|
|
963 {
|
|
964 strcat (name_out, ".buffer.");
|
|
965 /* we know buffer is live; otherwise we got an error above. */
|
14
|
966 strcat (name_out, (CONST char *) XSTRING_DATA (Fbuffer_name (locale)));
|
0
|
967 strcat (class_out, ".EmacsLocaleType.EmacsBuffer");
|
|
968 }
|
|
969 else if (FRAMEP (locale))
|
|
970 {
|
|
971 strcat (name_out, ".frame.");
|
|
972 /* we know frame is live; otherwise we got an error above. */
|
14
|
973 strcat (name_out, (CONST char *) XSTRING_DATA (Fframe_name (locale)));
|
0
|
974 strcat (class_out, ".EmacsLocaleType.EmacsFrame");
|
|
975 }
|
|
976 else
|
|
977 {
|
|
978 assert (DEVICEP (locale));
|
|
979 strcat (name_out, ".device.");
|
|
980 /* we know device is live; otherwise we got an error above. */
|
14
|
981 strcat (name_out, (CONST char *) XSTRING_DATA (Fdevice_name (locale)));
|
0
|
982 strcat (class_out, ".EmacsLocaleType.EmacsDevice");
|
|
983 }
|
|
984 return;
|
|
985 }
|
|
986
|
20
|
987 DEFUN ("x-get-resource", Fx_get_resource, 3, 6, 0, /*
|
0
|
988 Retrieve an X resource from the resource manager.
|
|
989
|
183
|
990 The first arg is the name of the resource to retrieve, such as "font".
|
|
991 The second arg is the class of the resource to retrieve, like "Font".
|
0
|
992 The third arg should be one of the symbols 'string, 'integer, 'natnum, or
|
|
993 'boolean, specifying the type of object that the database is searched for.
|
|
994 The fourth arg is the locale to search for the resources on, and can
|
|
995 currently be a a buffer, a frame, a device, or 'global. If omitted, it
|
|
996 defaults to 'global.
|
|
997 The fifth arg is the device to search for the resources on. (The resource
|
|
998 database for a particular device is constructed by combining non-device-
|
183
|
999 specific resources such as any command-line resources specified and any
|
0
|
1000 app-defaults files found [or the fallback resources supplied by XEmacs,
|
|
1001 if no app-defaults file is found] with device-specific resources such as
|
|
1002 those supplied using xrdb.) If omitted, it defaults to the device of
|
|
1003 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device),
|
|
1004 and otherwise defaults to the value of `default-x-device'.
|
|
1005 The sixth arg NOERROR, if non-nil, means do not signal an error if a
|
|
1006 bogus resource specification was retrieved (e.g. if a non-integer was
|
|
1007 given when an integer was requested). In this case, a warning is issued
|
|
1008 instead.
|
|
1009
|
|
1010 The resource names passed to this function are looked up relative to the
|
|
1011 locale.
|
|
1012
|
|
1013 If you want to search for a subresource, you just need to specify the
|
|
1014 resource levels in NAME and CLASS. For example, NAME could be
|
183
|
1015 "modeline.attributeFont", and CLASS "Face.AttributeFont".
|
0
|
1016
|
|
1017 Specifically,
|
|
1018
|
|
1019 1) If LOCALE is a buffer, a call
|
|
1020
|
183
|
1021 (x-get-resource "foreground" "Foreground" 'string SOME-BUFFER)
|
0
|
1022
|
|
1023 is an interface to a C call something like
|
|
1024
|
183
|
1025 XrmGetResource (db, "xemacs.buffer.BUFFER-NAME.foreground",
|
|
1026 "Emacs.EmacsLocaleType.EmacsBuffer.Foreground",
|
|
1027 "String");
|
0
|
1028
|
|
1029 2) If LOCALE is a frame, a call
|
|
1030
|
183
|
1031 (x-get-resource "foreground" "Foreground" 'string SOME-FRAME)
|
0
|
1032
|
|
1033 is an interface to a C call something like
|
|
1034
|
183
|
1035 XrmGetResource (db, "xemacs.frame.FRAME-NAME.foreground",
|
|
1036 "Emacs.EmacsLocaleType.EmacsFrame.Foreground",
|
|
1037 "String");
|
0
|
1038
|
|
1039 3) If LOCALE is a device, a call
|
|
1040
|
183
|
1041 (x-get-resource "foreground" "Foreground" 'string SOME-DEVICE)
|
0
|
1042
|
|
1043 is an interface to a C call something like
|
|
1044
|
183
|
1045 XrmGetResource (db, "xemacs.device.DEVICE-NAME.foreground",
|
|
1046 "Emacs.EmacsLocaleType.EmacsDevice.Foreground",
|
|
1047 "String");
|
0
|
1048
|
|
1049 4) If LOCALE is 'global, a call
|
|
1050
|
183
|
1051 (x-get-resource "foreground" "Foreground" 'string 'global)
|
0
|
1052
|
|
1053 is an interface to a C call something like
|
|
1054
|
183
|
1055 XrmGetResource (db, "xemacs.foreground",
|
|
1056 "Emacs.Foreground",
|
|
1057 "String");
|
0
|
1058
|
|
1059 Note that for 'global, no prefix is added other than that of the
|
|
1060 application itself; thus, you can use this locale to retrieve
|
|
1061 arbitrary application resources, if you really want to.
|
|
1062
|
|
1063 The returned value of this function is nil if the queried resource is not
|
|
1064 found. If the third arg is `string', a string is returned, and if it is
|
|
1065 `integer', an integer is returned. If the third arg is `boolean', then the
|
|
1066 returned value is the list (t) for true, (nil) for false, and is nil to
|
|
1067 mean ``unspecified.''
|
20
|
1068 */
|
|
1069 (name, class, type, locale, device, no_error))
|
0
|
1070 {
|
|
1071 /* #### fixed limit, could be overflowed */
|
|
1072 char name_string[2048], class_string[2048];
|
|
1073 char *raw_result;
|
|
1074 XrmDatabase db;
|
|
1075 Display *display;
|
|
1076 Error_behavior errb = decode_error_behavior_flag (no_error);
|
|
1077
|
|
1078 CHECK_STRING (name);
|
|
1079 CHECK_STRING (class);
|
|
1080 CHECK_SYMBOL (type);
|
|
1081
|
183
|
1082 if (!EQ (type, Qstring) &&
|
|
1083 !EQ (type, Qboolean) &&
|
|
1084 !EQ (type, Qinteger) &&
|
|
1085 !EQ (type, Qnatnum))
|
0
|
1086 return maybe_signal_continuable_error
|
|
1087 (Qwrong_type_argument,
|
|
1088 list2 (build_translated_string
|
|
1089 ("should be string, integer, natnum or boolean"),
|
|
1090 type),
|
|
1091 Qresource, errb);
|
|
1092
|
|
1093 x_get_resource_prefix (locale, device, &display, name_string,
|
|
1094 class_string);
|
|
1095 if (!display)
|
|
1096 return Qnil;
|
|
1097
|
|
1098 db = XtDatabase (display);
|
|
1099
|
|
1100 strcat (name_string, ".");
|
14
|
1101 strcat (name_string, (CONST char *) XSTRING_DATA (name));
|
0
|
1102 strcat (class_string, ".");
|
14
|
1103 strcat (class_string, (CONST char *) XSTRING_DATA (class));
|
0
|
1104
|
|
1105 {
|
|
1106 XrmValue xrm_value;
|
|
1107 XrmName namelist[100];
|
|
1108 XrmClass classlist[100];
|
|
1109 XrmName *namerest = namelist;
|
|
1110 XrmClass *classrest = classlist;
|
|
1111 XrmRepresentation xrm_type;
|
|
1112 XrmRepresentation string_quark;
|
|
1113 int result;
|
|
1114 XrmStringToNameList (name_string, namelist);
|
|
1115 XrmStringToClassList (class_string, classlist);
|
|
1116 string_quark = XrmStringToQuark ("String");
|
|
1117
|
|
1118 /* ensure that they have the same length */
|
|
1119 while (namerest[0] && classrest[0])
|
|
1120 namerest++, classrest++;
|
|
1121 if (namerest[0] || classrest[0])
|
|
1122 signal_simple_error_2
|
|
1123 ("class list and name list must be the same length", name, class);
|
|
1124 result = XrmQGetResource (db, namelist, classlist, &xrm_type, &xrm_value);
|
|
1125
|
|
1126 if (result != True || xrm_type != string_quark)
|
|
1127 return Qnil;
|
|
1128 raw_result = (char *) xrm_value.addr;
|
|
1129 }
|
|
1130
|
|
1131 if (EQ (type, Qstring))
|
|
1132 return build_string (raw_result);
|
|
1133 else if (EQ (type, Qboolean))
|
|
1134 {
|
183
|
1135 if (!strcasecmp (raw_result, "off") ||
|
0
|
1136 !strcasecmp (raw_result, "false") ||
|
183
|
1137 !strcasecmp (raw_result, "no"))
|
0
|
1138 return Fcons (Qnil, Qnil);
|
183
|
1139 else if (!strcasecmp (raw_result, "on") ||
|
0
|
1140 !strcasecmp (raw_result, "true") ||
|
|
1141 !strcasecmp (raw_result, "yes"))
|
|
1142 return Fcons (Qt, Qnil);
|
|
1143 else
|
|
1144 return maybe_continuable_error (Qresource, errb,
|
|
1145 "can't convert %s: %s to a Boolean",
|
|
1146 name_string, raw_result);
|
|
1147 }
|
|
1148 else if (EQ (type, Qinteger) || EQ (type, Qnatnum))
|
|
1149 {
|
|
1150 int i;
|
|
1151 char c;
|
|
1152 if (1 != sscanf (raw_result, "%d%c", &i, &c))
|
|
1153 return maybe_continuable_error
|
|
1154 (Qresource, errb,
|
|
1155 "can't convert %s: %s to an integer",
|
|
1156 name_string, raw_result);
|
|
1157 else if (EQ (type, Qnatnum) && i < 0)
|
|
1158 return maybe_continuable_error
|
|
1159 (Qresource, errb,
|
|
1160 "invalid numerical value %d for resource %s",
|
|
1161 i, name_string);
|
|
1162 else
|
|
1163 return make_int (i);
|
|
1164 }
|
|
1165 else
|
|
1166 abort ();
|
|
1167
|
|
1168 /* Can't get here. */
|
|
1169 return Qnil; /* shut up compiler */
|
|
1170 }
|
|
1171
|
20
|
1172 DEFUN ("x-get-resource-prefix", Fx_get_resource_prefix, 1, 2, 0, /*
|
0
|
1173 Return the resource prefix for LOCALE on DEVICE.
|
|
1174 The resource prefix is the strings used to prefix resources if
|
|
1175 the LOCALE and DEVICE arguments were passed to `x-get-resource'.
|
|
1176 The returned value is a cons of a name prefix and a class prefix.
|
|
1177 For example, if LOCALE is a frame, the returned value might be
|
183
|
1178 \("xemacs.frame.FRAME-NAME" . "Emacs.EmacsLocaleType.EmacsFrame").
|
0
|
1179 If no valid X device for resourcing can be obtained, this function
|
|
1180 returns nil. (In such a case, `x-get-resource' would always return nil.)
|
20
|
1181 */
|
|
1182 (locale, device))
|
0
|
1183 {
|
|
1184 /* #### fixed limit, could be overflowed */
|
|
1185 char name[1024], class[1024];
|
|
1186 Display *display;
|
|
1187
|
|
1188 x_get_resource_prefix (locale, device, &display, name, class);
|
|
1189 if (!display)
|
|
1190 return Qnil;
|
|
1191 return Fcons (build_string (name), build_string (class));
|
|
1192 }
|
|
1193
|
20
|
1194 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /*
|
0
|
1195 Add a resource to the resource database for DEVICE.
|
|
1196 RESOURCE-LINE specifies the resource to add and should be a
|
|
1197 standard resource specification.
|
20
|
1198 */
|
|
1199 (resource_line, device))
|
0
|
1200 {
|
|
1201 struct device *d = decode_device (device);
|
|
1202 char *str, *colon_pos;
|
|
1203
|
|
1204 CHECK_STRING (resource_line);
|
14
|
1205 str = (char *) XSTRING_DATA (resource_line);
|
0
|
1206 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n'))
|
|
1207 invalid:
|
|
1208 signal_simple_error ("Invalid resource line", resource_line);
|
|
1209 if (strspn (str,
|
|
1210 /* Only the following chars are allowed before the colon */
|
|
1211 " \t.*?abcdefghijklmnopqrstuvwxyz"
|
|
1212 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-") != colon_pos - str)
|
|
1213 goto invalid;
|
|
1214
|
|
1215 if (DEVICE_X_P (d))
|
|
1216 {
|
|
1217 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d));
|
|
1218 XrmPutLineResource (&db, str);
|
|
1219 }
|
|
1220
|
|
1221 return Qnil;
|
|
1222 }
|
|
1223
|
|
1224
|
|
1225 /************************************************************************/
|
|
1226 /* display information functions */
|
|
1227 /************************************************************************/
|
|
1228
|
20
|
1229 DEFUN ("default-x-device", Fdefault_x_device, 0, 0, 0, /*
|
0
|
1230 Return the default X device for resourcing.
|
|
1231 This is the first-created X device that still exists.
|
20
|
1232 */
|
|
1233 ())
|
0
|
1234 {
|
|
1235 return Vdefault_x_device;
|
|
1236 }
|
|
1237
|
20
|
1238 DEFUN ("x-display-visual-class", Fx_display_visual_class, 0, 1, 0, /*
|
219
|
1239 Return the visual class of the X display `device' is using.
|
|
1240 This can be altered from the default at startup using the XResource "EmacsVisual".
|
0
|
1241 The returned value will be one of the symbols `static-gray', `gray-scale',
|
|
1242 `static-color', `pseudo-color', `true-color', or `direct-color'.
|
20
|
1243 */
|
|
1244 (device))
|
0
|
1245 {
|
219
|
1246 Visual *vis = DEVICE_X_VISUAL (decode_x_device (device));
|
|
1247 switch (vis->class)
|
0
|
1248 {
|
193
|
1249 case StaticGray: return intern ("static-gray");
|
|
1250 case GrayScale: return intern ("gray-scale");
|
|
1251 case StaticColor: return intern ("static-color");
|
|
1252 case PseudoColor: return intern ("pseudo-color");
|
|
1253 case TrueColor: return intern ("true-color");
|
|
1254 case DirectColor: return intern ("direct-color");
|
0
|
1255 default:
|
|
1256 error ("display has an unknown visual class");
|
|
1257 }
|
|
1258
|
|
1259 return Qnil; /* suppress compiler warning */
|
|
1260 }
|
|
1261
|
219
|
1262 DEFUN ("x-display-visual-depth", Fx_display_visual_depth, 0, 1, 0, /*
|
|
1263 Return the bitplane depth of the visual the X display `device' is using.
|
|
1264 */
|
|
1265 (device))
|
|
1266 {
|
|
1267 return make_int (DEVICE_X_DEPTH (decode_x_device (device)));
|
|
1268 }
|
|
1269
|
0
|
1270 static int
|
|
1271 x_device_pixel_width (struct device *d)
|
|
1272 {
|
|
1273 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1274
|
|
1275 return DisplayWidth (dpy, DefaultScreen (dpy));
|
|
1276 }
|
|
1277
|
|
1278 static int
|
|
1279 x_device_pixel_height (struct device *d)
|
|
1280 {
|
|
1281 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1282
|
|
1283 return DisplayHeight (dpy, DefaultScreen (dpy));
|
|
1284 }
|
|
1285
|
|
1286 static int
|
|
1287 x_device_mm_width (struct device *d)
|
|
1288 {
|
|
1289 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1290
|
|
1291 return DisplayWidthMM (dpy, DefaultScreen (dpy));
|
|
1292 }
|
|
1293
|
|
1294 static int
|
|
1295 x_device_mm_height (struct device *d)
|
|
1296 {
|
|
1297 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1298
|
|
1299 return DisplayHeightMM (dpy, DefaultScreen (dpy));
|
|
1300 }
|
|
1301
|
|
1302 static int
|
|
1303 x_device_bitplanes (struct device *d)
|
|
1304 {
|
|
1305 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1306
|
|
1307 return DisplayPlanes (dpy, DefaultScreen (dpy));
|
|
1308 }
|
|
1309
|
|
1310 static int
|
|
1311 x_device_color_cells (struct device *d)
|
|
1312 {
|
|
1313 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1314
|
|
1315 return DisplayCells (dpy, DefaultScreen (dpy));
|
|
1316 }
|
|
1317
|
20
|
1318 DEFUN ("x-server-vendor", Fx_server_vendor, 0, 1, 0, /*
|
0
|
1319 Return the vendor ID string of the X server `device' on.
|
20
|
1320 */
|
|
1321 (device))
|
0
|
1322 {
|
|
1323 Display *dpy = get_x_display (device);
|
|
1324 char *vendor = ServerVendor (dpy);
|
|
1325
|
183
|
1326 return build_string (vendor ? vendor : "");
|
0
|
1327 }
|
|
1328
|
20
|
1329 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /*
|
0
|
1330 Return the version numbers of the X server `device' is on.
|
|
1331 The returned value is a list of three integers: the major and minor
|
|
1332 version numbers of the X Protocol in use, and the vendor-specific release
|
|
1333 number. See also `x-server-vendor'.
|
20
|
1334 */
|
|
1335 (device))
|
0
|
1336 {
|
|
1337 Display *dpy = get_x_display (device);
|
|
1338
|
187
|
1339 return list3 (make_int (ProtocolVersion (dpy)),
|
0
|
1340 make_int (ProtocolRevision (dpy)),
|
187
|
1341 make_int (VendorRelease (dpy)));
|
0
|
1342 }
|
|
1343
|
20
|
1344 DEFUN ("x-valid-keysym-name-p", Fx_valid_keysym_name_p, 1, 1, 0, /*
|
0
|
1345 Return true if KEYSYM names a keysym that the X library knows about.
|
|
1346 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1347 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
20
|
1348 */
|
|
1349 (keysym))
|
0
|
1350 {
|
|
1351 CONST char *keysym_ext;
|
183
|
1352
|
0
|
1353 CHECK_STRING (keysym);
|
|
1354 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext);
|
183
|
1355
|
|
1356 return XStringToKeysym (keysym_ext) ? Qt : Qnil;
|
0
|
1357 }
|
|
1358
|
187
|
1359 DEFUN ("x-keysym-hashtable", Fx_keysym_hashtable, 0, 1, 0, /*
|
|
1360 Return a hashtable which contains a hash key for all keysyms which
|
|
1361 name keys on the keyboard. See `x-keysym-on-keyboard-p'.
|
|
1362 */
|
|
1363 (device))
|
|
1364 {
|
|
1365 struct device *d = decode_device (device);
|
|
1366 if (!DEVICE_X_P (d))
|
|
1367 signal_simple_error ("Not an X device", device);
|
|
1368
|
|
1369 return DEVICE_X_DATA (d)->x_keysym_map_hashtable;
|
|
1370 }
|
|
1371
|
|
1372 DEFUN ("x-keysym-on-keyboard-sans-modifiers-p",
|
|
1373 Fx_keysym_on_keyboard_sans_modifiers_p, 1, 2, 0, /*
|
0
|
1374 Return true if KEYSYM names a key on the keyboard of DEVICE.
|
|
1375 More precisely, return true if pressing a physical key
|
|
1376 on the keyboard of DEVICE without any modifier keys generates KEYSYM.
|
|
1377 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1378 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
20
|
1379 */
|
|
1380 (keysym, device))
|
0
|
1381 {
|
187
|
1382 struct device *d = decode_device (device);
|
|
1383 if (!DEVICE_X_P (d))
|
|
1384 signal_simple_error ("Not an X device", device);
|
|
1385 CHECK_STRING (keysym);
|
|
1386
|
|
1387 return (EQ (Qsans_modifiers,
|
|
1388 Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ?
|
|
1389 Qt : Qnil);
|
|
1390 }
|
|
1391
|
|
1392
|
|
1393 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /*
|
|
1394 Return true if KEYSYM names a key on the keyboard of DEVICE.
|
|
1395 More precisely, return true if some keystroke (possibly including modifiers)
|
|
1396 on the keyboard of DEVICE keys generates KEYSYM.
|
|
1397 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
|
|
1398 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
|
|
1399 */
|
|
1400 (keysym, device))
|
|
1401 {
|
|
1402 struct device *d = decode_device (device);
|
183
|
1403
|
0
|
1404 if (!DEVICE_X_P (d))
|
|
1405 signal_simple_error ("Not an X device", device);
|
|
1406 CHECK_STRING (keysym);
|
183
|
1407
|
187
|
1408 return (NILP (Fgethash (keysym, DEVICE_X_KEYSYM_MAP_HASHTABLE (d), Qnil)) ?
|
|
1409 Qnil : Qt);
|
0
|
1410 }
|
|
1411
|
|
1412
|
|
1413 /************************************************************************/
|
|
1414 /* grabs and ungrabs */
|
|
1415 /************************************************************************/
|
|
1416
|
20
|
1417 DEFUN ("x-grab-pointer", Fx_grab_pointer, 0, 3, 0, /*
|
0
|
1418 Grab the pointer and restrict it to its current window.
|
|
1419 If optional DEVICE argument is nil, the default device will be used.
|
|
1420 If optional CURSOR argument is non-nil, change the pointer shape to that
|
|
1421 until `x-ungrab-pointer' is called (it should be an object returned by the
|
|
1422 `make-cursor-glyph' function).
|
|
1423 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all
|
|
1424 keyboard events during the grab.
|
|
1425 Returns t if the grab is successful, nil otherwise.
|
20
|
1426 */
|
|
1427 (device, cursor, ignore_keyboard))
|
0
|
1428 {
|
|
1429 Window w;
|
|
1430 int pointer_mode, result;
|
|
1431 struct device *d = decode_x_device (device);
|
|
1432
|
|
1433 if (!NILP (cursor))
|
|
1434 {
|
|
1435 CHECK_POINTER_GLYPH (cursor);
|
|
1436 cursor = glyph_image_instance (cursor, device, ERROR_ME, 0);
|
|
1437 }
|
|
1438
|
|
1439 if (!NILP (ignore_keyboard))
|
|
1440 pointer_mode = GrabModeSync;
|
|
1441 else
|
|
1442 pointer_mode = GrabModeAsync;
|
|
1443
|
|
1444 w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
|
|
1445
|
|
1446 /* #### Possibly this needs to gcpro the cursor somehow, but it doesn't
|
|
1447 seem to cause a problem if XFreeCursor is called on a cursor in use
|
|
1448 in a grab; I suppose the X server counts the grab as a reference
|
|
1449 and doesn't free it until it exits? */
|
|
1450 result = XGrabPointer (DEVICE_X_DISPLAY (d), w,
|
|
1451 False,
|
193
|
1452 ButtonMotionMask |
|
|
1453 ButtonPressMask |
|
|
1454 ButtonReleaseMask |
|
|
1455 PointerMotionHintMask,
|
0
|
1456 GrabModeAsync, /* Keep pointer events flowing */
|
|
1457 pointer_mode, /* Stall keyboard events */
|
|
1458 w, /* Stay in this window */
|
|
1459 (NILP (cursor) ? 0
|
|
1460 : XIMAGE_INSTANCE_X_CURSOR (cursor)),
|
|
1461 CurrentTime);
|
183
|
1462 return (result == GrabSuccess) ? Qt : Qnil;
|
0
|
1463 }
|
|
1464
|
20
|
1465 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, 0, 1, 0, /*
|
0
|
1466 Release a pointer grab made with `x-grab-pointer'.
|
|
1467 If optional first arg DEVICE is nil the default device is used.
|
|
1468 If it is t the pointer will be released on all X devices.
|
20
|
1469 */
|
|
1470 (device))
|
0
|
1471 {
|
|
1472 if (!EQ (device, Qt))
|
|
1473 {
|
|
1474 Display *dpy = get_x_display (device);
|
|
1475 XUngrabPointer (dpy, CurrentTime);
|
|
1476 }
|
|
1477 else
|
|
1478 {
|
|
1479 Lisp_Object devcons, concons;
|
|
1480
|
|
1481 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
1482 {
|
|
1483 struct device *d = XDEVICE (XCAR (devcons));
|
|
1484
|
|
1485 if (DEVICE_X_P (d))
|
|
1486 XUngrabPointer (DEVICE_X_DISPLAY (d), CurrentTime);
|
|
1487 }
|
|
1488 }
|
|
1489
|
|
1490 return Qnil;
|
|
1491 }
|
|
1492
|
20
|
1493 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, 0, 1, 0, /*
|
0
|
1494 Grab the keyboard on the given device (defaulting to the selected one).
|
|
1495 So long as the keyboard is grabbed, all keyboard events will be delivered
|
|
1496 to emacs -- it is not possible for other X clients to eavesdrop on them.
|
|
1497 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect).
|
|
1498 Returns t if the grab was successful; nil otherwise.
|
20
|
1499 */
|
|
1500 (device))
|
0
|
1501 {
|
|
1502 struct device *d = decode_x_device (device);
|
|
1503 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
|
|
1504 Display *dpy = DEVICE_X_DISPLAY (d);
|
|
1505 Status status;
|
|
1506 XSync (dpy, False);
|
|
1507 status = XGrabKeyboard (dpy, w, True,
|
|
1508 /* I don't really understand sync-vs-async
|
|
1509 grabs, but this is what xterm does. */
|
|
1510 GrabModeAsync, GrabModeAsync,
|
|
1511 /* Use the timestamp of the last user action
|
|
1512 read by emacs proper; xterm uses CurrentTime
|
|
1513 but there's a comment that says "wrong"...
|
|
1514 (Despite the name this is the time of the
|
|
1515 last key or mouse event.) */
|
|
1516 DEVICE_X_MOUSE_TIMESTAMP (d));
|
|
1517 if (status == GrabSuccess)
|
|
1518 {
|
|
1519 /* The XUngrabKeyboard should generate a FocusIn back to this
|
|
1520 window but it doesn't unless we explicitly set focus to the
|
|
1521 window first (which should already have it. The net result
|
|
1522 is that without this call when x-ungrab-keyboard is called
|
|
1523 the selected frame ends up not having focus. */
|
|
1524 XSetInputFocus (dpy, w, RevertToParent, DEVICE_X_MOUSE_TIMESTAMP (d));
|
|
1525 return Qt;
|
|
1526 }
|
|
1527 else
|
|
1528 return Qnil;
|
|
1529 }
|
|
1530
|
20
|
1531 DEFUN ("x-ungrab-keyboard", Fx_ungrab_keyboard, 0, 1, 0, /*
|
0
|
1532 Release a keyboard grab made with `x-grab-keyboard'.
|
20
|
1533 */
|
|
1534 (device))
|
0
|
1535 {
|
|
1536 Display *dpy = get_x_display (device);
|
|
1537 XUngrabKeyboard (dpy, CurrentTime);
|
|
1538 return Qnil;
|
|
1539 }
|
|
1540
|
|
1541
|
|
1542 /************************************************************************/
|
|
1543 /* initialization */
|
|
1544 /************************************************************************/
|
|
1545
|
|
1546 void
|
|
1547 syms_of_device_x (void)
|
|
1548 {
|
20
|
1549 DEFSUBR (Fx_debug_mode);
|
|
1550 DEFSUBR (Fx_get_resource);
|
|
1551 DEFSUBR (Fx_get_resource_prefix);
|
|
1552 DEFSUBR (Fx_put_resource);
|
0
|
1553
|
20
|
1554 DEFSUBR (Fdefault_x_device);
|
|
1555 DEFSUBR (Fx_display_visual_class);
|
219
|
1556 DEFSUBR (Fx_display_visual_depth);
|
20
|
1557 DEFSUBR (Fx_server_vendor);
|
|
1558 DEFSUBR (Fx_server_version);
|
|
1559 DEFSUBR (Fx_valid_keysym_name_p);
|
187
|
1560 DEFSUBR (Fx_keysym_hashtable);
|
20
|
1561 DEFSUBR (Fx_keysym_on_keyboard_p);
|
187
|
1562 DEFSUBR (Fx_keysym_on_keyboard_sans_modifiers_p);
|
0
|
1563
|
20
|
1564 DEFSUBR (Fx_grab_pointer);
|
|
1565 DEFSUBR (Fx_ungrab_pointer);
|
|
1566 DEFSUBR (Fx_grab_keyboard);
|
|
1567 DEFSUBR (Fx_ungrab_keyboard);
|
0
|
1568
|
|
1569 defsymbol (&Qx_error, "x-error");
|
|
1570 defsymbol (&Qinit_pre_x_win, "init-pre-x-win");
|
|
1571 defsymbol (&Qinit_post_x_win, "init-post-x-win");
|
|
1572 }
|
|
1573
|
|
1574 void
|
|
1575 console_type_create_device_x (void)
|
|
1576 {
|
|
1577 CONSOLE_HAS_METHOD (x, init_device);
|
|
1578 CONSOLE_HAS_METHOD (x, finish_init_device);
|
|
1579 CONSOLE_HAS_METHOD (x, mark_device);
|
|
1580 CONSOLE_HAS_METHOD (x, delete_device);
|
|
1581 CONSOLE_HAS_METHOD (x, device_pixel_width);
|
|
1582 CONSOLE_HAS_METHOD (x, device_pixel_height);
|
|
1583 CONSOLE_HAS_METHOD (x, device_mm_width);
|
|
1584 CONSOLE_HAS_METHOD (x, device_mm_height);
|
|
1585 CONSOLE_HAS_METHOD (x, device_bitplanes);
|
|
1586 CONSOLE_HAS_METHOD (x, device_color_cells);
|
|
1587 }
|
|
1588
|
|
1589 void
|
|
1590 vars_of_device_x (void)
|
|
1591 {
|
|
1592 DEFVAR_LISP ("x-emacs-application-class", &Vx_emacs_application_class /*
|
|
1593 The X application class of the XEmacs process.
|
|
1594 This controls, among other things, the name of the `app-defaults' file
|
|
1595 that XEmacs will use. For changes to this variable to take effect, they
|
|
1596 must be made before the connection to the X server is initialized, that is,
|
|
1597 this variable may only be changed before emacs is dumped, or by setting it
|
|
1598 in the file lisp/term/x-win.el.
|
|
1599 */ );
|
|
1600 Vx_emacs_application_class = Fpurecopy (build_string ("Emacs"));
|
|
1601
|
|
1602 DEFVAR_LISP ("x-initial-argv-list", &Vx_initial_argv_list /*
|
|
1603 You don't want to know.
|
|
1604 This is used during startup to communicate the remaining arguments in
|
|
1605 `command-line-args-left' to the C code, which passes the args to
|
|
1606 the X initialization code, which removes some args, and then the
|
|
1607 args are placed back into `x-initial-arg-list' and thence into
|
|
1608 `command-line-args-left'. Perhaps `command-line-args-left' should
|
|
1609 just reside in C.
|
|
1610 */ );
|
|
1611 Vx_initial_argv_list = Qnil;
|
|
1612
|
167
|
1613 DEFVAR_BOOL ("x-seppuku-on-epipe", &x_seppuku_on_epipe /*
|
|
1614 When non-nil terminate XEmacs immediately on SIGPIPE from the X server.
|
|
1615 XEmacs doesn't terminate properly on some systems.
|
|
1616 When this variable is non-nil, XEmacs will commit immediate suicide
|
|
1617 when it gets a sigpipe from the X Server.
|
|
1618 */ );
|
|
1619 x_seppuku_on_epipe = 0;
|
|
1620
|
0
|
1621 Fprovide (Qx);
|
|
1622
|
|
1623 staticpro (&Vdefault_x_device);
|
|
1624 Vdefault_x_device = Qnil;
|
|
1625
|
|
1626 error_expected = 0;
|
|
1627 error_occurred = 0;
|
|
1628
|
|
1629 in_resource_setting = 0;
|
|
1630 in_specifier_change_function = 0;
|
|
1631 }
|