70
|
1 /* Generic device functions.
|
0
|
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
|
4 Copyright (C) 1995, 1996 Ben Wing
|
|
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
|
|
25 /* Original version by Chuck Thompson;
|
|
26 rewritten and expanded by Ben Wing. */
|
|
27
|
|
28 #include <config.h>
|
|
29 #include "lisp.h"
|
|
30
|
|
31 #include "buffer.h"
|
|
32 #include "console.h"
|
|
33 #include "device.h"
|
|
34 #include "elhash.h"
|
|
35 #include "events.h"
|
|
36 #include "faces.h"
|
|
37 #include "frame.h"
|
|
38 #include "keymap.h"
|
|
39 #include "redisplay.h"
|
|
40 #include "scrollbar.h"
|
|
41 #include "specifier.h"
|
|
42 #include "sysdep.h"
|
|
43 #include "window.h"
|
|
44
|
|
45 #include "syssignal.h"
|
|
46
|
|
47 /* Vdefault_device is the firstly-created non-stream device that's still
|
|
48 around. We don't really use it anywhere currently, but it might
|
|
49 be used for resourcing at some point. (Currently we use
|
|
50 Vdefault_x_device.) */
|
|
51 Lisp_Object Vdefault_device;
|
|
52
|
|
53 Lisp_Object Vcreate_device_hook, Vdelete_device_hook;
|
|
54
|
|
55 /* Device classes */
|
|
56 /* Qcolor defined in general.c */
|
|
57 Lisp_Object Qgrayscale, Qmono;
|
|
58
|
282
|
59 /* Device metrics symbols */
|
284
|
60 Lisp_Object
|
|
61 Qcolor_default, Qcolor_select, Qcolor_balloon, Qcolor_3d_face,
|
|
62 Qcolor_3d_light, Qcolor_3d_dark, Qcolor_menu, Qcolor_menu_highlight,
|
|
63 Qcolor_menu_button, Qcolor_menu_disabled, Qcolor_toolbar,
|
|
64 Qcolor_scrollbar, Qcolor_desktop, Qcolor_workspace, Qfont_default,
|
|
65 Qfont_menubar, Qfont_dialog, Qsize_cursor, Qsize_scrollbar,
|
|
66 Qsize_menu, Qsize_toolbar, Qsize_toolbar_button,
|
|
67 Qsize_toolbar_border, Qsize_icon, Qsize_icon_small, Qsize_device,
|
|
68 Qsize_workspace, Qsize_device_mm, Qdevice_dpi, Qnum_bit_planes,
|
|
69 Qnum_color_cells, Qmouse_buttons, Qswap_buttons, Qshow_sounds,
|
|
70 Qslow_device, Qsecurity;
|
282
|
71
|
0
|
72 Lisp_Object Qdevicep, Qdevice_live_p;
|
|
73 Lisp_Object Qdelete_device;
|
|
74 Lisp_Object Qcreate_device_hook;
|
|
75 Lisp_Object Qdelete_device_hook;
|
|
76
|
|
77 Lisp_Object Vdevice_class_list;
|
|
78
|
|
79
|
|
80 static Lisp_Object
|
|
81 mark_device (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
82 {
|
|
83 struct device *d = XDEVICE (obj);
|
|
84
|
|
85 ((markobj) (d->name));
|
|
86 ((markobj) (d->connection));
|
|
87 ((markobj) (d->canon_connection));
|
|
88 ((markobj) (d->console));
|
|
89 ((markobj) (d->_selected_frame));
|
|
90 ((markobj) (d->frame_with_focus_real));
|
|
91 ((markobj) (d->frame_with_focus_for_hooks));
|
|
92 ((markobj) (d->frame_that_ought_to_have_focus));
|
|
93 ((markobj) (d->device_class));
|
|
94 ((markobj) (d->user_defined_tags));
|
|
95 ((markobj) (d->pixel_to_glyph_cache.obj1));
|
|
96 ((markobj) (d->pixel_to_glyph_cache.obj2));
|
|
97
|
|
98 ((markobj) (d->color_instance_cache));
|
|
99 ((markobj) (d->font_instance_cache));
|
70
|
100 #ifdef MULE
|
|
101 ((markobj) (d->charset_font_cache));
|
|
102 #endif
|
0
|
103 ((markobj) (d->image_instance_cache));
|
|
104
|
|
105 if (d->devmeths)
|
|
106 {
|
|
107 ((markobj) (d->devmeths->symbol));
|
|
108 MAYBE_DEVMETH (d, mark_device, (d, markobj));
|
|
109 }
|
|
110
|
|
111 return (d->frame_list);
|
|
112 }
|
|
113
|
|
114 static void
|
|
115 print_device (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
116 {
|
|
117 struct device *d = XDEVICE (obj);
|
|
118 char buf[256];
|
|
119
|
|
120 if (print_readably)
|
|
121 error ("printing unreadable object #<device %s 0x%x>",
|
14
|
122 XSTRING_DATA (d->name), d->header.uid);
|
0
|
123
|
|
124 sprintf (buf, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" :
|
|
125 DEVICE_TYPE_NAME (d));
|
|
126 write_c_string (buf, printcharfun);
|
|
127 if (DEVICE_LIVE_P (d))
|
|
128 {
|
|
129 write_c_string (" on ", printcharfun);
|
|
130 print_internal (DEVICE_CONNECTION (d), printcharfun, 1);
|
|
131 }
|
|
132 sprintf (buf, " 0x%x>", d->header.uid);
|
|
133 write_c_string (buf, printcharfun);
|
|
134 }
|
|
135
|
272
|
136 DEFINE_LRECORD_IMPLEMENTATION ("device", device,
|
|
137 mark_device, print_device, 0, 0, 0,
|
|
138 struct device);
|
0
|
139
|
|
140 int
|
|
141 valid_device_class_p (Lisp_Object class)
|
|
142 {
|
|
143 return !NILP (memq_no_quit (class, Vdevice_class_list));
|
|
144 }
|
|
145
|
20
|
146 DEFUN ("valid-device-class-p", Fvalid_device_class_p, 1, 1, 0, /*
|
0
|
147 Given a DEVICE-CLASS, return t if it is valid.
|
|
148 Valid classes are 'color, 'grayscale, and 'mono.
|
20
|
149 */
|
|
150 (device_class))
|
0
|
151 {
|
185
|
152 return valid_device_class_p (device_class) ? Qt : Qnil;
|
0
|
153 }
|
|
154
|
20
|
155 DEFUN ("device-class-list", Fdevice_class_list, 0, 0, 0, /*
|
0
|
156 Return a list of valid device classes.
|
20
|
157 */
|
|
158 ())
|
0
|
159 {
|
|
160 return Fcopy_sequence (Vdevice_class_list);
|
|
161 }
|
|
162
|
|
163 static struct device *
|
|
164 allocate_device (Lisp_Object console)
|
|
165 {
|
185
|
166 Lisp_Object device;
|
|
167 struct device *d = alloc_lcrecord_type (struct device, lrecord_device);
|
0
|
168 struct gcpro gcpro1;
|
|
169
|
|
170 zero_lcrecord (d);
|
|
171
|
|
172 XSETDEVICE (device, d);
|
|
173 GCPRO1 (device);
|
|
174
|
|
175 d->name = Qnil;
|
|
176 d->console = console;
|
|
177 d->connection = Qnil;
|
|
178 d->canon_connection = Qnil;
|
|
179 d->frame_list = Qnil;
|
|
180 d->_selected_frame = Qnil;
|
|
181 d->frame_with_focus_real = Qnil;
|
|
182 d->frame_with_focus_for_hooks = Qnil;
|
|
183 d->frame_that_ought_to_have_focus = Qnil;
|
|
184 d->device_class = Qnil;
|
|
185 d->user_defined_tags = Qnil;
|
|
186 d->pixel_to_glyph_cache.obj1 = Qnil;
|
|
187 d->pixel_to_glyph_cache.obj2 = Qnil;
|
|
188
|
|
189 d->infd = d->outfd = -1;
|
|
190
|
|
191 /* #### is 20 reasonable? */
|
|
192 d->color_instance_cache = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
|
|
193 HASHTABLE_EQUAL);
|
|
194 d->font_instance_cache = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
|
|
195 HASHTABLE_EQUAL);
|
70
|
196 #ifdef MULE
|
|
197 /* Note that the following table is bi-level. */
|
|
198 d->charset_font_cache = make_lisp_hashtable (20, HASHTABLE_NONWEAK,
|
|
199 HASHTABLE_EQ);
|
|
200 #endif
|
0
|
201 /*
|
|
202 Note that the image instance cache is actually bi-level.
|
|
203 See device.h. We use a low number here because most of the
|
|
204 time there aren't very many diferent masks that will be used.
|
|
205 */
|
|
206 d->image_instance_cache = make_lisp_hashtable (5, HASHTABLE_NONWEAK,
|
|
207 HASHTABLE_EQ);
|
|
208
|
|
209 UNGCPRO;
|
|
210 return d;
|
|
211 }
|
|
212
|
|
213 struct device *
|
|
214 decode_device (Lisp_Object device)
|
|
215 {
|
|
216 if (NILP (device))
|
|
217 device = Fselected_device (Qnil);
|
|
218 /* quietly accept frames for the device arg */
|
|
219 if (FRAMEP (device))
|
|
220 device = FRAME_DEVICE (decode_frame (device));
|
|
221 CHECK_LIVE_DEVICE (device);
|
|
222 return XDEVICE (device);
|
|
223 }
|
|
224
|
20
|
225 DEFUN ("dfw-device", Fdfw_device, 1, 1, 0, /*
|
0
|
226 Given a device, frame, or window, return the associated device.
|
|
227 Return nil otherwise.
|
20
|
228 */
|
|
229 (obj))
|
0
|
230 {
|
|
231 return DFW_DEVICE (obj);
|
|
232 }
|
|
233
|
|
234
|
20
|
235 DEFUN ("selected-device", Fselected_device, 0, 1, 0, /*
|
0
|
236 Return the device which is currently active.
|
|
237 If optional CONSOLE is non-nil, return the device that would be currently
|
|
238 active if CONSOLE were the selected console.
|
20
|
239 */
|
|
240 (console))
|
0
|
241 {
|
|
242 if (NILP (console) && NILP (Vselected_console))
|
|
243 return Qnil; /* happens early in temacs */
|
|
244 return CONSOLE_SELECTED_DEVICE (decode_console (console));
|
|
245 }
|
|
246
|
|
247 /* Called from selected_frame_1(), called from Fselect_window() */
|
|
248 void
|
|
249 select_device_1 (Lisp_Object device)
|
|
250 {
|
|
251 struct device *dev = XDEVICE (device);
|
|
252 Lisp_Object old_selected_device = Fselected_device (Qnil);
|
185
|
253
|
0
|
254 if (EQ (device, old_selected_device))
|
|
255 return;
|
|
256
|
|
257 /* now select the device's console */
|
|
258 CONSOLE_SELECTED_DEVICE (XCONSOLE (DEVICE_CONSOLE (dev))) = device;
|
|
259 select_console_1 (DEVICE_CONSOLE (dev));
|
|
260 }
|
|
261
|
20
|
262 DEFUN ("select-device", Fselect_device, 1, 1, 0, /*
|
0
|
263 Select the device DEVICE.
|
|
264 Subsequent editing commands apply to its console, selected frame,
|
|
265 and selected window.
|
|
266 The selection of DEVICE lasts until the next time the user does
|
|
267 something to select a different device, or until the next time this
|
|
268 function is called.
|
20
|
269 */
|
|
270 (device))
|
0
|
271 {
|
|
272 CHECK_LIVE_DEVICE (device);
|
|
273
|
|
274 /* select the device's selected frame's selected window. This will call
|
|
275 selected_frame_1()->selected_device_1()->selected_console_1(). */
|
|
276 if (!NILP (DEVICE_SELECTED_FRAME (XDEVICE (device))))
|
|
277 Fselect_window (FRAME_SELECTED_WINDOW
|
282
|
278 (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)))),
|
|
279 Qnil);
|
0
|
280 else
|
|
281 error ("Can't select a device with no frames");
|
|
282 return Qnil;
|
|
283 }
|
|
284
|
|
285 void
|
|
286 set_device_selected_frame (struct device *d, Lisp_Object frame)
|
|
287 {
|
|
288 if (!NILP (frame) && !FRAME_MINIBUF_ONLY_P (XFRAME (frame)))
|
|
289 set_console_last_nonminibuf_frame (XCONSOLE (DEVICE_CONSOLE (d)), frame);
|
|
290 d->_selected_frame = frame;
|
|
291 }
|
|
292
|
20
|
293 DEFUN ("set-device-selected-frame", Fset_device_selected_frame, 2, 2, 0, /*
|
0
|
294 Set the selected frame of device object DEVICE to FRAME.
|
|
295 If DEVICE is nil, the selected device is used.
|
|
296 If DEVICE is the selected device, this makes FRAME the selected frame.
|
20
|
297 */
|
|
298 (device, frame))
|
0
|
299 {
|
272
|
300 XSETDEVICE (device, decode_device (device));
|
0
|
301 CHECK_LIVE_FRAME (frame);
|
|
302
|
|
303 if (! EQ (device, FRAME_DEVICE (XFRAME (frame))))
|
|
304 error ("In `set-device-selected-frame', FRAME is not on DEVICE");
|
|
305
|
|
306 if (EQ (device, Fselected_device (Qnil)))
|
|
307 return Fselect_frame (frame);
|
|
308
|
|
309 set_device_selected_frame (XDEVICE (device), frame);
|
|
310 return frame;
|
|
311 }
|
|
312
|
20
|
313 DEFUN ("devicep", Fdevicep, 1, 1, 0, /*
|
0
|
314 Return non-nil if OBJECT is a device.
|
20
|
315 */
|
|
316 (object))
|
0
|
317 {
|
185
|
318 return DEVICEP (object) ? Qt : Qnil;
|
0
|
319 }
|
|
320
|
20
|
321 DEFUN ("device-live-p", Fdevice_live_p, 1, 1, 0, /*
|
0
|
322 Return non-nil if OBJECT is a device that has not been deleted.
|
20
|
323 */
|
|
324 (object))
|
0
|
325 {
|
185
|
326 return DEVICEP (object) && DEVICE_LIVE_P (XDEVICE (object)) ? Qt : Qnil;
|
0
|
327 }
|
|
328
|
20
|
329 DEFUN ("device-name", Fdevice_name, 0, 1, 0, /*
|
0
|
330 Return the name of the specified device.
|
|
331 DEVICE defaults to the selected device if omitted.
|
20
|
332 */
|
|
333 (device))
|
0
|
334 {
|
|
335 return DEVICE_NAME (decode_device (device));
|
|
336 }
|
|
337
|
20
|
338 DEFUN ("device-connection", Fdevice_connection, 0, 1, 0, /*
|
0
|
339 Return the connection of the specified device.
|
|
340 DEVICE defaults to the selected device if omitted.
|
20
|
341 */
|
|
342 (device))
|
0
|
343 {
|
|
344 return DEVICE_CONNECTION (decode_device (device));
|
|
345 }
|
|
346
|
20
|
347 DEFUN ("device-console", Fdevice_console, 0, 1, 0, /*
|
0
|
348 Return the console of the specified device.
|
|
349 DEVICE defaults to the selected device if omitted.
|
20
|
350 */
|
|
351 (device))
|
0
|
352 {
|
|
353 return DEVICE_CONSOLE (decode_device (device));
|
|
354 }
|
|
355
|
263
|
356 #ifdef HAVE_WINDOW_SYSTEM
|
0
|
357
|
|
358 static void
|
|
359 init_global_resources (struct device *d)
|
|
360 {
|
|
361 init_global_faces (d);
|
|
362 #ifdef HAVE_SCROLLBARS
|
|
363 init_global_scrollbars (d);
|
|
364 #endif
|
|
365 #ifdef HAVE_TOOLBARS
|
|
366 init_global_toolbars (d);
|
|
367 #endif
|
|
368 }
|
|
369
|
|
370 #endif
|
|
371
|
|
372 static void
|
|
373 init_device_resources (struct device *d)
|
|
374 {
|
|
375 init_device_faces (d);
|
|
376 #ifdef HAVE_SCROLLBARS
|
|
377 init_device_scrollbars (d);
|
|
378 #endif
|
|
379 #ifdef HAVE_TOOLBARS
|
|
380 init_device_toolbars (d);
|
|
381 #endif
|
|
382 }
|
|
383
|
|
384 static Lisp_Object
|
|
385 semi_canonicalize_device_connection (struct console_methods *meths,
|
|
386 Lisp_Object name, Error_behavior errb)
|
|
387 {
|
|
388 return CONTYPE_METH_OR_GIVEN (meths, semi_canonicalize_device_connection,
|
|
389 (name, errb), name);
|
|
390 }
|
|
391
|
|
392 static Lisp_Object
|
|
393 canonicalize_device_connection (struct console_methods *meths,
|
|
394 Lisp_Object name, Error_behavior errb)
|
|
395 {
|
|
396 return CONTYPE_METH_OR_GIVEN (meths, canonicalize_device_connection,
|
|
397 (name, errb), name);
|
|
398 }
|
|
399
|
|
400 static Lisp_Object
|
|
401 find_device_of_type (struct console_methods *meths, Lisp_Object canon)
|
|
402 {
|
|
403 Lisp_Object devcons, concons;
|
|
404
|
|
405 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
406 {
|
|
407 Lisp_Object device = XCAR (devcons);
|
|
408
|
|
409 if (EQ (CONMETH_TYPE (meths), DEVICE_TYPE (XDEVICE (device)))
|
195
|
410 && internal_equal (DEVICE_CANON_CONNECTION (XDEVICE (device)),
|
|
411 canon, 0))
|
0
|
412 return device;
|
|
413 }
|
|
414
|
|
415 return Qnil;
|
|
416 }
|
|
417
|
20
|
418 DEFUN ("find-device", Ffind_device, 1, 2, 0, /*
|
0
|
419 Look for an existing device attached to connection CONNECTION.
|
|
420 Return the device if found; otherwise, return nil.
|
|
421
|
|
422 If TYPE is specified, only return devices of that type; otherwise,
|
|
423 return devices of any type. (It is possible, although unlikely,
|
|
424 that two devices of different types could have the same connection
|
|
425 name; in such a case, the first device found is returned.)
|
20
|
426 */
|
|
427 (connection, type))
|
0
|
428 {
|
|
429 Lisp_Object canon = Qnil;
|
|
430 struct gcpro gcpro1;
|
|
431
|
|
432 GCPRO1 (canon);
|
|
433
|
|
434 if (!NILP (type))
|
|
435 {
|
|
436 struct console_methods *conmeths = decode_console_type (type, ERROR_ME);
|
|
437 canon = canonicalize_device_connection (conmeths, connection,
|
|
438 ERROR_ME_NOT);
|
|
439 if (UNBOUNDP (canon))
|
|
440 RETURN_UNGCPRO (Qnil);
|
|
441
|
|
442 RETURN_UNGCPRO (find_device_of_type (conmeths, canon));
|
|
443 }
|
|
444 else
|
|
445 {
|
|
446 int i;
|
|
447
|
|
448 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++)
|
|
449 {
|
|
450 struct console_methods *conmeths =
|
|
451 Dynarr_at (the_console_type_entry_dynarr, i).meths;
|
|
452 canon = canonicalize_device_connection (conmeths, connection,
|
|
453 ERROR_ME_NOT);
|
|
454 if (!UNBOUNDP (canon))
|
|
455 {
|
|
456 Lisp_Object device = find_device_of_type (conmeths, canon);
|
|
457 if (!NILP (device))
|
|
458 RETURN_UNGCPRO (device);
|
|
459 }
|
|
460 }
|
|
461
|
|
462 RETURN_UNGCPRO (Qnil);
|
|
463 }
|
|
464 }
|
|
465
|
20
|
466 DEFUN ("get-device", Fget_device, 1, 2, 0, /*
|
0
|
467 Look for an existing device attached to connection CONNECTION.
|
|
468 Return the device if found; otherwise, signal an error.
|
|
469
|
|
470 If TYPE is specified, only return devices of that type; otherwise,
|
|
471 return devices of any type. (It is possible, although unlikely,
|
|
472 that two devices of different types could have the same connection
|
|
473 name; in such a case, the first device found is returned.)
|
20
|
474 */
|
|
475 (connection, type))
|
0
|
476 {
|
|
477 Lisp_Object device = Ffind_device (connection, type);
|
|
478 if (NILP (device))
|
|
479 {
|
|
480 if (NILP (type))
|
|
481 signal_simple_error ("No such device", connection);
|
|
482 else
|
|
483 signal_simple_error_2 ("No such device", type, connection);
|
|
484 }
|
|
485 return device;
|
|
486 }
|
|
487
|
155
|
488 static Lisp_Object
|
272
|
489 delete_deviceless_console (Lisp_Object console)
|
155
|
490 {
|
|
491 if (NILP (XCONSOLE (console)->device_list))
|
185
|
492 Fdelete_console (console, Qnil);
|
155
|
493 return Qnil;
|
|
494 }
|
|
495
|
20
|
496 DEFUN ("make-device", Fmake_device, 2, 3, 0, /*
|
272
|
497 Return a new device of type TYPE, attached to connection CONNECTION.
|
0
|
498
|
|
499 The valid values for CONNECTION are device-specific; however,
|
|
500 CONNECTION is generally a string. (Specifically, for X devices,
|
|
501 CONNECTION should be a display specification such as "foo:0", and
|
|
502 for TTY devices, CONNECTION should be the filename of a TTY device
|
|
503 file, such as "/dev/ttyp4", or nil to refer to XEmacs' standard
|
|
504 input/output.)
|
|
505
|
|
506 PROPS, if specified, should be a plist of properties controlling
|
|
507 device creation.
|
|
508
|
|
509 If CONNECTION specifies an already-existing device connection, that
|
|
510 device is simply returned; no new device is created, and PROPS
|
|
511 have no effect.
|
20
|
512 */
|
|
513 (type, connection, props))
|
0
|
514 {
|
|
515 /* This function can GC */
|
|
516 struct device *d;
|
|
517 struct console *con;
|
|
518 Lisp_Object device = Qnil;
|
|
519 Lisp_Object console = Qnil;
|
|
520 Lisp_Object name = Qnil;
|
|
521 struct console_methods *conmeths;
|
155
|
522 int speccount = specpdl_depth();
|
0
|
523
|
|
524 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
525 #ifdef HAVE_X_WINDOWS
|
|
526 /* #### icky-poo. If this is the first X device we are creating,
|
|
527 then retrieve the global face resources. We have to do it
|
|
528 here, at the same time as (or just before) the device face
|
|
529 resources are retrieved; specifically, it needs to be done
|
|
530 after the device has been created but before any frames have
|
|
531 been popped up or much anything else has been done. It's
|
|
532 possible for other devices to specify different global
|
|
533 resources (there's a property on each X server's root window
|
|
534 that holds some resources); tough luck for the moment.
|
|
535
|
|
536 This is a nasty violation of device independence, but
|
|
537 there's not a whole lot I can figure out to do about it.
|
|
538 The real problem is that the concept of resources is not
|
|
539 generalized away from X. Similar resource-related
|
|
540 device-independence violations occur in faces.el. */
|
|
541 int first_x_device = NILP (Vdefault_x_device) && EQ (type, Qx);
|
|
542 #endif
|
|
543
|
|
544 GCPRO3 (device, console, name);
|
|
545
|
|
546 conmeths = decode_console_type (type, ERROR_ME_NOT);
|
|
547 if (!conmeths)
|
|
548 signal_simple_error ("Invalid device type", type);
|
|
549
|
|
550 device = Ffind_device (connection, type);
|
|
551 if (!NILP (device))
|
|
552 RETURN_UNGCPRO (device);
|
|
553
|
|
554 name = Fplist_get (props, Qname, Qnil);
|
|
555
|
|
556 {
|
|
557 Lisp_Object conconnect =
|
272
|
558 (HAS_CONTYPE_METH_P (conmeths, device_to_console_connection)) ?
|
|
559 CONTYPE_METH (conmeths, device_to_console_connection,
|
|
560 (connection, ERROR_ME)) :
|
|
561 connection;
|
0
|
562 console = create_console (name, type, conconnect, props);
|
|
563 }
|
|
564
|
155
|
565 record_unwind_protect(delete_deviceless_console, console);
|
|
566
|
0
|
567 con = XCONSOLE (console);
|
|
568 d = allocate_device (console);
|
|
569 XSETDEVICE (device, d);
|
|
570
|
|
571 d->devmeths = con->conmeths;
|
|
572
|
|
573 DEVICE_NAME (d) = name;
|
272
|
574 DEVICE_CONNECTION (d) =
|
|
575 semi_canonicalize_device_connection (conmeths, connection, ERROR_ME);
|
|
576 DEVICE_CANON_CONNECTION (d) =
|
|
577 canonicalize_device_connection (conmeths, connection, ERROR_ME);
|
0
|
578
|
|
579 MAYBE_DEVMETH (d, init_device, (d, props));
|
|
580
|
|
581 /* Do it this way so that the device list is in order of creation */
|
|
582 con->device_list = nconc2 (con->device_list, Fcons (device, Qnil));
|
|
583 RESET_CHANGED_SET_FLAGS;
|
|
584 if (NILP (Vdefault_device) || DEVICE_STREAM_P (XDEVICE (Vdefault_device)))
|
|
585 Vdefault_device = device;
|
|
586
|
|
587 init_device_sound (d);
|
|
588 #ifdef HAVE_X_WINDOWS
|
|
589 if (first_x_device)
|
|
590 init_global_resources (d);
|
|
591 #endif
|
|
592 init_device_resources (d);
|
|
593
|
|
594 MAYBE_DEVMETH (d, finish_init_device, (d, props));
|
|
595
|
|
596 /* If this is the first device on the console, make it the selected one. */
|
|
597 if (NILP (CONSOLE_SELECTED_DEVICE (con)))
|
|
598 CONSOLE_SELECTED_DEVICE (con) = device;
|
|
599
|
|
600 /* #### the following should trap errors. */
|
|
601 setup_device_initial_specifier_tags (d);
|
|
602
|
|
603 UNGCPRO;
|
155
|
604 unbind_to(speccount, Qnil);
|
0
|
605 return device;
|
|
606 }
|
|
607
|
|
608 /* find a device other than the selected one. Prefer non-stream
|
|
609 devices over stream devices. Maybe stay on the same console. */
|
|
610
|
|
611 static Lisp_Object
|
|
612 find_other_device (Lisp_Object device, int on_same_console)
|
|
613 {
|
272
|
614 Lisp_Object devcons = Qnil, concons;
|
0
|
615 Lisp_Object console = DEVICE_CONSOLE (XDEVICE (device));
|
|
616
|
|
617 /* look for a non-stream device */
|
|
618 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
619 {
|
|
620 Lisp_Object dev = XCAR (devcons);
|
|
621 if (on_same_console && !EQ (console, DEVICE_CONSOLE (XDEVICE (dev))))
|
|
622 continue;
|
|
623 if (!DEVICE_STREAM_P (XDEVICE (dev)) && !EQ (dev, device) &&
|
|
624 !NILP (DEVICE_SELECTED_FRAME (XDEVICE (dev))))
|
|
625 goto double_break_1;
|
|
626 }
|
|
627
|
|
628 double_break_1:
|
|
629 if (!NILP (devcons))
|
|
630 return XCAR (devcons);
|
|
631
|
|
632 /* OK, now look for a stream device */
|
|
633 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
634 {
|
|
635 Lisp_Object dev = XCAR (devcons);
|
|
636 if (on_same_console && !EQ (console, DEVICE_CONSOLE (XDEVICE (dev))))
|
|
637 continue;
|
|
638 if (!EQ (dev, device) && !NILP (DEVICE_SELECTED_FRAME (XDEVICE (dev))))
|
|
639 goto double_break_2;
|
|
640 }
|
|
641 double_break_2:
|
|
642 if (!NILP (devcons))
|
|
643 return XCAR (devcons);
|
|
644
|
|
645 /* Sorry, there ain't none */
|
|
646 return Qnil;
|
|
647 }
|
|
648
|
|
649 static int
|
|
650 find_nonminibuffer_frame_not_on_device_predicate (Lisp_Object frame,
|
|
651 void *closure)
|
|
652 {
|
|
653 Lisp_Object device;
|
|
654
|
|
655 VOID_TO_LISP (device, closure);
|
|
656 if (FRAME_MINIBUF_ONLY_P (XFRAME (frame)))
|
|
657 return 0;
|
|
658 if (EQ (device, FRAME_DEVICE (XFRAME (frame))))
|
|
659 return 0;
|
|
660 return 1;
|
|
661 }
|
|
662
|
|
663 Lisp_Object
|
|
664 find_nonminibuffer_frame_not_on_device (Lisp_Object device)
|
|
665 {
|
|
666 return find_some_frame (find_nonminibuffer_frame_not_on_device_predicate,
|
|
667 LISP_TO_VOID (device));
|
|
668 }
|
|
669
|
|
670
|
|
671 /* Delete device D.
|
|
672
|
|
673 If FORCE is non-zero, allow deletion of the only frame.
|
|
674
|
|
675 If CALLED_FROM_DELETE_CONSOLE is non-zero, then, if
|
|
676 deleting the last device on a console, just delete it,
|
|
677 instead of calling `delete-console'.
|
|
678
|
|
679 If FROM_IO_ERROR is non-zero, then the device is gone due
|
|
680 to an I/O error. This affects what happens if we exit
|
|
681 (we do an emergency exit instead of `save-buffers-kill-emacs'.)
|
|
682 */
|
|
683
|
|
684 void
|
|
685 delete_device_internal (struct device *d, int force,
|
|
686 int called_from_delete_console,
|
|
687 int from_io_error)
|
|
688 {
|
|
689 /* This function can GC */
|
|
690 struct console *c;
|
272
|
691 Lisp_Object device;
|
0
|
692 struct gcpro gcpro1;
|
|
693
|
|
694 /* OK to delete an already-deleted device. */
|
|
695 if (!DEVICE_LIVE_P (d))
|
|
696 return;
|
|
697
|
|
698 XSETDEVICE (device, d);
|
|
699 GCPRO1 (device);
|
|
700
|
|
701 c = XCONSOLE (DEVICE_CONSOLE (d));
|
|
702
|
|
703 if (!called_from_delete_console)
|
|
704 {
|
|
705 int delete_console = 0;
|
|
706 /* If we're deleting the only device on the console,
|
|
707 delete the console. */
|
|
708 if ((XINT (Flength (CONSOLE_DEVICE_LIST (c))) == 1)
|
|
709 /* if we just created the device, it might not be listed,
|
|
710 or something ... */
|
|
711 && !NILP (memq_no_quit (device, CONSOLE_DEVICE_LIST (c))))
|
|
712 delete_console = 1;
|
|
713 /* Or if there aren't any nonminibuffer frames that would be
|
|
714 left, delete the console (this will make XEmacs exit). */
|
|
715 else if (NILP (find_nonminibuffer_frame_not_on_device (device)))
|
|
716 delete_console = 1;
|
|
717
|
|
718 if (delete_console)
|
|
719 {
|
|
720 delete_console_internal (c, force, 0, from_io_error);
|
|
721 UNGCPRO;
|
|
722 return;
|
|
723 }
|
|
724 }
|
|
725
|
|
726 reset_one_device (d);
|
|
727
|
|
728 {
|
|
729 Lisp_Object frmcons;
|
|
730
|
|
731 /* First delete all frames without their own minibuffers,
|
|
732 to avoid errors coming from attempting to delete a frame
|
|
733 that is a surrogate for another frame. */
|
|
734 DEVICE_FRAME_LOOP (frmcons, d)
|
|
735 {
|
|
736 struct frame *f = XFRAME (XCAR (frmcons));
|
|
737 /* delete_frame_internal() might do anything such as run hooks,
|
|
738 so be defensive. */
|
|
739 if (FRAME_LIVE_P (f) && !FRAME_HAS_MINIBUF_P (f))
|
|
740 delete_frame_internal (f, 1, 1, from_io_error);
|
|
741
|
|
742 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
|
|
743 go ahead and delete anything */
|
|
744 {
|
|
745 UNGCPRO;
|
|
746 return;
|
|
747 }
|
|
748 }
|
|
749
|
|
750 /* #### This should probably be a device method but it is time for
|
|
751 19.14 to go out the door. */
|
|
752 #ifdef HAVE_X_WINDOWS
|
|
753 /* Next delete all frames which have the popup property to avoid
|
|
754 deleting a child after its parent. */
|
|
755 DEVICE_FRAME_LOOP (frmcons, d)
|
|
756 {
|
|
757 struct frame *f = XFRAME (XCAR (frmcons));
|
|
758
|
|
759 if (FRAME_LIVE_P (f))
|
|
760 {
|
|
761 Lisp_Object popup = Fframe_property (XCAR (frmcons), Qpopup, Qnil);
|
|
762 if (!NILP (popup))
|
|
763 delete_frame_internal (f, 1, 1, from_io_error);
|
|
764
|
|
765 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
|
|
766 go ahead and delete anything */
|
|
767 {
|
|
768 UNGCPRO;
|
|
769 return;
|
|
770 }
|
|
771 }
|
|
772 }
|
|
773 #endif /* HAVE_X_WINDOWS */
|
|
774
|
|
775 DEVICE_FRAME_LOOP (frmcons, d)
|
|
776 {
|
|
777 struct frame *f = XFRAME (XCAR (frmcons));
|
|
778 /* delete_frame_internal() might do anything such as run hooks,
|
|
779 so be defensive. */
|
|
780 if (FRAME_LIVE_P (f))
|
|
781 delete_frame_internal (f, 1, 1, from_io_error);
|
|
782
|
|
783 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
|
|
784 go ahead and delete anything */
|
|
785 {
|
|
786 UNGCPRO;
|
|
787 return;
|
|
788 }
|
|
789 }
|
|
790 }
|
|
791
|
|
792 set_device_selected_frame (d, Qnil);
|
|
793
|
|
794 /* try to select another device */
|
|
795
|
|
796 if (EQ (device, Fselected_device (DEVICE_CONSOLE (d))))
|
|
797 {
|
|
798 Lisp_Object other_dev = find_other_device (device, 1);
|
|
799 if (!NILP (other_dev))
|
|
800 Fselect_device (other_dev);
|
|
801 }
|
|
802
|
|
803 if (EQ (device, Vdefault_device))
|
|
804 Vdefault_device = find_other_device (device, 0);
|
|
805
|
|
806 MAYBE_DEVMETH (d, delete_device, (d));
|
|
807
|
|
808 CONSOLE_DEVICE_LIST (c) = delq_no_quit (device, CONSOLE_DEVICE_LIST (c));
|
|
809 RESET_CHANGED_SET_FLAGS;
|
|
810 d->devmeths = dead_console_methods;
|
|
811 UNGCPRO;
|
|
812 }
|
|
813
|
|
814 /* delete a device as a result of an I/O error. Called from
|
|
815 an enqueued magic-eval event. */
|
|
816
|
|
817 void
|
|
818 io_error_delete_device (Lisp_Object device)
|
|
819 {
|
|
820 delete_device_internal (XDEVICE (device), 1, 0, 1);
|
|
821 }
|
|
822
|
20
|
823 DEFUN ("delete-device", Fdelete_device, 1, 2, 0, /*
|
0
|
824 Delete DEVICE, permanently eliminating it from use.
|
|
825 Normally, you cannot delete the last non-minibuffer-only frame (you must
|
|
826 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
|
|
827 second argument FORCE is non-nil, you can delete the last frame. (This
|
|
828 will automatically call `save-buffers-kill-emacs'.)
|
20
|
829 */
|
|
830 (device, force))
|
0
|
831 {
|
|
832 CHECK_DEVICE (device);
|
|
833 delete_device_internal (XDEVICE (device), !NILP (force), 0, 0);
|
|
834 return Qnil;
|
|
835 }
|
|
836
|
20
|
837 DEFUN ("device-frame-list", Fdevice_frame_list, 0, 1, 0, /*
|
0
|
838 Return a list of all frames on DEVICE.
|
|
839 If DEVICE is nil, the selected device will be used.
|
20
|
840 */
|
|
841 (device))
|
0
|
842 {
|
|
843 return Fcopy_sequence (DEVICE_FRAME_LIST (decode_device (device)));
|
|
844 }
|
|
845
|
20
|
846 DEFUN ("device-class", Fdevice_class, 0, 1, 0, /*
|
0
|
847 Return the class (color behavior) of DEVICE.
|
|
848 This will be one of 'color, 'grayscale, or 'mono.
|
20
|
849 */
|
|
850 (device))
|
0
|
851 {
|
|
852 return DEVICE_CLASS (decode_device (device));
|
|
853 }
|
|
854
|
20
|
855 DEFUN ("set-device-class", Fset_device_class, 2, 2, 0, /*
|
0
|
856 Set the class (color behavior) of DEVICE.
|
|
857 CLASS should be one of 'color, 'grayscale, or 'mono.
|
|
858 This is only allowed on device such as TTY devices, where the color
|
|
859 behavior cannot necessarily be determined automatically.
|
20
|
860 */
|
|
861 (device, class))
|
0
|
862 {
|
|
863 struct device *d = decode_device (device);
|
|
864 XSETDEVICE (device, d);
|
|
865 if (!DEVICE_TTY_P (d))
|
|
866 signal_simple_error ("Cannot change the class of this device", device);
|
|
867 if (!EQ (class, Qcolor) && !EQ (class, Qmono) && !EQ (class, Qgrayscale))
|
|
868 signal_simple_error ("Must be color, mono, or grayscale", class);
|
272
|
869 if (! EQ (DEVICE_CLASS (d), class))
|
|
870 {
|
|
871 Lisp_Object frmcons;
|
|
872 DEVICE_CLASS (d) = class;
|
|
873 DEVICE_FRAME_LOOP (frmcons, d)
|
|
874 {
|
|
875 struct frame *f = XFRAME (XCAR (frmcons));
|
|
876
|
|
877 recompute_all_cached_specifiers_in_frame (f);
|
|
878 MARK_FRAME_FACES_CHANGED (f);
|
|
879 MARK_FRAME_GLYPHS_CHANGED (f);
|
|
880 MARK_FRAME_TOOLBARS_CHANGED (f);
|
|
881 f->menubar_changed = 1;
|
|
882 }
|
|
883 }
|
0
|
884 return Qnil;
|
|
885 }
|
|
886
|
20
|
887 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /*
|
0
|
888 Set the output baud rate of DEVICE to RATE.
|
|
889 On most systems, changing this value will affect the amount of padding
|
|
890 and other strategic decisions made during redisplay.
|
20
|
891 */
|
|
892 (device, rate))
|
0
|
893 {
|
|
894 CHECK_INT (rate);
|
|
895
|
|
896 DEVICE_BAUD_RATE (decode_device (device)) = XINT (rate);
|
|
897
|
|
898 return rate;
|
|
899 }
|
|
900
|
20
|
901 DEFUN ("device-baud-rate", Fdevice_baud_rate, 0, 1, 0, /*
|
0
|
902 Return the output baud rate of DEVICE.
|
20
|
903 */
|
|
904 (device))
|
0
|
905 {
|
|
906 return make_int (DEVICE_BAUD_RATE (decode_device (device)));
|
|
907 }
|
|
908
|
284
|
909 DEFUN ("device-system-metric", Fdevice_system_metric, 1, 3, 0, /*
|
|
910 Get a metric for DEVICE as provided by the system.
|
282
|
911
|
284
|
912 METRIC must be a symbol specifying requested metric. Note that the metrics
|
|
913 returned are these provided by the system internally, not read from resources,
|
|
914 so obtained from the most internal level.
|
282
|
915
|
284
|
916 If a metric is not provided by the system, then DEFAULT is returned.
|
|
917
|
|
918 When DEVICE is nil, selected device is assumed
|
282
|
919
|
|
920 Metrics, by group, are:
|
|
921
|
284
|
922 COLORS. Colors are returned as valid color instantiators. No other assumption
|
|
923 on the returned valie should be made (i.e. it can be a string on one system but
|
|
924 a color instance on another). For colors, returned value is a cons of
|
|
925 foreground and background colors. Note that if the system provides only one
|
|
926 color of the pair, the second one may be nil.
|
282
|
927
|
284
|
928 color-default Standard window text foreground and background.
|
|
929 color-select Selection highligh text and backgroun colors.
|
|
930 color-balloon Ballon popup text and background colors.
|
|
931 color-3d-face 3-D object (button, modeline) text and surface colors.
|
|
932 color-3d-light Fore and back colors for 3-D edges facing light source.
|
|
933 color-3d-dark Fore and back colors for 3-D edges facing away from
|
|
934 light source.
|
|
935 color-menu Text and background for menus
|
|
936 color-menu-highlight Selected menu item colors
|
|
937 color-menu-button Menu button colors
|
|
938 color-menu-disabled Unselectable menu item colors
|
|
939 color-toolbar Toolbar foreground and background colors
|
|
940 color-scrollbar Scrollbar foreground and background colors
|
|
941 color-desktop Desktop window colors
|
|
942 color-workspace Workspace window colors
|
282
|
943
|
284
|
944 FONTS. Fonts are returned as valid font instantiators. No other assumption on
|
|
945 the returned value should be made (i.e. it can be a string on one system but
|
|
946 font instance on another).
|
282
|
947
|
284
|
948 font-default Default fixed width font.
|
|
949 font-menubar Menubar font
|
|
950 font-dialog Dialog boxes font
|
282
|
951
|
284
|
952 GEOMETRY. These metrics are returned as conses of (X . Y). As with colors,
|
282
|
953 either car or cdr of the cons may be nil if the system does not provide one
|
|
954 of corresponding dimensions.
|
|
955
|
284
|
956 size-cursor Mouse cursor size.
|
|
957 size-scrollbar Scrollbars (WIDTH . HEIGHT)
|
|
958 size-menu Menubar height, as (nil . HEIGHT)
|
|
959 size-toolbar Toolbar width and height.
|
|
960 size-toolbar-button Toolbar button size.
|
|
961 size-toolbar-border Toolbar border width and height.
|
|
962 size-icon Icon dimensions.
|
|
963 size-icon-small Small icon dimensions.
|
|
964 size-device Device screen size in pixels.
|
|
965 size-workspace Workspace size in pixels. This can be less than the
|
|
966 above if window manager has decorations which
|
|
967 effectively shrink the area remaining for application
|
|
968 windows.
|
|
969 size-device-mm Device screen size in millimeters.
|
|
970 device-dpi Device resolution, in dots per inch.
|
|
971 num-bit-planes Integer, number of deivce bit planes.
|
|
972 num-color-cells Integer, number of device color cells.
|
282
|
973
|
284
|
974 FEATURES. This group reports various device features. If a feature is
|
|
975 present, integer 1 (one) is returned, if it is not present, then integer
|
|
976 0 (zero) is returned. If the system is unaware of the feature, then
|
|
977 DEFAULT is returned.
|
|
978
|
|
979 mouse-buttons Integer, number of mouse buttons, or zero if no mouse.
|
|
980 swap-buttons Non-zero if left and right mouse buttons are swapped.
|
|
981 show-sounds User preference for visual over audible bell.
|
|
982 slow-device Device is slow, avoid animation.
|
|
983 security Non-zero if user environment is secure.
|
282
|
984 */
|
284
|
985 (device, metric, default_))
|
282
|
986 {
|
|
987 struct device *d = decode_device (device);
|
|
988 enum device_metrics m;
|
284
|
989 Lisp_Object res;
|
282
|
990
|
|
991 /* Decode metric */
|
284
|
992 #define FROB(met) \
|
|
993 else if (EQ (metric, Q##met)) \
|
|
994 m = DM_##met
|
|
995
|
|
996 if (0)
|
|
997 ;
|
|
998 FROB (color_default);
|
|
999 FROB (color_select);
|
|
1000 FROB (color_balloon);
|
|
1001 FROB (color_3d_face);
|
|
1002 FROB (color_3d_light);
|
|
1003 FROB (color_3d_dark);
|
|
1004 FROB (color_menu);
|
|
1005 FROB (color_menu_highlight);
|
|
1006 FROB (color_menu_button);
|
|
1007 FROB (color_menu_disabled);
|
|
1008 FROB (color_toolbar);
|
|
1009 FROB (color_scrollbar);
|
|
1010 FROB (color_desktop);
|
|
1011 FROB (color_workspace);
|
|
1012 FROB (font_default);
|
|
1013 FROB (font_menubar);
|
|
1014 FROB (font_dialog);
|
|
1015 FROB (size_cursor);
|
|
1016 FROB (size_scrollbar);
|
|
1017 FROB (size_menu);
|
|
1018 FROB (size_toolbar);
|
|
1019 FROB (size_toolbar_button);
|
|
1020 FROB (size_toolbar_border);
|
|
1021 FROB (size_icon);
|
|
1022 FROB (size_icon_small);
|
|
1023 FROB (size_device);
|
|
1024 FROB (size_workspace);
|
|
1025 FROB (size_device_mm);
|
|
1026 FROB (device_dpi);
|
|
1027 FROB (num_bit_planes);
|
|
1028 FROB (num_color_cells);
|
|
1029 FROB (mouse_buttons);
|
|
1030 FROB (swap_buttons);
|
|
1031 FROB (show_sounds);
|
|
1032 FROB (slow_device);
|
|
1033 FROB (security);
|
282
|
1034 else
|
|
1035 signal_simple_error ("Invalid device metric symbol", metric);
|
284
|
1036
|
|
1037 res = DEVMETH_OR_GIVEN (d, device_system_metrics, (d, m), Qunbound);
|
|
1038 return UNBOUNDP(res) ? default_ : res;
|
|
1039
|
|
1040 #undef FROB
|
|
1041 }
|
|
1042
|
|
1043 DEFUN ("device-system-metrics", Fdevice_system_metrics, 0, 1, 0, /*
|
|
1044 Get a property list of device metric for DEVICE.
|
|
1045
|
|
1046 See `device-system-metric' for the description of available metrics.
|
|
1047 DEVICE defaults to selected device when omitted.
|
|
1048 */
|
|
1049 (device))
|
|
1050 {
|
|
1051 struct device *d = decode_device (device);
|
|
1052 Lisp_Object plist = Qnil, one_metric;
|
|
1053
|
|
1054 #define FROB(m) \
|
|
1055 if (!UNBOUNDP ((one_metric = \
|
|
1056 DEVMETH_OR_GIVEN (d, device_system_metrics, \
|
|
1057 (d, DM_##m), Qunbound)))) \
|
|
1058 plist = Fcons (Q##m, Fcons (one_metric, plist));
|
|
1059
|
|
1060 FROB (color_default);
|
|
1061 FROB (color_select);
|
|
1062 FROB (color_balloon);
|
|
1063 FROB (color_3d_face);
|
|
1064 FROB (color_3d_light);
|
|
1065 FROB (color_3d_dark);
|
|
1066 FROB (color_menu);
|
|
1067 FROB (color_menu_highlight);
|
|
1068 FROB (color_menu_button);
|
|
1069 FROB (color_menu_disabled);
|
|
1070 FROB (color_toolbar);
|
|
1071 FROB (color_scrollbar);
|
|
1072 FROB (color_desktop);
|
|
1073 FROB (color_workspace);
|
|
1074 FROB (font_default);
|
|
1075 FROB (font_menubar);
|
|
1076 FROB (font_dialog);
|
|
1077 FROB (size_cursor);
|
|
1078 FROB (size_scrollbar);
|
|
1079 FROB (size_menu);
|
|
1080 FROB (size_toolbar);
|
|
1081 FROB (size_toolbar_button);
|
|
1082 FROB (size_toolbar_border);
|
|
1083 FROB (size_icon);
|
|
1084 FROB (size_icon_small);
|
|
1085 FROB (size_device);
|
|
1086 FROB (size_workspace);
|
|
1087 FROB (size_device_mm);
|
|
1088 FROB (device_dpi);
|
|
1089 FROB (num_bit_planes);
|
|
1090 FROB (num_color_cells);
|
|
1091 FROB (mouse_buttons);
|
|
1092 FROB (swap_buttons);
|
|
1093 FROB (show_sounds);
|
|
1094 FROB (slow_device);
|
|
1095 FROB (security);
|
|
1096
|
|
1097 return plist;
|
|
1098
|
|
1099 #undef FROB
|
282
|
1100 }
|
|
1101
|
269
|
1102 Lisp_Object
|
|
1103 domain_device_type (Lisp_Object domain)
|
|
1104 {
|
|
1105 /* This cannot GC */
|
|
1106 assert (WINDOWP (domain) || FRAMEP (domain)
|
|
1107 || DEVICEP (domain) || CONSOLEP (domain));
|
|
1108
|
|
1109 if (WINDOWP (domain))
|
|
1110 {
|
|
1111 if (!WINDOW_LIVE_P (XWINDOW (domain)))
|
|
1112 return Qdead;
|
|
1113 domain = WINDOW_FRAME (XWINDOW (domain));
|
|
1114 }
|
|
1115 if (FRAMEP (domain))
|
|
1116 {
|
|
1117 if (!FRAME_LIVE_P (XFRAME (domain)))
|
|
1118 return Qdead;
|
|
1119 domain = FRAME_DEVICE (XFRAME (domain));
|
|
1120 }
|
|
1121 if (DEVICEP (domain))
|
|
1122 {
|
|
1123 if (!DEVICE_LIVE_P (XDEVICE (domain)))
|
|
1124 return Qdead;
|
|
1125 domain = DEVICE_CONSOLE (XDEVICE (domain));
|
|
1126 }
|
|
1127 return CONSOLE_TYPE (XCONSOLE (domain));
|
|
1128 }
|
|
1129
|
|
1130 /*
|
|
1131 * Determine whether window system bases window geometry on character
|
|
1132 * or pixel counts.
|
|
1133 * Return non-zero for pixel-based geometry, zero for character-based.
|
|
1134 */
|
|
1135 int
|
|
1136 window_system_pixelated_geometry (Lisp_Object domain)
|
|
1137 {
|
|
1138 /* This cannot GC */
|
|
1139 Lisp_Object winsy = domain_device_type (domain);
|
|
1140 struct console_methods *meth = decode_console_type (winsy, ERROR_ME_NOT);
|
|
1141 assert (meth);
|
|
1142 return (MAYBE_INT_CONTYPE_METH (meth, device_implementation_flags, ())
|
|
1143 & XDEVIMPF_PIXEL_GEOMETRY);
|
|
1144 }
|
|
1145
|
|
1146 DEFUN ("domain-device-type", Fdomain_device_type, 0, 1, 0, /*
|
|
1147 Return the device type symbol for a DOMAIN, e.g. 'x or 'tty.
|
|
1148 DOMAIN can be either a window, frame, device or console.
|
|
1149 */
|
|
1150 (domain))
|
|
1151 {
|
|
1152 if (!WINDOWP (domain) && !FRAMEP (domain)
|
|
1153 && !DEVICEP (domain) && !CONSOLEP (domain))
|
|
1154 signal_simple_error
|
|
1155 ("Domain must be either a window, frame, device or console", domain);
|
|
1156
|
|
1157 return domain_device_type (domain);
|
|
1158 }
|
|
1159
|
0
|
1160 void
|
|
1161 handle_asynch_device_change (void)
|
|
1162 {
|
|
1163 int i;
|
|
1164 int old_asynch_device_change_pending = asynch_device_change_pending;
|
|
1165 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++)
|
|
1166 {
|
|
1167 if (Dynarr_at (the_console_type_entry_dynarr, i).meths->
|
|
1168 asynch_device_change_method)
|
|
1169 (Dynarr_at (the_console_type_entry_dynarr, i).meths->
|
|
1170 asynch_device_change_method) ();
|
|
1171 }
|
|
1172 /* reset the flag to 0 unless another notification occurred while
|
|
1173 we were processing this one. Block SIGWINCH during this
|
|
1174 check to prevent a possible race condition. */
|
100
|
1175 #ifndef WINDOWSNT
|
0
|
1176 EMACS_BLOCK_SIGNAL (SIGWINCH);
|
100
|
1177 #endif
|
0
|
1178 if (old_asynch_device_change_pending == asynch_device_change_pending)
|
|
1179 asynch_device_change_pending = 0;
|
100
|
1180 #ifndef WINDOWSNT
|
0
|
1181 EMACS_UNBLOCK_SIGNAL (SIGWINCH);
|
100
|
1182 #endif
|
0
|
1183 }
|
|
1184
|
|
1185 void
|
|
1186 call_critical_lisp_code (struct device *d, Lisp_Object function,
|
|
1187 Lisp_Object object)
|
|
1188 {
|
|
1189 int old_gc_currently_forbidden = gc_currently_forbidden;
|
|
1190 Lisp_Object old_inhibit_quit = Vinhibit_quit;
|
|
1191
|
|
1192 /* There's no reason to bother doing specbinds here, because if
|
|
1193 initialize-*-faces signals an error, emacs is going to crash
|
|
1194 immediately.
|
|
1195 */
|
|
1196 gc_currently_forbidden = 1;
|
|
1197 Vinhibit_quit = Qt;
|
|
1198 LOCK_DEVICE (d);
|
|
1199
|
|
1200 /* But it's useful to have an error handler; otherwise an infinite
|
|
1201 loop may result. */
|
|
1202 if (!NILP (object))
|
|
1203 call1_with_handler (Qreally_early_error_handler, function, object);
|
|
1204 else
|
|
1205 call0_with_handler (Qreally_early_error_handler, function);
|
185
|
1206
|
0
|
1207 UNLOCK_DEVICE (d);
|
|
1208 Vinhibit_quit = old_inhibit_quit;
|
|
1209 gc_currently_forbidden = old_gc_currently_forbidden;
|
|
1210 }
|
|
1211
|
|
1212
|
|
1213 /************************************************************************/
|
|
1214 /* initialization */
|
|
1215 /************************************************************************/
|
|
1216
|
|
1217 void
|
|
1218 syms_of_device (void)
|
|
1219 {
|
20
|
1220 DEFSUBR (Fvalid_device_class_p);
|
|
1221 DEFSUBR (Fdevice_class_list);
|
0
|
1222
|
20
|
1223 DEFSUBR (Fdfw_device);
|
|
1224 DEFSUBR (Fselected_device);
|
|
1225 DEFSUBR (Fselect_device);
|
|
1226 DEFSUBR (Fset_device_selected_frame);
|
|
1227 DEFSUBR (Fdevicep);
|
|
1228 DEFSUBR (Fdevice_live_p);
|
|
1229 DEFSUBR (Fdevice_name);
|
|
1230 DEFSUBR (Fdevice_connection);
|
|
1231 DEFSUBR (Fdevice_console);
|
|
1232 DEFSUBR (Ffind_device);
|
|
1233 DEFSUBR (Fget_device);
|
|
1234 DEFSUBR (Fmake_device);
|
|
1235 DEFSUBR (Fdelete_device);
|
|
1236 DEFSUBR (Fdevice_frame_list);
|
|
1237 DEFSUBR (Fdevice_class);
|
|
1238 DEFSUBR (Fset_device_class);
|
282
|
1239 DEFSUBR (Fdevice_system_metrics);
|
284
|
1240 DEFSUBR (Fdevice_system_metric);
|
20
|
1241 DEFSUBR (Fset_device_baud_rate);
|
|
1242 DEFSUBR (Fdevice_baud_rate);
|
269
|
1243 DEFSUBR (Fdomain_device_type);
|
0
|
1244
|
|
1245 defsymbol (&Qdevicep, "devicep");
|
|
1246 defsymbol (&Qdevice_live_p, "device-live-p");
|
|
1247 defsymbol (&Qdelete_device, "delete-device");
|
|
1248
|
|
1249 defsymbol (&Qcreate_device_hook, "create-device-hook");
|
|
1250 defsymbol (&Qdelete_device_hook, "delete-device-hook");
|
|
1251
|
|
1252 /* Qcolor defined in general.c */
|
|
1253 defsymbol (&Qgrayscale, "grayscale");
|
|
1254 defsymbol (&Qmono, "mono");
|
282
|
1255
|
|
1256 /* Device metrics symbols */
|
|
1257 defsymbol (&Qcolor_default, "color-default");
|
|
1258 defsymbol (&Qcolor_select, "color-select");
|
|
1259 defsymbol (&Qcolor_balloon, "color-balloon");
|
|
1260 defsymbol (&Qcolor_3d_face, "color-3d-face");
|
|
1261 defsymbol (&Qcolor_3d_light, "color-3d-light");
|
|
1262 defsymbol (&Qcolor_3d_dark, "color-3d-dark");
|
|
1263 defsymbol (&Qcolor_menu, "color-menu");
|
284
|
1264 defsymbol (&Qcolor_menu_highlight, "color-menu-highlight");
|
282
|
1265 defsymbol (&Qcolor_menu_button, "color-menu-button");
|
284
|
1266 defsymbol (&Qcolor_menu_disabled, "color-menu-disabled");
|
282
|
1267 defsymbol (&Qcolor_toolbar, "color-toolbar");
|
|
1268 defsymbol (&Qcolor_scrollbar, "color-scrollbar");
|
|
1269 defsymbol (&Qcolor_desktop, "color-desktop");
|
|
1270 defsymbol (&Qcolor_workspace, "color-workspace");
|
|
1271 defsymbol (&Qfont_default, "font-default");
|
|
1272 defsymbol (&Qfont_menubar, "font-menubar");
|
|
1273 defsymbol (&Qfont_dialog, "font-dialog");
|
|
1274 defsymbol (&Qsize_cursor, "size-cursor");
|
|
1275 defsymbol (&Qsize_scrollbar, "size-scrollbar");
|
|
1276 defsymbol (&Qsize_menu, "size-menu");
|
|
1277 defsymbol (&Qsize_toolbar, "size-toolbar");
|
284
|
1278 defsymbol (&Qsize_toolbar_button, "size-toolbar-button");
|
|
1279 defsymbol (&Qsize_toolbar_border, "size-toolbar-border");
|
282
|
1280 defsymbol (&Qsize_icon, "size-icon");
|
|
1281 defsymbol (&Qsize_icon_small, "size-icon-small");
|
|
1282 defsymbol (&Qsize_device, "size-device");
|
|
1283 defsymbol (&Qsize_workspace, "size-workspace");
|
|
1284 defsymbol (&Qsize_device_mm, "size-device-mm");
|
|
1285 defsymbol (&Qnum_bit_planes, "num-bit-planes");
|
|
1286 defsymbol (&Qnum_color_cells, "num-color-cells");
|
|
1287 defsymbol (&Qdevice_dpi, "device-dpi");
|
|
1288 defsymbol (&Qmouse_buttons, "mouse-buttons");
|
|
1289 defsymbol (&Qswap_buttons, "swap-buttons");
|
|
1290 defsymbol (&Qshow_sounds, "show-sounds");
|
|
1291 defsymbol (&Qslow_device, "slow-device");
|
|
1292 defsymbol (&Qsecurity, "security");
|
0
|
1293 }
|
|
1294
|
|
1295 void
|
|
1296 vars_of_device (void)
|
|
1297 {
|
|
1298 DEFVAR_LISP ("create-device-hook", &Vcreate_device_hook /*
|
|
1299 Function or functions to call when a device is created.
|
|
1300 One argument, the newly-created device.
|
|
1301 This is called after the first frame has been created, but before
|
|
1302 calling the `create-frame-hook'.
|
|
1303 Note that in general the device will not be selected.
|
|
1304 */ );
|
|
1305 Vcreate_device_hook = Qnil;
|
|
1306
|
|
1307 DEFVAR_LISP ("delete-device-hook", &Vdelete_device_hook /*
|
|
1308 Function or functions to call when a device is deleted.
|
|
1309 One argument, the to-be-deleted device.
|
|
1310 */ );
|
|
1311 Vdelete_device_hook = Qnil;
|
|
1312
|
|
1313 staticpro (&Vdefault_device);
|
|
1314 Vdefault_device = Qnil;
|
|
1315
|
|
1316 asynch_device_change_pending = 0;
|
|
1317
|
|
1318 Vdevice_class_list = list3 (Qcolor, Qgrayscale, Qmono);
|
|
1319 staticpro (&Vdevice_class_list);
|
229
|
1320
|
|
1321 /* Death to devices.el !!! */
|
|
1322 Fprovide(intern("devices"));
|
0
|
1323 }
|