annotate src/device.c @ 14:9ee227acff29 r19-15b90

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