annotate src/device.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents b2472a1930f2
children c42ec1d1cded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1 /* Generic device functions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /* Original version by Chuck Thompson;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 rewritten and expanded by Ben Wing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "console.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "elhash.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "events.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #include "keymap.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #include "redisplay.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 #include "scrollbar.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include "specifier.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #include "sysdep.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #include "syssignal.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 /* Vdefault_device is the firstly-created non-stream device that's still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 around. We don't really use it anywhere currently, but it might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 be used for resourcing at some point. (Currently we use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Vdefault_x_device.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Lisp_Object Vdefault_device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 Lisp_Object Vcreate_device_hook, Vdelete_device_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 /* Device classes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 /* Qcolor defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Lisp_Object Qgrayscale, Qmono;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Lisp_Object Qdevicep, Qdevice_live_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Lisp_Object Qdelete_device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Lisp_Object Qcreate_device_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Lisp_Object Qdelete_device_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Lisp_Object Vdevice_class_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 mark_device (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 struct device *d = XDEVICE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ((markobj) (d->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ((markobj) (d->connection));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ((markobj) (d->canon_connection));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ((markobj) (d->console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ((markobj) (d->_selected_frame));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ((markobj) (d->frame_with_focus_real));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ((markobj) (d->frame_with_focus_for_hooks));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ((markobj) (d->frame_that_ought_to_have_focus));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ((markobj) (d->device_class));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ((markobj) (d->user_defined_tags));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ((markobj) (d->pixel_to_glyph_cache.obj1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ((markobj) (d->pixel_to_glyph_cache.obj2));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ((markobj) (d->color_instance_cache));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ((markobj) (d->font_instance_cache));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
87 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
88 ((markobj) (d->charset_font_cache));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
89 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ((markobj) (d->image_instance_cache));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 if (d->devmeths)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ((markobj) (d->devmeths->symbol));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 MAYBE_DEVMETH (d, mark_device, (d, markobj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 return (d->frame_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 print_device (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 struct device *d = XDEVICE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 char buf[256];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 error ("printing unreadable object #<device %s 0x%x>",
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
109 XSTRING_DATA (d->name), d->header.uid);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 sprintf (buf, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 DEVICE_TYPE_NAME (d));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 if (DEVICE_LIVE_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 write_c_string (" on ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 print_internal (DEVICE_CONNECTION (d), printcharfun, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 sprintf (buf, " 0x%x>", d->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
123 DEFINE_LRECORD_IMPLEMENTATION ("device", device,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
124 mark_device, print_device, 0, 0, 0,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
125 struct device);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 valid_device_class_p (Lisp_Object class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 return !NILP (memq_no_quit (class, Vdevice_class_list));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
133 DEFUN ("valid-device-class-p", Fvalid_device_class_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 Given a DEVICE-CLASS, return t if it is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Valid classes are 'color, 'grayscale, and 'mono.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
136 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
137 (device_class))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
139 return valid_device_class_p (device_class) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
142 DEFUN ("device-class-list", Fdevice_class_list, 0, 0, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 Return a list of valid device classes.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
144 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
145 ())
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 return Fcopy_sequence (Vdevice_class_list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 static struct device *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 allocate_device (Lisp_Object console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
153 Lisp_Object device;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
154 struct device *d = alloc_lcrecord_type (struct device, lrecord_device);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 zero_lcrecord (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 GCPRO1 (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 d->name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 d->console = console;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 d->connection = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 d->canon_connection = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 d->frame_list = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 d->_selected_frame = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 d->frame_with_focus_real = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 d->frame_with_focus_for_hooks = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 d->frame_that_ought_to_have_focus = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 d->device_class = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 d->user_defined_tags = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 d->pixel_to_glyph_cache.obj1 = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 d->pixel_to_glyph_cache.obj2 = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 d->infd = d->outfd = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 /* #### is 20 reasonable? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 d->color_instance_cache = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 HASHTABLE_EQUAL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 d->font_instance_cache = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 HASHTABLE_EQUAL);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
183 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
184 /* Note that the following table is bi-level. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
185 d->charset_font_cache = make_lisp_hashtable (20, HASHTABLE_NONWEAK,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
186 HASHTABLE_EQ);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
187 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 Note that the image instance cache is actually bi-level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 See device.h. We use a low number here because most of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 time there aren't very many diferent masks that will be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 d->image_instance_cache = make_lisp_hashtable (5, HASHTABLE_NONWEAK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 HASHTABLE_EQ);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 return d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 struct device *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 decode_device (Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 if (NILP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 device = Fselected_device (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 /* quietly accept frames for the device arg */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 if (FRAMEP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 device = FRAME_DEVICE (decode_frame (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 CHECK_LIVE_DEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 return XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
212 DEFUN ("dfw-device", Fdfw_device, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Given a device, frame, or window, return the associated device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Return nil otherwise.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
215 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
216 (obj))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 return DFW_DEVICE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
222 DEFUN ("selected-device", Fselected_device, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 Return the device which is currently active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 If optional CONSOLE is non-nil, return the device that would be currently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 active if CONSOLE were the selected console.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
226 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
227 (console))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 if (NILP (console) && NILP (Vselected_console))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 return Qnil; /* happens early in temacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 return CONSOLE_SELECTED_DEVICE (decode_console (console));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 /* Called from selected_frame_1(), called from Fselect_window() */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 select_device_1 (Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 struct device *dev = XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 Lisp_Object old_selected_device = Fselected_device (Qnil);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
240
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 if (EQ (device, old_selected_device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 /* now select the device's console */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 CONSOLE_SELECTED_DEVICE (XCONSOLE (DEVICE_CONSOLE (dev))) = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 select_console_1 (DEVICE_CONSOLE (dev));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
249 DEFUN ("select-device", Fselect_device, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 Select the device DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 Subsequent editing commands apply to its console, selected frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 and selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 The selection of DEVICE lasts until the next time the user does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 something to select a different device, or until the next time this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 function is called.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
256 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
257 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 CHECK_LIVE_DEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 /* select the device's selected frame's selected window. This will call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 selected_frame_1()->selected_device_1()->selected_console_1(). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 if (!NILP (DEVICE_SELECTED_FRAME (XDEVICE (device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Fselect_window (FRAME_SELECTED_WINDOW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 error ("Can't select a device with no frames");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 set_device_selected_frame (struct device *d, Lisp_Object frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 if (!NILP (frame) && !FRAME_MINIBUF_ONLY_P (XFRAME (frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 set_console_last_nonminibuf_frame (XCONSOLE (DEVICE_CONSOLE (d)), frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 d->_selected_frame = frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
279 DEFUN ("set-device-selected-frame", Fset_device_selected_frame, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 Set the selected frame of device object DEVICE to FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 If DEVICE is nil, the selected device is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 If DEVICE is the selected device, this makes FRAME the selected frame.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
283 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
284 (device, frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
286 XSETDEVICE (device, decode_device (device));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 CHECK_LIVE_FRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 if (! EQ (device, FRAME_DEVICE (XFRAME (frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 error ("In `set-device-selected-frame', FRAME is not on DEVICE");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 if (EQ (device, Fselected_device (Qnil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 return Fselect_frame (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 set_device_selected_frame (XDEVICE (device), frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 return frame;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
299 DEFUN ("devicep", Fdevicep, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Return non-nil if OBJECT is a device.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
301 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
302 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
304 return DEVICEP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
307 DEFUN ("device-live-p", Fdevice_live_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 Return non-nil if OBJECT is a device that has not been deleted.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
309 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
310 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
312 return DEVICEP (object) && DEVICE_LIVE_P (XDEVICE (object)) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
315 DEFUN ("device-name", Fdevice_name, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 Return the name of the specified device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 DEVICE defaults to the selected device if omitted.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
318 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
319 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 return DEVICE_NAME (decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
324 DEFUN ("device-connection", Fdevice_connection, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 Return the connection of the specified device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 DEVICE defaults to the selected device if omitted.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
327 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
328 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 return DEVICE_CONNECTION (decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
333 DEFUN ("device-console", Fdevice_console, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 Return the console of the specified device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 DEVICE defaults to the selected device if omitted.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
336 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
337 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 return DEVICE_CONSOLE (decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
263
727739f917cb Import from CVS: tag r20-5b30
cvs
parents: 229
diff changeset
342 #ifdef HAVE_WINDOW_SYSTEM
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 init_global_resources (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 init_global_faces (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 #ifdef HAVE_SCROLLBARS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 init_global_scrollbars (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 #ifdef HAVE_TOOLBARS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 init_global_toolbars (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 init_device_resources (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 init_device_faces (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 #ifdef HAVE_SCROLLBARS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 init_device_scrollbars (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 #ifdef HAVE_TOOLBARS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 init_device_toolbars (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 semi_canonicalize_device_connection (struct console_methods *meths,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Lisp_Object name, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 return CONTYPE_METH_OR_GIVEN (meths, semi_canonicalize_device_connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (name, errb), name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 canonicalize_device_connection (struct console_methods *meths,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 Lisp_Object name, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 return CONTYPE_METH_OR_GIVEN (meths, canonicalize_device_connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (name, errb), name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 find_device_of_type (struct console_methods *meths, Lisp_Object canon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Lisp_Object devcons, concons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 DEVICE_LOOP_NO_BREAK (devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 Lisp_Object device = XCAR (devcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 if (EQ (CONMETH_TYPE (meths), DEVICE_TYPE (XDEVICE (device)))
195
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
396 && internal_equal (DEVICE_CANON_CONNECTION (XDEVICE (device)),
a2f645c6b9f8 Import from CVS: tag r20-3b24
cvs
parents: 185
diff changeset
397 canon, 0))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 return device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
404 DEFUN ("find-device", Ffind_device, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 Look for an existing device attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Return the device if found; otherwise, return nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 If TYPE is specified, only return devices of that type; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 return devices of any type. (It is possible, although unlikely,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 that two devices of different types could have the same connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 name; in such a case, the first device found is returned.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
412 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
413 (connection, type))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Lisp_Object canon = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 GCPRO1 (canon);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 if (!NILP (type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 struct console_methods *conmeths = decode_console_type (type, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 canon = canonicalize_device_connection (conmeths, connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 if (UNBOUNDP (canon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 RETURN_UNGCPRO (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 RETURN_UNGCPRO (find_device_of_type (conmeths, canon));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 struct console_methods *conmeths =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Dynarr_at (the_console_type_entry_dynarr, i).meths;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 canon = canonicalize_device_connection (conmeths, connection,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 if (!UNBOUNDP (canon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 Lisp_Object device = find_device_of_type (conmeths, canon);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 if (!NILP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 RETURN_UNGCPRO (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 RETURN_UNGCPRO (Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
452 DEFUN ("get-device", Fget_device, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Look for an existing device attached to connection CONNECTION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 Return the device if found; otherwise, signal an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 If TYPE is specified, only return devices of that type; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 return devices of any type. (It is possible, although unlikely,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 that two devices of different types could have the same connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 name; in such a case, the first device found is returned.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
460 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
461 (connection, type))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 Lisp_Object device = Ffind_device (connection, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 if (NILP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 if (NILP (type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 signal_simple_error ("No such device", connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 signal_simple_error_2 ("No such device", type, connection);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 return device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
474 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
475 delete_deviceless_console (Lisp_Object console)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
476 {
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
477 if (NILP (XCONSOLE (console)->device_list))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
478 Fdelete_console (console, Qnil);
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
479 return Qnil;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
480 }
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
481
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
482 DEFUN ("make-device", Fmake_device, 2, 3, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
483 Return a new device of type TYPE, attached to connection CONNECTION.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 The valid values for CONNECTION are device-specific; however,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 CONNECTION is generally a string. (Specifically, for X devices,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 CONNECTION should be a display specification such as "foo:0", and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 for TTY devices, CONNECTION should be the filename of a TTY device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 file, such as "/dev/ttyp4", or nil to refer to XEmacs' standard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 input/output.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 PROPS, if specified, should be a plist of properties controlling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 device creation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 If CONNECTION specifies an already-existing device connection, that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 device is simply returned; no new device is created, and PROPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 have no effect.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
498 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
499 (type, connection, props))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 struct device *d;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 struct console *con;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 Lisp_Object device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 Lisp_Object console = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 Lisp_Object name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 struct console_methods *conmeths;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
508 int speccount = specpdl_depth();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 struct gcpro gcpro1, gcpro2, gcpro3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 /* #### icky-poo. If this is the first X device we are creating,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 then retrieve the global face resources. We have to do it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 here, at the same time as (or just before) the device face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 resources are retrieved; specifically, it needs to be done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 after the device has been created but before any frames have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 been popped up or much anything else has been done. It's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 possible for other devices to specify different global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 resources (there's a property on each X server's root window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 that holds some resources); tough luck for the moment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 This is a nasty violation of device independence, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 there's not a whole lot I can figure out to do about it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 The real problem is that the concept of resources is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 generalized away from X. Similar resource-related
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 device-independence violations occur in faces.el. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 int first_x_device = NILP (Vdefault_x_device) && EQ (type, Qx);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 GCPRO3 (device, console, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 conmeths = decode_console_type (type, ERROR_ME_NOT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 if (!conmeths)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 signal_simple_error ("Invalid device type", type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 device = Ffind_device (connection, type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 if (!NILP (device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 RETURN_UNGCPRO (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 name = Fplist_get (props, Qname, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 Lisp_Object conconnect =
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
544 (HAS_CONTYPE_METH_P (conmeths, device_to_console_connection)) ?
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
545 CONTYPE_METH (conmeths, device_to_console_connection,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
546 (connection, ERROR_ME)) :
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
547 connection;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 console = create_console (name, type, conconnect, props);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
551 record_unwind_protect(delete_deviceless_console, console);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
552
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 con = XCONSOLE (console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 d = allocate_device (console);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 d->devmeths = con->conmeths;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 DEVICE_NAME (d) = name;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
560 DEVICE_CONNECTION (d) =
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
561 semi_canonicalize_device_connection (conmeths, connection, ERROR_ME);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
562 DEVICE_CANON_CONNECTION (d) =
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
563 canonicalize_device_connection (conmeths, connection, ERROR_ME);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 MAYBE_DEVMETH (d, init_device, (d, props));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 /* Do it this way so that the device list is in order of creation */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 con->device_list = nconc2 (con->device_list, Fcons (device, Qnil));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 RESET_CHANGED_SET_FLAGS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 if (NILP (Vdefault_device) || DEVICE_STREAM_P (XDEVICE (Vdefault_device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 Vdefault_device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 init_device_sound (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 if (first_x_device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 init_global_resources (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 init_device_resources (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 MAYBE_DEVMETH (d, finish_init_device, (d, props));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 /* If this is the first device on the console, make it the selected one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 if (NILP (CONSOLE_SELECTED_DEVICE (con)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 CONSOLE_SELECTED_DEVICE (con) = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 /* #### the following should trap errors. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 setup_device_initial_specifier_tags (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 UNGCPRO;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 120
diff changeset
590 unbind_to(speccount, Qnil);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 return device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 /* find a device other than the selected one. Prefer non-stream
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 devices over stream devices. Maybe stay on the same console. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 find_other_device (Lisp_Object device, int on_same_console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
600 Lisp_Object devcons = Qnil, concons;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Lisp_Object console = DEVICE_CONSOLE (XDEVICE (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 /* look for a non-stream device */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 DEVICE_LOOP_NO_BREAK (devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 Lisp_Object dev = XCAR (devcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 if (on_same_console && !EQ (console, DEVICE_CONSOLE (XDEVICE (dev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 if (!DEVICE_STREAM_P (XDEVICE (dev)) && !EQ (dev, device) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 !NILP (DEVICE_SELECTED_FRAME (XDEVICE (dev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 goto double_break_1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 double_break_1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 if (!NILP (devcons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 return XCAR (devcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 /* OK, now look for a stream device */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 DEVICE_LOOP_NO_BREAK (devcons, concons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 Lisp_Object dev = XCAR (devcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 if (on_same_console && !EQ (console, DEVICE_CONSOLE (XDEVICE (dev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 if (!EQ (dev, device) && !NILP (DEVICE_SELECTED_FRAME (XDEVICE (dev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 goto double_break_2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 double_break_2:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 if (!NILP (devcons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 return XCAR (devcons);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 /* Sorry, there ain't none */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 find_nonminibuffer_frame_not_on_device_predicate (Lisp_Object frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 void *closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 VOID_TO_LISP (device, closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 if (FRAME_MINIBUF_ONLY_P (XFRAME (frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 if (EQ (device, FRAME_DEVICE (XFRAME (frame))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 find_nonminibuffer_frame_not_on_device (Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 return find_some_frame (find_nonminibuffer_frame_not_on_device_predicate,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 LISP_TO_VOID (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 /* Delete device D.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 If FORCE is non-zero, allow deletion of the only frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 If CALLED_FROM_DELETE_CONSOLE is non-zero, then, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 deleting the last device on a console, just delete it,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 instead of calling `delete-console'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 If FROM_IO_ERROR is non-zero, then the device is gone due
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 to an I/O error. This affects what happens if we exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (we do an emergency exit instead of `save-buffers-kill-emacs'.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 delete_device_internal (struct device *d, int force,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 int called_from_delete_console,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 int from_io_error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 struct console *c;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
677 Lisp_Object device;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 struct gcpro gcpro1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 /* OK to delete an already-deleted device. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 if (!DEVICE_LIVE_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 GCPRO1 (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 c = XCONSOLE (DEVICE_CONSOLE (d));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 if (!called_from_delete_console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 int delete_console = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 /* If we're deleting the only device on the console,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 delete the console. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 if ((XINT (Flength (CONSOLE_DEVICE_LIST (c))) == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 /* if we just created the device, it might not be listed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 or something ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 && !NILP (memq_no_quit (device, CONSOLE_DEVICE_LIST (c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 delete_console = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 /* Or if there aren't any nonminibuffer frames that would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 left, delete the console (this will make XEmacs exit). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 else if (NILP (find_nonminibuffer_frame_not_on_device (device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 delete_console = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 if (delete_console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 delete_console_internal (c, force, 0, from_io_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 reset_one_device (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Lisp_Object frmcons;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 /* First delete all frames without their own minibuffers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 to avoid errors coming from attempting to delete a frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 that is a surrogate for another frame. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 DEVICE_FRAME_LOOP (frmcons, d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 struct frame *f = XFRAME (XCAR (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 /* delete_frame_internal() might do anything such as run hooks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 so be defensive. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 if (FRAME_LIVE_P (f) && !FRAME_HAS_MINIBUF_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 delete_frame_internal (f, 1, 1, from_io_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 go ahead and delete anything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 /* #### This should probably be a device method but it is time for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 19.14 to go out the door. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 #ifdef HAVE_X_WINDOWS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 /* Next delete all frames which have the popup property to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 deleting a child after its parent. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 DEVICE_FRAME_LOOP (frmcons, d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 struct frame *f = XFRAME (XCAR (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 if (FRAME_LIVE_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 Lisp_Object popup = Fframe_property (XCAR (frmcons), Qpopup, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 if (!NILP (popup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 delete_frame_internal (f, 1, 1, from_io_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 go ahead and delete anything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 #endif /* HAVE_X_WINDOWS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 DEVICE_FRAME_LOOP (frmcons, d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 struct frame *f = XFRAME (XCAR (frmcons));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 /* delete_frame_internal() might do anything such as run hooks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 so be defensive. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 if (FRAME_LIVE_P (f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 delete_frame_internal (f, 1, 1, from_io_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 if (!DEVICE_LIVE_P (d)) /* make sure the delete-*-hook didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 go ahead and delete anything */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 set_device_selected_frame (d, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 /* try to select another device */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 if (EQ (device, Fselected_device (DEVICE_CONSOLE (d))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 Lisp_Object other_dev = find_other_device (device, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 if (!NILP (other_dev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 Fselect_device (other_dev);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 if (EQ (device, Vdefault_device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 Vdefault_device = find_other_device (device, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 MAYBE_DEVMETH (d, delete_device, (d));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 CONSOLE_DEVICE_LIST (c) = delq_no_quit (device, CONSOLE_DEVICE_LIST (c));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 RESET_CHANGED_SET_FLAGS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 d->devmeths = dead_console_methods;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 UNGCPRO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 /* delete a device as a result of an I/O error. Called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 an enqueued magic-eval event. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 io_error_delete_device (Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 delete_device_internal (XDEVICE (device), 1, 0, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
809 DEFUN ("delete-device", Fdelete_device, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 Delete DEVICE, permanently eliminating it from use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 Normally, you cannot delete the last non-minibuffer-only frame (you must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 second argument FORCE is non-nil, you can delete the last frame. (This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 will automatically call `save-buffers-kill-emacs'.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
815 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
816 (device, force))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 CHECK_DEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 delete_device_internal (XDEVICE (device), !NILP (force), 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
823 DEFUN ("device-frame-list", Fdevice_frame_list, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 Return a list of all frames on DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 If DEVICE is nil, the selected device will be used.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
826 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
827 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 return Fcopy_sequence (DEVICE_FRAME_LIST (decode_device (device)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
832 DEFUN ("device-class", Fdevice_class, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 Return the class (color behavior) of DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 This will be one of 'color, 'grayscale, or 'mono.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
835 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
836 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 return DEVICE_CLASS (decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
841 DEFUN ("set-device-class", Fset_device_class, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 Set the class (color behavior) of DEVICE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 CLASS should be one of 'color, 'grayscale, or 'mono.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 This is only allowed on device such as TTY devices, where the color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 behavior cannot necessarily be determined automatically.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
846 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
847 (device, class))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 if (!DEVICE_TTY_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 signal_simple_error ("Cannot change the class of this device", device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 if (!EQ (class, Qcolor) && !EQ (class, Qmono) && !EQ (class, Qgrayscale))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 signal_simple_error ("Must be color, mono, or grayscale", class);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
855 if (! EQ (DEVICE_CLASS (d), class))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
856 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
857 Lisp_Object frmcons;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
858 DEVICE_CLASS (d) = class;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
859 DEVICE_FRAME_LOOP (frmcons, d)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
860 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
861 struct frame *f = XFRAME (XCAR (frmcons));
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
862
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
863 recompute_all_cached_specifiers_in_frame (f);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
864 MARK_FRAME_FACES_CHANGED (f);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
865 MARK_FRAME_GLYPHS_CHANGED (f);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
866 MARK_FRAME_TOOLBARS_CHANGED (f);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
867 f->menubar_changed = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
868 }
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
869 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
873 DEFUN ("device-pixel-width", Fdevice_pixel_width, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 Return the width in pixels of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
875 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
876 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
879 int retval = DEVMETH_OR_GIVEN (d, device_pixel_width, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
881 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
884 DEFUN ("device-pixel-height", Fdevice_pixel_height, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 Return the height in pixels of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
886 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
887 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
890 int retval = DEVMETH_OR_GIVEN (d, device_pixel_height, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
892 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
895 DEFUN ("device-mm-width", Fdevice_mm_width, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 Return the width in millimeters of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
897 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
898 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
901 int retval = DEVMETH_OR_GIVEN (d, device_mm_width, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
903 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
906 DEFUN ("device-mm-height", Fdevice_mm_height, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 Return the height in millimeters of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
908 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
909 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
912 int retval = DEVMETH_OR_GIVEN (d, device_mm_height, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
914 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
917 DEFUN ("device-bitplanes", Fdevice_bitplanes, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 Return the number of bitplanes of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
919 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
920 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
923 int retval = DEVMETH_OR_GIVEN (d, device_bitplanes, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
925 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
928 DEFUN ("device-color-cells", Fdevice_color_cells, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 Return the number of color cells of DEVICE, or nil if unknown.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
930 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
931 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 struct device *d = decode_device (device);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
934 int retval = DEVMETH_OR_GIVEN (d, device_color_cells, (d), 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
936 return retval <= 0 ? Qnil : make_int (retval);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
939 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 Set the output baud rate of DEVICE to RATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 On most systems, changing this value will affect the amount of padding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 and other strategic decisions made during redisplay.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
943 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
944 (device, rate))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 CHECK_INT (rate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 DEVICE_BAUD_RATE (decode_device (device)) = XINT (rate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 return rate;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
953 DEFUN ("device-baud-rate", Fdevice_baud_rate, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 Return the output baud rate of DEVICE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
955 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
956 (device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 return make_int (DEVICE_BAUD_RATE (decode_device (device)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
961 Lisp_Object
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
962 domain_device_type (Lisp_Object domain)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
963 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
964 /* This cannot GC */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
965 assert (WINDOWP (domain) || FRAMEP (domain)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
966 || DEVICEP (domain) || CONSOLEP (domain));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
967
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
968 if (WINDOWP (domain))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
969 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
970 if (!WINDOW_LIVE_P (XWINDOW (domain)))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
971 return Qdead;
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
972 domain = WINDOW_FRAME (XWINDOW (domain));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
973 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
974 if (FRAMEP (domain))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
975 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
976 if (!FRAME_LIVE_P (XFRAME (domain)))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
977 return Qdead;
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
978 domain = FRAME_DEVICE (XFRAME (domain));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
979 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
980 if (DEVICEP (domain))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
981 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
982 if (!DEVICE_LIVE_P (XDEVICE (domain)))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
983 return Qdead;
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
984 domain = DEVICE_CONSOLE (XDEVICE (domain));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
985 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
986 return CONSOLE_TYPE (XCONSOLE (domain));
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
987 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
988
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
989 /*
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
990 * Determine whether window system bases window geometry on character
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
991 * or pixel counts.
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
992 * Return non-zero for pixel-based geometry, zero for character-based.
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
993 */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
994 int
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
995 window_system_pixelated_geometry (Lisp_Object domain)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
996 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
997 /* This cannot GC */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
998 Lisp_Object winsy = domain_device_type (domain);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
999 struct console_methods *meth = decode_console_type (winsy, ERROR_ME_NOT);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1000 assert (meth);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1001 return (MAYBE_INT_CONTYPE_METH (meth, device_implementation_flags, ())
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1002 & XDEVIMPF_PIXEL_GEOMETRY);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1003 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1004
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1005 DEFUN ("domain-device-type", Fdomain_device_type, 0, 1, 0, /*
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1006 Return the device type symbol for a DOMAIN, e.g. 'x or 'tty.
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1007 DOMAIN can be either a window, frame, device or console.
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1008 */
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1009 (domain))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1010 {
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1011 if (!WINDOWP (domain) && !FRAMEP (domain)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1012 && !DEVICEP (domain) && !CONSOLEP (domain))
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1013 signal_simple_error
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1014 ("Domain must be either a window, frame, device or console", domain);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1015
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1016 return domain_device_type (domain);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1017 }
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1018
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 handle_asynch_device_change (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 int old_asynch_device_change_pending = asynch_device_change_pending;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 for (i = 0; i < Dynarr_length (the_console_type_entry_dynarr); i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 if (Dynarr_at (the_console_type_entry_dynarr, i).meths->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 asynch_device_change_method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (Dynarr_at (the_console_type_entry_dynarr, i).meths->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 asynch_device_change_method) ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 /* reset the flag to 0 unless another notification occurred while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 we were processing this one. Block SIGWINCH during this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 check to prevent a possible race condition. */
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1034 #ifndef WINDOWSNT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 EMACS_BLOCK_SIGNAL (SIGWINCH);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1036 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 if (old_asynch_device_change_pending == asynch_device_change_pending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 asynch_device_change_pending = 0;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1039 #ifndef WINDOWSNT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 EMACS_UNBLOCK_SIGNAL (SIGWINCH);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
1041 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 call_critical_lisp_code (struct device *d, Lisp_Object function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 Lisp_Object object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 int old_gc_currently_forbidden = gc_currently_forbidden;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 Lisp_Object old_inhibit_quit = Vinhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 /* There's no reason to bother doing specbinds here, because if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 initialize-*-faces signals an error, emacs is going to crash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 gc_currently_forbidden = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 Vinhibit_quit = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 LOCK_DEVICE (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 /* But it's useful to have an error handler; otherwise an infinite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 loop may result. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 if (!NILP (object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 call1_with_handler (Qreally_early_error_handler, function, object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 call0_with_handler (Qreally_early_error_handler, function);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 155
diff changeset
1065
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 UNLOCK_DEVICE (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 Vinhibit_quit = old_inhibit_quit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 gc_currently_forbidden = old_gc_currently_forbidden;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 syms_of_device (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1079 DEFSUBR (Fvalid_device_class_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1080 DEFSUBR (Fdevice_class_list);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1082 DEFSUBR (Fdfw_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1083 DEFSUBR (Fselected_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1084 DEFSUBR (Fselect_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1085 DEFSUBR (Fset_device_selected_frame);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1086 DEFSUBR (Fdevicep);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1087 DEFSUBR (Fdevice_live_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1088 DEFSUBR (Fdevice_name);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1089 DEFSUBR (Fdevice_connection);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1090 DEFSUBR (Fdevice_console);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1091 DEFSUBR (Ffind_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1092 DEFSUBR (Fget_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1093 DEFSUBR (Fmake_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1094 DEFSUBR (Fdelete_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1095 DEFSUBR (Fdevice_frame_list);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1096 DEFSUBR (Fdevice_class);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1097 DEFSUBR (Fset_device_class);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1098 DEFSUBR (Fdevice_pixel_width);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1099 DEFSUBR (Fdevice_pixel_height);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1100 DEFSUBR (Fdevice_mm_width);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1101 DEFSUBR (Fdevice_mm_height);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1102 DEFSUBR (Fdevice_bitplanes);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1103 DEFSUBR (Fdevice_color_cells);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1104 DEFSUBR (Fset_device_baud_rate);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1105 DEFSUBR (Fdevice_baud_rate);
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 263
diff changeset
1106 DEFSUBR (Fdomain_device_type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 defsymbol (&Qdevicep, "devicep");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 defsymbol (&Qdevice_live_p, "device-live-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 defsymbol (&Qdelete_device, "delete-device");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 defsymbol (&Qcreate_device_hook, "create-device-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 defsymbol (&Qdelete_device_hook, "delete-device-hook");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 /* Qcolor defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 defsymbol (&Qgrayscale, "grayscale");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 defsymbol (&Qmono, "mono");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 vars_of_device (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 DEFVAR_LISP ("create-device-hook", &Vcreate_device_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 Function or functions to call when a device is created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 One argument, the newly-created device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 This is called after the first frame has been created, but before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 calling the `create-frame-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 Note that in general the device will not be selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 Vcreate_device_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 DEFVAR_LISP ("delete-device-hook", &Vdelete_device_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 Function or functions to call when a device is deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 One argument, the to-be-deleted device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 Vdelete_device_hook = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 staticpro (&Vdefault_device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 Vdefault_device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 asynch_device_change_pending = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 Vdevice_class_list = list3 (Qcolor, Qgrayscale, Qmono);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 staticpro (&Vdevice_class_list);
229
434959a2fba3 Import from CVS: tag r20-5b13
cvs
parents: 195
diff changeset
1145
434959a2fba3 Import from CVS: tag r20-5b13
cvs
parents: 195
diff changeset
1146 /* Death to devices.el !!! */
434959a2fba3 Import from CVS: tag r20-5b13
cvs
parents: 195
diff changeset
1147 Fprovide(intern("devices"));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 }