annotate src/epoch.c @ 44:8d2a9b52c682 r19-15prefinal

Import from CVS: tag r19-15prefinal
author cvs
date Mon, 13 Aug 2007 08:55:10 +0200
parents 859a2309aef8
children
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 /* Epoch functionality.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985-1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "console-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "objects-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "events.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 Lisp_Object Qx_property_change, Qx_client_message, Qx_map, Qx_unmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Lisp_Object Vepoch_event, Vepoch_event_handler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 /* X resources */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 Lisp_Object Qx_resource_live_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 #define XX_RESOURCE(x) XRECORD (x, x_resource, struct Lisp_X_Resource)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #define XSETX_RESOURCE(x, p) XSETRECORD (x, p, x_resource)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 #define X_RESOURCEP(x) RECORDP (x, x_resource)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #define GC_X_RESOURCEP(x) GC_RECORDP (x, x_resource)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 #define CHECK_X_RESOURCE(x) CHECK_RECORD (x, x_resource)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 #define X_RESOURCE_LIVE_P(xr) (DEVICE_LIVE_P (XDEVICE ((xr)->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #define CHECK_LIVE_X_RESOURCE(x) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 do { CHECK_X_RESOURCE (x); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 if (!X_RESOURCE_LIVE_P (XX_RESOURCE (x))) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 x = wrong_type_argument (Qx_resource_live_p, (x)); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 struct Lisp_X_Resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 struct lcrecord_header header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 XID xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Atom type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 };
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 Qx_resourcep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 static Lisp_Object mark_x_resource (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 static void print_x_resource (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 static void finalize_x_resource (void *, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 static int x_resource_equal (Lisp_Object o1, Lisp_Object o2, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 static unsigned long x_resource_hash (Lisp_Object obj, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 DEFINE_LRECORD_IMPLEMENTATION ("x-resource", x_resource,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 mark_x_resource, print_x_resource,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 finalize_x_resource, x_resource_equal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 x_resource_hash, struct Lisp_X_Resource);
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_x_resource (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 return XX_RESOURCE (obj)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 print_x_resource (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Bufbyte *default_string = "Resource";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 Lisp_Object atom_symbol;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Lisp_Object device = XX_RESOURCE (obj)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 if (!DEVICE_LIVE_P (XDEVICE (device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 error ("printing unreadable object #<dead x-resource>");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 error ("printing unreadable object #<x-resource 0x%x>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (unsigned int) XX_RESOURCE (obj)->xid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 if (!DEVICE_LIVE_P (XDEVICE (device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 write_c_string ("#<dead x-resource>", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 atom_symbol = x_atom_to_symbol (XDEVICE (device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 XX_RESOURCE (obj)->type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 sprintf (buf, "#<x-resource %s on ",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (NILP (atom_symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ? default_string
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
107 : XSTRING_DATA (Fsymbol_name (atom_symbol))));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 print_internal (device, printcharfun, escapeflag);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 sprintf (buf, " 0x%x>",(unsigned int) XX_RESOURCE (obj)->xid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 finalize_x_resource (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 x_resource_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 return (XX_RESOURCE (o1)->xid == XX_RESOURCE (o2)->xid &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 EQ (XX_RESOURCE (o1)->device, XX_RESOURCE (o2)->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 x_resource_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 return HASH2 (XX_RESOURCE (obj)->xid,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 internal_hash (XX_RESOURCE (obj)->device, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 }
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 * Epoch equivalent: epoch::resourcep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
137 DEFUN ("x-resource-p", Fx_resource_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 Return non-nil if OBJECT is an X resource object.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
139 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
140 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 return (X_RESOURCEP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
145 DEFUN ("x-resource-live-p", Fx_resource_live_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Return non-nil if OBJECT is a live X resource object.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 That means that the X resource's device is live.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
148 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
149 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 return (X_RESOURCEP (object) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 X_RESOURCE_LIVE_P (XX_RESOURCE (object)) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
155 DEFUN ("x-resource-device", Fx_resource_device, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Return the device that OBJECT (an X resource object) exists on.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
157 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
158 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 CHECK_LIVE_X_RESOURCE (object);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 return XX_RESOURCE (object)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 * Epoch equivalent: epoch::set-resource-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
167 DEFUN ("set-x-resource-type", Fset_x_resource_type, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 Set the type of RESOURCE to TYPE. The new type must be an atom.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
169 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
170 (resource, type))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 CHECK_LIVE_X_RESOURCE (resource);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 CHECK_LIVE_X_RESOURCE (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 if (XX_RESOURCE (type)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 error ("New type must be an atom");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 XX_RESOURCE (resource)->type = XX_RESOURCE (type)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 return resource;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 make_x_resource (XID xid, Atom type, Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 struct Lisp_X_Resource *xr =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 alloc_lcrecord (sizeof (struct Lisp_X_Resource), lrecord_x_resource);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 xr->xid = xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 xr->type = type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 xr->device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 XSETX_RESOURCE (val, xr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 get_symbol_or_string_as_symbol (Lisp_Object name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 retry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 if (SYMBOLP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 return name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 else if (STRINGP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 return Fintern (name, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 signal_simple_continuable_error ("Must be symbol or string",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 goto retry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 return Qnil; /* not reached */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 }
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 * Epoch equivalent: epoch::intern-atom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
217 DEFUN ("x-intern-atom", Fx_intern_atom, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Convert a string or symbol into an atom and return as an X resource.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Optional argument DEVICE specifies the display connection and defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 to the selected device.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
221 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
222 (name, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 Atom atom;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 struct device *d = decode_x_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 atom = symbol_to_x_atom (d, get_symbol_or_string_as_symbol (name), 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 return make_x_resource (atom, XA_ATOM, device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 }
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 * Epoch equivalent: epoch::unintern-atom
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
235 DEFUN ("x-atom-name", Fx_atom_name, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Return the name of an X atom resource as a string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
237 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
238 (atom))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 CHECK_LIVE_X_RESOURCE (atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 if (XX_RESOURCE (atom)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 signal_simple_error ("Resource is not an atom", atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 val = x_atom_to_symbol (XDEVICE (XX_RESOURCE (atom)->device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 XX_RESOURCE (atom)->xid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 if (NILP (val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 return Fsymbol_name (val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 * Epoch equivalent: epoch::string-to-resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
256 DEFUN ("string-to-x-resource", Fstring_to_x_resource, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Convert a numeric STRING to an X-RESOURCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 STRING is assumed to represent a 32-bit numer value. X-RESOURCE must be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 an X atom. Optional BASE argument should be a number between 2 and 36,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 specifying the base for converting STRING.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
261 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
262 (string, type, base))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 XID xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 struct Lisp_X_Resource *xr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 char *ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 int b;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 CHECK_STRING (string);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 CHECK_LIVE_X_RESOURCE (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 if (NILP (base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 b = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 CHECK_INT (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 b = XINT (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 check_int_range (b, 2, 36);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 if (XX_RESOURCE (type)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 error ("Resource must be an atom");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 xr = XX_RESOURCE (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
285 xid = (XID) strtol ((CONST char *) XSTRING_DATA (string), &ptr, b);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
287 return ((ptr == (char *) XSTRING_DATA (string))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ? Qnil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 : make_x_resource (xid, xr->xid, xr->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 }
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 * Epoch equivalent: epoch::resource-to-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
295 DEFUN ("x-resource-to-type", Fx_resource_to_type, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 Return an x-resource of type ATOM whose value is the type of the argument
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
297 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
298 (resource))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 struct Lisp_X_Resource *xr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 CHECK_LIVE_X_RESOURCE (resource);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 xr = XX_RESOURCE (resource);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 return make_x_resource (xr->type, XA_ATOM, xr->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 /* internal crap stolen from Epoch */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 static char LongToStringBuffer[33]; /* can't have statics inside functions! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 long_to_string (unsigned long n, unsigned int base)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 char *digit = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 char *s = LongToStringBuffer + 32; /* at most 33 characters in binary */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 *s = 0; /* terminate */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 while (n) /* something there */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 *--s = digit[n % base]; /* store bottom digit */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 n /= base; /* shift right */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 if (*s == 0) *--s = '0'; /* in case nothing was put in string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 return s;
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 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 * Epoch equivalent: epoch::resource-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
329 DEFUN ("x-resource-to-string", Fx_resource_to_string, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 Convert the xid of RESOURCE to a numeric string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 Optional BASE specifies the base for the conversion (2..36 inclusive)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
332 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
333 (resource, base))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 int cbase = 10;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 CHECK_LIVE_X_RESOURCE (resource);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 if (!NILP (base))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 CHECK_INT (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 cbase = XINT (base);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 check_int_range (cbase, 2, 36);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 return build_string (long_to_string (XX_RESOURCE (resource)->xid, cbase));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 * Epoch equivalent: epoch::xid-of-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
351 DEFUN ("x-id-of-frame", Fx_id_of_frame, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 Return the window ID of FRAME as an x-resource.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 This differs from `x-window-id' in that its return value is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 x-resource rather than a string.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
355 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
356 (frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 struct frame *f = decode_x_frame (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 return make_x_resource (XtWindow (FRAME_X_SHELL_WIDGET (f)), XA_WINDOW,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 FRAME_DEVICE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 /* Given a frame or ID X resource, return the X window and device
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 it refers to. If text_p is non-zero, the window returned corresponds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 to the text widget of the frame rather than the shell widget. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 epoch_get_window_and_device (Lisp_Object frame, Window *window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Lisp_Object *device, int text_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 if (X_RESOURCEP (frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 CHECK_LIVE_X_RESOURCE (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 if (XX_RESOURCE (frame)->type != XA_WINDOW)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 error ("Frame resource must be of type WINDOW");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 *window = XX_RESOURCE (frame)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 *device = XX_RESOURCE (frame)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 struct frame *f = decode_x_frame (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 XSETFRAME (frame, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 if (text_p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 *window = XtWindow (FRAME_X_TEXT_WIDGET (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 *window = XX_RESOURCE (Fx_id_of_frame (frame))->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 *device = FRAME_DEVICE (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 * Epoch equivalent: epoch::query-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
397 DEFUN ("x-query-tree", Fx_query_tree, 0, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 Return the portion of the window tree adjacent to FRAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 Return value is the list ( ROOT PARENT . CHILDREN ). The FRAME arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 can either be a frame object or an x-resource of type window.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
401 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
402 (frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 Window win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 Window root, parent, *children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 unsigned int count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 int retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 epoch_get_window_and_device (frame, &win, &device, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 retval =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 XQueryTree (DEVICE_X_DISPLAY (XDEVICE (device)), win, &root, &parent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 &children, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 /* Thank you, X-Consortium. XQueryTree doesn't return Success like everyone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 * else, it returns 1. (Success is defined to be 0 in the standard header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 * files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 if (!retval) return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 val = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 val = Fcons (make_x_resource (children[--count], XA_WINDOW, device), val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 XFree (children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 return Fcons (make_x_resource (root, XA_WINDOW, device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Fcons ((parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ? make_x_resource (parent, XA_WINDOW, device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 : Qnil),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 val));
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 /* more internal crap stolen from Epoch */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 verify_vector_has_consistent_type (Lisp_Object vector)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 int i; /* vector index */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 XID rtype; /* X_resource type (if vector of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 X_resources) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 int length; /* vector length */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 struct Lisp_Vector *v = XVECTOR (vector);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 Lisp_Object *element;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Lisp_Object sample;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Lisp_Object type_obj; /* base type of vector elements */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 sample = v->contents[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 type_obj = sample;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 if (X_RESOURCEP (sample))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 CHECK_LIVE_X_RESOURCE (sample);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 rtype = XX_RESOURCE (sample)->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 device = XX_RESOURCE (sample)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 length = v->size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 element = v->contents;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 for (i = 1; i < length; ++i, ++element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 if (X_RESOURCEP (type_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 CHECK_LIVE_X_RESOURCE (type_obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 if ((XTYPE (*element) != XTYPE (type_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 || (LRECORDP (type_obj) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (XRECORD_LHEADER (*element)->implementation !=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 XRECORD_LHEADER (type_obj)->implementation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 || (X_RESOURCEP (type_obj) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (rtype != XX_RESOURCE (*element)->type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 || !EQ (device, XX_RESOURCE (*element)->device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 error ("Vector has inconsistent types");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 verify_list_has_consistent_type (Lisp_Object list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 Lisp_Object type_obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 XID rtype; /* X_resource type (if vector of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 X_resources) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 Lisp_Object temp = Fcar (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 type_obj = temp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 if (X_RESOURCEP (temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 CHECK_LIVE_X_RESOURCE (temp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 rtype = XX_RESOURCE (temp)->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 device = XX_RESOURCE (temp)->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 list = Fcdr (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 for ( ; !NILP (list) ; list = Fcdr (list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 QUIT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 temp = Fcar (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 if (X_RESOURCEP (temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 CHECK_LIVE_X_RESOURCE (temp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 if ((XTYPE (temp) != XTYPE (type_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 || (LRECORDP (type_obj) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (XRECORD_LHEADER (temp)->implementation !=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 XRECORD_LHEADER (type_obj)->implementation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 || (X_RESOURCEP (type_obj) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (rtype != XX_RESOURCE (temp)->type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 || !EQ (device, XX_RESOURCE (temp)->device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 error ("List has inconsistent types");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 #define BYTESIZE 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 /* 16 bit types */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 typedef short int int16;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 typedef short unsigned int uint16;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 /* the Calculate functions return allocated memory that must be free'd.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 I tried to use alloca, but that fails. Sigh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 static void *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 calculate_vector_property (Lisp_Object vector, unsigned long *count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 Atom *type, int *format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 unsigned int size,tsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 struct Lisp_Vector *v;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 void *addr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 v = XVECTOR (vector);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 *count = length = v->size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 switch (XTYPE (v->contents[0]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 case Lisp_Int:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 *type = XA_INTEGER;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 if (*format != 8 && *format != 16) *format = 32;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 size = *format * length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 for ( i = 0 ; i < length ; ++i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 switch (*format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 case 32 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ((int *)addr)[i] = XINT (v->contents[i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 case 16 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ((int16 *)addr)[i] = XINT (v->contents[i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 case 8 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ((char *)addr)[i] = XINT (v->contents[i]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 case Lisp_Record:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 if (X_RESOURCEP (v->contents[0]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 CHECK_LIVE_X_RESOURCE (v->contents[0]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 size = BYTESIZE * sizeof (XID) * length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 *format = BYTESIZE * sizeof (XID);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 *type = XX_RESOURCE (v->contents[0])->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 for ( i = 0 ; i < length ; ++i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ( (XID *) addr) [i] = XX_RESOURCE (v->contents[i])->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 case Lisp_String:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 *format = BYTESIZE * sizeof (char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 *type = XA_STRING;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 for ( i=0, size=0 ; i < length ; ++i )
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
574 size += (XSTRING_LENGTH (v->contents[i]) +
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 1); /* include null */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 *count = size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 for ( i = 0 , size = 0 ; i < length ; ++i )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
580 tsize = XSTRING_LENGTH (v->contents[i]) + 1;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
581 memmove (((char *) addr), XSTRING_DATA (v->contents[i]),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 tsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 size += tsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 error ("Invalid type for conversion");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 return addr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 static void *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 calculate_list_property (Lisp_Object list, unsigned long *count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 Atom *type, int *format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 int length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 unsigned int size, tsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Lisp_Object tlist,temp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 void *addr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 *count = length = XINT (Flength (list));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 switch (XTYPE (Fcar (list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 case Lisp_Int:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 *type = XA_INTEGER;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 if (*format != 8 && *format != 16) *format = 32;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 size = *format * length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 for ( i = 0 ; i < length ; ++i, list = Fcdr (list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 switch (*format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 case 32 : ((int *)addr)[i] = XINT (Fcar (list)); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 case 16 : ((int16 *)addr)[i] = XINT (Fcar (list)); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 case 8 : ((char *)addr)[i] = XINT (Fcar (list)); break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 case Lisp_Record:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 if (X_RESOURCEP (Fcar (list)))
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 car = Fcar (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 CHECK_LIVE_X_RESOURCE (car);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 size = BYTESIZE * sizeof (XID) * length;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 *format = BYTESIZE * sizeof (XID);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 *type = XX_RESOURCE (Fcar (list))->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 for ( i = 0 ; i < length ; ++i, list = Fcdr (list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Lisp_Object carr = Fcar (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 CHECK_LIVE_X_RESOURCE (carr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ((XID *)addr)[i] = XX_RESOURCE (carr)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 case Lisp_String:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 *format = BYTESIZE * sizeof (char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 *type = XA_STRING;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 for ( i=0, size=0 , tlist=list ; i < length ; ++i, tlist = Fcdr (tlist) )
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
644 size += XSTRING_LENGTH (Fcar (tlist)) + 1; /* include null */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 addr = (void *) xmalloc (size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 *count = size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 for ( i=0, size=0, tlist=list ; i < length ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ++i , tlist = Fcdr (tlist) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 temp = Fcar (tlist);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
651 tsize = XSTRING_LENGTH (temp) + 1;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
652 memmove (((char *) addr), XSTRING_DATA (temp), tsize);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 size += tsize;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 error ("Invalid type for conversion");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 return addr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 /* Returns whether the conversion was successful or not */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 convert_elisp_to_x (Lisp_Object value, void **addr, unsigned long *count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 Atom *type, int *format, int *free_storage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 if (VECTORP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 verify_vector_has_consistent_type (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 else if (CONSP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 verify_list_has_consistent_type (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 *free_storage = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 switch (XTYPE (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 case Lisp_String:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 *format = BYTESIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 *type = XA_STRING;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
680 *count = strlen ((CONST char *) XSTRING_DATA (value)) + 1;
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
681 *addr = (void *) XSTRING_DATA (value);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 case Lisp_Int:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 *type = XA_INTEGER;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 *count = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 *free_storage = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 *addr = (void *) xmalloc (sizeof (int));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 /* This is ugly -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 * we have to deal with the possibility of different formats
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 switch (*format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 default :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 case 32 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 *format = 32;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 *((int *)(*addr)) = XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 case 16 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 *((int16 *)(*addr)) = XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 case 8 :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 *((char *)(*addr)) = XINT (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 case Lisp_Record:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 if (X_RESOURCEP (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 CHECK_LIVE_X_RESOURCE (value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 *format = sizeof (XID) * BYTESIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 *type = XX_RESOURCE (value)->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 *count = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 *addr = (void *) & (XX_RESOURCE (value)->xid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 case Lisp_Cons:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 *addr = calculate_list_property (value, count, type, format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 *free_storage = 1; /* above allocates storage */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 case Lisp_Vector:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 *addr = calculate_vector_property (value, count, type, format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 *free_storage = 1; /* above allocates storage */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 default :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 error ("Improper type for conversion");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 return 1;
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 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 format_size_hints (XSizeHints *hints)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 struct Lisp_Vector *v;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 result = Fmake_vector (make_int (6), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 v = XVECTOR (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 /* ugly but straightforward - just step through the members and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 * and stick in the ones that are there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 if (hints->flags & (PPosition|USPosition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 v->contents[0] = Fcons (make_int (hints->x), make_int (hints->y));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 if (hints->flags & (PSize|USSize))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 v->contents[1] = Fcons (make_int (hints->width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 make_int (hints->height));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 if (hints->flags & PMinSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 v->contents[2] = Fcons (make_int (hints->min_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 make_int (hints->min_height));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 if (hints->flags & PMaxSize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 v->contents[3] = Fcons (make_int (hints->max_width),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 make_int (hints->max_height));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 if (hints->flags & PResizeInc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 v->contents[4] = Fcons (make_int (hints->width_inc),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 make_int (hints->height_inc));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 if (hints->flags & PAspect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 v->contents[5] = Fcons (make_int (hints->min_aspect.x),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 Fcons (make_int (hints->min_aspect.y),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Fcons (make_int (hints->max_aspect.x),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 make_int (hints->max_aspect.y))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 format_string_property (char *buffer, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 Lisp_Object value = Qnil; /* data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 Lisp_Object temp; /* temp value holder */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 int len; /* length of current string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 char *strend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 strend = memchr (buffer, 0, (int) count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 len = strend ? strend - buffer : count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 if (len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 temp = make_string ((Bufbyte *) buffer, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 value = Fcons (temp, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 buffer = strend + 1; /* skip null, or leaving loop if no null */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 count -= len + !!strend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 : Fnreverse (value));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 format_integer_32_property (long *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 format_integer_16_property (int16 *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 format_integer_8_property (char *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 format_integer_property (void *buff, unsigned long count, int format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 switch (format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 case 8:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 return format_integer_8_property ((char *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 case 16:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 return format_integer_16_property ((int16 *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 case 32:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 return format_integer_32_property ((long *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 format_cardinal_32_property (unsigned long *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 format_cardinal_16_property (uint16 *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 format_cardinal_8_property (unsigned char *buff, unsigned long count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 while (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 value = Fcons (make_int (buff[--count]), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 format_cardinal_property (void *buff, unsigned long count, int format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 switch (format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 case 8:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 return format_cardinal_8_property ((unsigned char *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 case 16:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 return format_cardinal_16_property ((uint16 *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 case 32:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 return format_cardinal_32_property ((unsigned long *) buff, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 format_unknown_property (struct device *d, void *buff, unsigned long count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 Atom type, int format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 Lisp_Object value = Qnil; /* return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 Lisp_Object device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 switch (format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 case 32:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 XID *xid = (XID *) buff;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 int non_zero = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 while (count--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 if (non_zero || xid[count])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 value = Fcons (make_x_resource (xid[count], type, device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 non_zero = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 return (NILP (Fcdr (value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 ? Fcar (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 : value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 convert_x_to_elisp (struct device *d, void *buffer, unsigned long count,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 Atom type, int format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 Lisp_Object value = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 switch (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 case None:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 value = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 case XA_STRING:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 value = format_string_property (buffer, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 case XA_INTEGER:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 value = format_integer_property ((long *) buffer, count, format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 case XA_CARDINAL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 value = format_cardinal_property ((unsigned long *) buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 count, format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 case XA_WM_SIZE_HINTS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 value = format_size_hints ((XSizeHints *) buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 value = format_unknown_property (d, (void *) buffer, count, type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 /* get a property given its atom, device, and window */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 raw_get_property (struct device *d, Window win, Atom prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 Lisp_Object value = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 Atom actual_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 int actual_format;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 unsigned char *buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 unsigned long count, remaining;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 int zret;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 Display *dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 zret = XGetWindowProperty (dpy, win, prop,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 0L, 1024L, False, AnyPropertyType,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 &actual_type, &actual_format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 &count, &remaining, &buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 /* If remaining is set, then there's more of the property to get.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 Let's just do the whole read again, this time with enough space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 to get it all. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 if (zret == Success && remaining > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 XFree (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 zret = XGetWindowProperty (dpy, win, prop,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 0L, 1024L + ((remaining + 3) / 4),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 False, AnyPropertyType,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 &actual_type, &actual_format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 &count, &remaining, &buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 if (zret != Success)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 return Qnil; /* failed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 value = convert_x_to_elisp (d, buffer, count, actual_type, actual_format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 XFree (buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 * Epoch equivalent: epoch::get-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1020 DEFUN ("x-get-property", Fx_get_property, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 Retrieve the X window property for a frame. Arguments are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 PROPERTY: must be a string or an X-resource of type ATOM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 FRAME: (optional) If present, must be a frame object, a frame id, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 and X-resource of type WINDOW. Defaults to the current frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 Returns the value of the property, or nil if the property couldn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 be retrieved.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1027 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1028 (name, frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 Atom prop = None;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 Window win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 /* We can't use Fx_id_of_frame because it returns the xid of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 the shell widget. But the property change has to take place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 on the edit widget in order for a PropertyNotify event to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 be generated */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 epoch_get_window_and_device (frame, &win, &device, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 dpy = DEVICE_X_DISPLAY (XDEVICE (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 if (STRINGP (name) || SYMBOLP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 prop = symbol_to_x_atom (XDEVICE (device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 get_symbol_or_string_as_symbol (name),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 else if (X_RESOURCEP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 CHECK_LIVE_X_RESOURCE (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 if (XX_RESOURCE (name)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 error ("Property must be an ATOM X-resource");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 prop = XX_RESOURCE (name)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 error ("Property must be a string or X-resource ATOM");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 if (prop == None)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 /* now we have the atom, let's ask for the property! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 return raw_get_property (XDEVICE (device), win, prop);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 raw_set_property (Display *dpy, Window win, Atom prop, Lisp_Object value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 Atom actual_type; /* X type of items */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 int actual_format; /* size of data items (8,16,32) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 unsigned long count; /* Number of data items */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 void* addr; /* address of data item array */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 int zret; /* X call return value */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 int free_storage; /* set if addr points at non-malloc'd store */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 actual_format = 0; /* don't force a particular format */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 convert_elisp_to_x (value, &addr, &count, &actual_type, &actual_format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 &free_storage);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 zret = XChangeProperty (dpy, win, prop, actual_type, actual_format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 PropModeReplace, (char *) addr, count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 XFlush (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 if (free_storage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 xfree (addr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 return value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1090 DEFUN ("x-set-property", Fx_set_property, 2, 3, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 Set a named property for a frame. The first argument (required)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 is the name of the property. The second is the value to set the propery
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 to. The third (optional) is the frame, default is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 the current frame.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1095 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1096 (name, value, frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 Atom prop = None; /* name of the property */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 Lisp_Object device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 Window win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 /* We can't use Fx_id_of_frame because it returns the xid of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 the shell widget. But the property change has to take place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 on the edit widget in order for a PropertyNotify event to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 be generated */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 epoch_get_window_and_device (frame, &win, &device, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 dpy = DEVICE_X_DISPLAY (XDEVICE (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 /* parse the atom name, either a string or an actual atom */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 if (STRINGP (name) || SYMBOLP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 prop = symbol_to_x_atom (XDEVICE (device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 get_symbol_or_string_as_symbol (name),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 else if (X_RESOURCEP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 CHECK_LIVE_X_RESOURCE (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 if (XX_RESOURCE (name)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 error ("Property must be an X-resource ATOM");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 prop = XX_RESOURCE (name)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 error ("Property must be a string or X-resource ATOM");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 if (prop == None)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 /* that's it. Now set it */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 return raw_set_property (dpy, win, prop, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 * Epoch equivalent: epoch::send-client-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 */
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1137 DEFUN ("x-send-client-message", Fx_send_client_message, 1, 5, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 Send a client message to DEST, marking it as being from SOURCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 The message is DATA of TYPE with FORMAT. If TYPE and FORMAT are omitted,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 they are deduced from DATA. If SOURCE is nil, the current frame is used.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1141 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1142 (dest, source, data, type, format))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 int actual_format = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 Atom actual_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 unsigned long count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 void *addr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 int free_storage;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 XEvent ev;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 Window dest_win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 Lisp_Object dest_device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 Window src_win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 Lisp_Object src_device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 epoch_get_window_and_device (dest, &dest_win, &dest_device, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 if (NILP (source))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 /* This catches a return of nil */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 XSETFRAME (source, device_selected_frame (XDEVICE (dest_device)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 epoch_get_window_and_device (source, &src_win, &src_device, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 if (!EQ (src_device, dest_device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 error ("Destination and source must be on the same device");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 dpy = DEVICE_X_DISPLAY (XDEVICE (dest_device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ev.xclient.window = src_win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 /* check format before data, because it can cause the data format to vary */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 if (!NILP (format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 CHECK_INT (format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 actual_format = XINT (format);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 if (actual_format != 8 && actual_format != 16 && actual_format != 32)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 error ("Format must be 8, 16, or 32, or nil");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 /* clear out any cruft */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 memset ((char *) &ev.xclient.data, 0, 20);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 /* look for the data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 if (!NILP (data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 convert_elisp_to_x (data, &addr, &count, &actual_type, &actual_format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 &free_storage);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 if ((count * actual_format) > 20*8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 if (free_storage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 xfree (addr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 error ("Data is too big to fit in a client message");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 memmove (&ev.xclient.data, (char *)addr, count * (actual_format/8));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 if (free_storage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 xfree (addr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 if (!NILP (type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 CHECK_LIVE_X_RESOURCE (type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 if (XX_RESOURCE (type)->type != XA_ATOM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 error ("Resource for message type must be an atom");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 actual_type = XX_RESOURCE (type)->xid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ev.xany.type = ClientMessage;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 ev.xclient.message_type = actual_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 ev.xclient.format = actual_format;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 /* There's no better way to set the mask than to hard code the correct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 * width bit pattern. 1L<<24 == OwnerGrabButtonMask, is the largest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 * This is the word from the X-consortium.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 result = (XSendEvent (dpy, dest_win, False, (1L<<25)-1L,&ev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 ? Qt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 XFlush (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 * These duplicate the needed functionality from the Epoch event handler.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 read_client_message (struct device *d, XClientMessageEvent *cm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 Lisp_Object result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 Lisp_Object device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 XSETDEVICE (device, d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 if (!cm->format) /* this is probably a sign of a bug somewhere else */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 result = Fcons (make_x_resource (cm->message_type, XA_ATOM, device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 Fcons (make_x_resource (cm->window, XA_WINDOW, device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 convert_x_to_elisp (d, (void *) cm->data.b,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (20*8)/cm->format,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 cm->message_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 cm->format)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 read_property_event (XPropertyEvent *pe, Lisp_Object frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 Lisp_Object result, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 struct frame *f = XFRAME (frame);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 struct device *d = XDEVICE (FRAME_DEVICE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 Lisp_Object atom;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 atom = x_atom_to_symbol (d, pe->atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 /* didn't get a name, blow this one off */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 if (NILP (atom))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 /* We can't use Fx_id_of_frame because it returns the xid of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 the shell widget. But the property change has to take place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 on the edit widget in order for a PropertyNotify event to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 be generated */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 value = raw_get_property (d, XtWindow (FRAME_X_TEXT_WIDGET (f)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 pe->atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 result = Fcons (Fsymbol_name (atom), value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 void dispatch_epoch_event (struct frame *f, XEvent *event, Lisp_Object type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 dispatch_epoch_event (struct frame *f, XEvent *event, Lisp_Object type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 /* This function can GC */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 struct Lisp_Vector *evp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 struct device *d = XDEVICE (FRAME_DEVICE (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 if (NILP (Vepoch_event_handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 if (!VECTORP (Vepoch_event) || XVECTOR (Vepoch_event)->size < 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 Vepoch_event = Fmake_vector (make_int (3), Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 evp = XVECTOR (Vepoch_event);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 XSETFRAME (evp->contents[2], f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 if (EQ (type, Qx_property_change))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 evp->contents[0] = Qx_property_change;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 evp->contents[1] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 read_property_event (&event->xproperty, evp->contents[2]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 else if (EQ (type, Qx_client_message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 evp->contents[0] = Qx_client_message;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 evp->contents[1] = read_client_message (d, &event->xclient);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 else if (EQ (type, Qx_map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 evp->contents[0] = Qx_map;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 evp->contents[1] = Qt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 else if (EQ (type, Qx_unmap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 evp->contents[0] = Qx_unmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 evp->contents[1] = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 Vepoch_event = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 if (NILP (Vepoch_event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 Ffuncall (1, &Vepoch_event_handler);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 Vepoch_event = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 syms_of_epoch (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1327 DEFSUBR (Fx_intern_atom);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1328 DEFSUBR (Fx_atom_name);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1329 DEFSUBR (Fstring_to_x_resource);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1330 DEFSUBR (Fx_resource_to_type);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1331 DEFSUBR (Fx_resource_to_string);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1332 DEFSUBR (Fx_id_of_frame);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1333 DEFSUBR (Fx_query_tree);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1334 DEFSUBR (Fx_get_property);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1335 DEFSUBR (Fx_set_property);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1336 DEFSUBR (Fx_send_client_message);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1337 DEFSUBR (Fx_resource_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1338 DEFSUBR (Fx_resource_device);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1339 DEFSUBR (Fx_resource_live_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
1340 DEFSUBR (Fset_x_resource_type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 defsymbol (&Qx_resourcep, "x-resource-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 defsymbol (&Qx_resource_live_p, "x-resource-live-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 defsymbol (&Qx_property_change, "x-property-change");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 defsymbol (&Qx_client_message, "x-client-message");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 defsymbol (&Qx_map, "x-map");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 defsymbol (&Qx_unmap, "x-unmap");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 vars_of_epoch (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 Fprovide (intern ("epoch"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 DEFVAR_LISP ("epoch-event-handler", &Vepoch_event_handler /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 If this variable is not nil, then it is assumed to have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 a function in it. When an epoch event is received for a frame, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 function is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 Vepoch_event_handler = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 DEFVAR_LISP ("epoch-event", &Vepoch_event /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 Bound to the value of the current event when epoch-event-handler is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 Vepoch_event = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 }