author | Claus Gittinger <cg@exept.de> |
Mon, 19 Jan 1998 20:13:02 +0100 | |
changeset 1990 | 201f8ecfdad3 |
parent 1979 | 1cfb8e10e258 |
child 1995 | 1ff668145d23 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1344 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
DeviceWorkstation subclass:#XWorkstation |
|
1344 | 14 |
instanceVariableNames:'screen hasShapeExtension hasShmExtension hasDPSExtension |
15 |
hasMbufExtension hasXVideoExtension hasSaveUnder hasPEXExtension |
|
16 |
hasImageExtension hasInputExtension ignoreBackingStore blackpixel |
|
17 |
whitepixel protocolsAtom deleteWindowAtom saveYourselfAtom |
|
18 |
quitAppAtom primaryAtom secondaryAtom cutBuffer0Atom stringAtom |
|
1535 | 19 |
lengthAtom wmStateAtom listOfXFonts buttonsPressed eventRootX |
20 |
eventRootY displayName eventTrace dispatchingExpose rgbVisual |
|
21 |
virtualRootId rootId eventBuffer altModifierMask metaModifierMask |
|
1978 | 22 |
multiClickTime deviceErrorSignal deviceIOErrorSignal |
23 |
deviceIOTimeoutErrorSignal' |
|
1344 | 24 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
25 |
poolDictionaries:'' |
|
26 |
category:'Interface-Graphics' |
|
295 | 27 |
! |
0 | 28 |
|
78 | 29 |
!XWorkstation primitiveDefinitions! |
0 | 30 |
%{ |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
31 |
|
1062 | 32 |
#ifdef LINUX |
33 |
# define SHM |
|
34 |
#endif |
|
35 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
36 |
#define COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
37 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
38 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
39 |
static int __cnt_color = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
40 |
static int __cnt_bitmap = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
41 |
static int __cnt_view = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
42 |
static int __cnt_gc = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
43 |
static int __cnt_cursor = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
44 |
static int __cnt_font = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
45 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
46 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
47 |
|
46 | 48 |
/* |
49 |
* x does a typedef Time - I need Object Time ... |
|
50 |
*/ |
|
0 | 51 |
#define Time XTime |
52 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
53 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
54 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
55 |
* we are lucky - the ST/X True/False are not needed |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
56 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
57 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
58 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
59 |
|
37 | 60 |
#ifdef memset |
61 |
# undef memset |
|
62 |
#endif |
|
63 |
||
1891 | 64 |
#ifdef __openVMS__ |
65 |
# undef __new |
|
66 |
#endif |
|
67 |
||
0 | 68 |
#include <stdio.h> |
69 |
#include <X11/Xlib.h> |
|
70 |
#include <X11/Xutil.h> |
|
71 |
#include <X11/Xatom.h> |
|
72 |
||
150 | 73 |
#define XK_MISCELLANY |
74 |
#include <X11/keysymdef.h> |
|
75 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
76 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
77 |
|
1974 | 78 |
#ifdef LINUX |
79 |
# include <sys/socket.h> |
|
80 |
#endif |
|
81 |
||
90 | 82 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
83 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
84 |
* TrueColor systems - I am not certain, if this is |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
85 |
* always legal to do (it works with XFree servers). |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
86 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
87 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
88 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
89 |
/* |
0 | 90 |
* shape support works; enabled by -DSHAPE in makefile |
91 |
* see RoundClock and RoundGlobe examples |
|
92 |
*/ |
|
93 |
#ifdef SHAPE |
|
94 |
# include <X11/extensions/shape.h> |
|
95 |
#endif |
|
96 |
||
97 |
/* |
|
150 | 98 |
* shared memory extension access is currently not supported |
0 | 99 |
* (only query is implemented) |
100 |
*/ |
|
101 |
#ifdef SHM |
|
102 |
# include <X11/extensions/XShm.h> |
|
103 |
#endif |
|
104 |
||
105 |
/* |
|
150 | 106 |
* multiBuffer extension access is currently not supported |
107 |
* (only query is implemented) |
|
108 |
*/ |
|
109 |
#ifdef MBUF |
|
110 |
# include <X11/extensions/multibuf.h> |
|
111 |
#endif |
|
112 |
||
113 |
/* |
|
114 |
* XVideo extension access is currently not supported |
|
115 |
* (only query is implemented) |
|
116 |
*/ |
|
117 |
#ifdef XVIDEO |
|
118 |
# include <X11/extensions/Xv.h> |
|
119 |
#endif |
|
120 |
||
121 |
/* |
|
186 | 122 |
* PEX extension - if available |
123 |
*/ |
|
124 |
#ifdef PEX5 |
|
125 |
# include <PEX5/PEX.h> |
|
126 |
#endif |
|
127 |
||
128 |
/* |
|
129 |
* XImage extension - if available |
|
130 |
*/ |
|
131 |
#ifdef XIE |
|
132 |
# include <X11/extensions/XIE.h> |
|
133 |
#endif |
|
134 |
||
135 |
/* |
|
90 | 136 |
* when I have more time to check it out, I will support display-PS |
0 | 137 |
*/ |
138 |
#ifdef DPS |
|
139 |
# ifdef sgi |
|
140 |
# include <X11/extensions/XDPS.h> |
|
141 |
# include <X11/extensions/XDPSlib.h> |
|
142 |
# include <X11/extensions/dpsXclient.h> |
|
143 |
# else |
|
144 |
# include <DPS/XDPS.h> |
|
145 |
# include <DPS/XDPSlib.h> |
|
146 |
# include <DPS/dpsXclient.h> |
|
147 |
# endif |
|
148 |
#endif |
|
149 |
||
1898 | 150 |
#if defined(someMachine) |
151 |
/* |
|
152 |
* if nformats cannot be found in the Display structure ... |
|
153 |
*/ |
|
154 |
# define NO_PRIVATE_DISPLAY_ACCESS |
|
155 |
#endif |
|
156 |
||
157 |
#if defined(IRIX5) || defined(__VMS) || (XlibSpecificationRelease == 6) |
|
90 | 158 |
/* |
159 |
* accessing private data in Display ... sorry |
|
160 |
*/ |
|
161 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
162 |
#else |
|
163 |
# define DISPLAYACCESS(d) d |
|
164 |
#endif |
|
165 |
||
78 | 166 |
/* |
167 |
* some defines - tired of typing ... |
|
168 |
*/ |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
169 |
#define _DisplayVal(o) (Display *)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
170 |
#define _WindowVal(o) (Window)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
171 |
#define _PixmapVal(o) (Pixmap)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
172 |
#define _GCVal(o) (GC)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
173 |
#define _CursorVal(o) (Cursor)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
174 |
#define _FontVal(o) (XFontStruct *)(__externalAddressVal(o)) |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
175 |
#define _DPSContextVal(o) (DPSContext)(__externalAddressVal(o)) |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
176 |
|
211 | 177 |
#define __MKATOMOBJ(a) __MKSMALLINT(a) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
178 |
#define _AtomVal(o) __intVal(o) |
211 | 179 |
#define __isAtomID(o) __isSmallInteger(o) |
180 |
||
555 | 181 |
#define myDpy _DisplayVal(__INST(displayId)) |
182 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 183 |
|
184 |
#ifndef THISCONTEXT_IN_REGISTER |
|
1098 | 185 |
|
78 | 186 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
187 |
# define END_INTERRUPTSBLOCKED /* */ |
|
1098 | 188 |
|
78 | 189 |
#else |
1098 | 190 |
|
78 | 191 |
# define BEGIN_INTERRUPTSBLOCKED \ |
192 |
{ \ |
|
1344 | 193 |
int needUnblock = 0; \ |
194 |
\ |
|
195 |
__BEGIN_PROTECT_REGISTERS__ \ |
|
196 |
if (!__interruptsBlocked) { \ |
|
197 |
__BLOCKINTERRUPTS(); \ |
|
198 |
needUnblock = 1; \ |
|
199 |
} |
|
78 | 200 |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
201 |
# define END_INTERRUPTSBLOCKED_NOW \ |
1344 | 202 |
__END_PROTECT_REGISTERS__ \ |
203 |
if (needUnblock) { \ |
|
204 |
__UNBLOCKINTERRUPTS(); \ |
|
205 |
} \ |
|
78 | 206 |
} |
207 |
||
1103
8378530a4e8d
XShmQueryExtension -> XQueryExtension
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
208 |
# define END_INTERRUPTSBLOCKED \ |
1344 | 209 |
__END_PROTECT_REGISTERS__ |
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
210 |
|
78 | 211 |
#endif |
1891 | 212 |
|
213 |
#ifdef __VMS__ |
|
1899 | 214 |
# include "vms_Xnames.h" |
1891 | 215 |
#endif |
216 |
||
1974 | 217 |
#ifdef LINUX |
218 |
# define DEFAULT_XLIB_TIMEOUT 200 /* in 50ms ticks */ |
|
219 |
static __xlibTimeout__ = DEFAULT_XLIB_TIMEOUT; |
|
220 |
# define ENTER_XLIB() \ |
|
221 |
{ \ |
|
222 |
__blockingPrimitiveTimoutHandler__ = (VOIDFUNC)__XTimeoutErrorHandler; \ |
|
223 |
__blockingPrimitiveTimeoutArg__ = (INT)self; \ |
|
224 |
__blockingPrimitiveTimeout__ = __xlibTimeout__; \ |
|
225 |
} |
|
226 |
# define LEAVE_XLIB() \ |
|
227 |
{ \ |
|
228 |
__blockingPrimitiveTimeout__ = 0; \ |
|
229 |
} |
|
230 |
#else |
|
231 |
# define ENTER_XLIB() /* as nothing */ |
|
232 |
# define LEAVE_XLIB() /* as nothing */ |
|
233 |
#endif |
|
234 |
||
78 | 235 |
%} |
236 |
! ! |
|
237 |
||
238 |
!XWorkstation primitiveVariables! |
|
239 |
%{ |
|
0 | 240 |
/* |
146 | 241 |
* remembered info from private error handler |
0 | 242 |
*/ |
1974 | 243 |
static char lastErrorMsg[128] = ""; |
1888 | 244 |
static unsigned INT lastRequestCode = 0; |
245 |
static unsigned INT lastMinorCode = 0; |
|
246 |
static unsigned INT lastResource = 0; |
|
129 | 247 |
|
248 |
static int __debug__ = 0; |
|
249 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 250 |
%} |
251 |
! ! |
|
252 |
||
253 |
!XWorkstation primitiveFunctions! |
|
254 |
%{ |
|
1062 | 255 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
256 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
257 |
* some systems need a dummy reference to force the linker |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
258 |
* to include that stuff. Should be #ifdef'd ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
259 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
260 |
#ifndef ELF |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
261 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
262 |
# ifdef __GNUC__ |
1081 | 263 |
VOLATILE |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
264 |
# endif |
1081 | 265 |
static |
1062 | 266 |
dummyToForceLoading() { |
1344 | 267 |
XCreateSimpleWindow(0, 0, 0, 0, 0, 0, 0, 0, 0); |
268 |
XCloseDisplay(0); |
|
269 |
XCreateImage(0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0); |
|
270 |
XSetWindowColormap(0, 0, 0); |
|
271 |
XQueryColors(0,0,0,0); |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
272 |
# ifdef SHM |
1344 | 273 |
XShmAttach(0, 0); |
274 |
XShmCreateImage(0, 0, 0, 0, 0, 0, 0 ,0); |
|
275 |
XShmDetach(0, 0); |
|
276 |
XShmPutImage(0, 0, 0, 0 , 0,0,0,0,0,0,0); |
|
277 |
shmctl(0,0,0); |
|
278 |
fgetc(0); |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
279 |
# endif |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
280 |
} |
1062 | 281 |
#endif |
282 |
||
18 | 283 |
/* |
144 | 284 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
285 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 286 |
* the implementation below is somewhat wrong: it will |
78 | 287 |
* report all errors for Display, even though there could be |
162 | 288 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
289 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 290 |
*/ |
1974 | 291 |
int |
12 | 292 |
__XErrorHandler__(dpy, event) |
0 | 293 |
Display *dpy; |
294 |
XErrorEvent *event; |
|
295 |
{ |
|
1974 | 296 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 127); |
297 |
lastErrorMsg[127] = '\0'; |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
298 |
|
0 | 299 |
if (lastErrorMsg[0] == '\0') { |
1344 | 300 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 301 |
} |
2 | 302 |
lastRequestCode = event->request_code; |
303 |
lastMinorCode = event->minor_code; |
|
304 |
lastResource = event->resourceid; |
|
911 | 305 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
1344 | 306 |
/* |
307 |
* this is a BadWindow error for X_DestroyWindow. |
|
308 |
* ignore it here, since it results from the GC freeing windows |
|
309 |
* in non bottom-up window order. |
|
310 |
*/ |
|
311 |
return 0; |
|
911 | 312 |
} |
2 | 313 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
314 |
if (@global(ErrorPrinting) == true) { |
1753 | 315 |
fprintf(stderr, "XWorkstation [error]: x-error caught maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
1344 | 316 |
event->request_code, event->request_code, |
317 |
event->minor_code, event->minor_code, event->resourceid); |
|
1974 | 318 |
fprintf(stderr, "XWorkstation [error]: x-error message is [%d] '%s'\n", |
319 |
event->error_code, lastErrorMsg); |
|
320 |
} |
|
321 |
||
1990 | 322 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKEXTERNALADDRESS(dpy)); |
0 | 323 |
return 0; |
324 |
} |
|
325 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
326 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
327 |
* much like the above, but for IO Errors; |
1974 | 328 |
* forwarded as errorInterrupt:#DisplayIOError, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
329 |
* In single display apps, handling those here does not |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
330 |
* really make sense (except, for a controlled cleanup). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
331 |
* However, in multiDisplay apps, a single broken |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
332 |
* connection should not affect the other users. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
333 |
*/ |
1974 | 334 |
int |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
335 |
__XIOErrorHandler__(dpy) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
336 |
Display *dpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
337 |
{ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
338 |
if (@global(ErrorPrinting) == true) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
339 |
fprintf(stderr, "XWorkstation [error]: I/O error\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
340 |
} |
1974 | 341 |
__immediateErrorInterruptWithIDAndParameter__(@symbol(DisplayIOError), |
342 |
__MKEXTERNALADDRESS(dpy)); |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
343 |
__internalError("unhandled display I/O error"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
344 |
__terminateProcess(0); /* soft terminate */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
345 |
__terminateProcess(1); /* hard terminate */ |
1974 | 346 |
/* never reached */ |
347 |
return 0; |
|
348 |
} |
|
349 |
||
350 |
/* |
|
351 |
* timeout error in case of Xlib request timeout. |
|
352 |
* forwarded as errorInterrupt:#DisplayIOTimeoutError, |
|
353 |
* This is generated synthetically by the VM if the |
|
354 |
* timeoutHandler has been set. |
|
355 |
*/ |
|
356 |
void |
|
357 |
__XTimeoutErrorHandler(displayDeviceInst) |
|
358 |
OBJ displayDeviceInst; |
|
359 |
{ |
|
360 |
if (@global(ErrorPrinting) == true) { |
|
361 |
fprintf(stderr, "XWorkstation [error]: I/O request timeout dpy=%x\n", displayDeviceInst); |
|
362 |
} |
|
363 |
/* |
|
364 |
* must immediately flush that displays deviceID - otherwise, |
|
365 |
* the scheduler may try to ask for pending events without a watchdog |
|
366 |
* timer ... |
|
367 |
*/ |
|
1990 | 368 |
__OINST(displayDeviceInst, displayId) = nil; |
369 |
||
370 |
__immediateErrorInterruptWithIDAndParameter__(@symbol(DisplayIOTimeoutError), displayDeviceInst); |
|
1974 | 371 |
__internalError("unhandled display Timeout error"); |
1990 | 372 |
|
1974 | 373 |
__terminateProcess(0); /* soft terminate */ |
374 |
__terminateProcess(1); /* hard terminate */ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
375 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
376 |
|
90 | 377 |
#ifdef VIRTUAL_ROOT |
0 | 378 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
379 |
* added since RootWindow-macro is not sufficient |
18 | 380 |
* when virtual root-windows are involved (i.e. tvtwm) |
381 |
*/ |
|
382 |
static Window |
|
383 |
getRootWindow(dpy, screen) |
|
384 |
Display *dpy; |
|
385 |
{ |
|
386 |
Window root; |
|
387 |
Atom vRootAtom = None; |
|
388 |
int i; |
|
389 |
Window rootReturn, parentReturn; |
|
1050
b2c03e24d56c
another memoryLeak, due to an ommited XFree
Claus Gittinger <cg@exept.de>
parents:
1049
diff
changeset
|
390 |
Window* children = (Window *)0; |
18 | 391 |
unsigned int numChildren; |
392 |
||
393 |
root = RootWindow(dpy, screen); |
|
394 |
/* |
|
395 |
* on IRIS, this creates a badwindow error - why ? |
|
396 |
* children contains a funny window (000034) |
|
397 |
*/ |
|
90 | 398 |
# if !defined(IRIS) || defined(IRIX5) |
1887 | 399 |
if (root) { |
1906 | 400 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
1887 | 401 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
402 |
if (vRootAtom != None) { |
|
1906 | 403 |
for (i=0; i < numChildren; i++) { |
1887 | 404 |
Atom actual_type; |
405 |
int actual_format; |
|
406 |
unsigned long nitems, bytesafter; |
|
407 |
Window* newRoot = (Window*) 0; |
|
408 |
||
409 |
if (children[i]) { |
|
1906 | 410 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
1887 | 411 |
0L, 1L, False, XA_WINDOW, |
412 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
413 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
414 |
root = *newRoot; |
|
415 |
XFree(newRoot); /* XXX */ |
|
416 |
break; |
|
1906 | 417 |
} |
1344 | 418 |
} |
1906 | 419 |
} |
1344 | 420 |
} |
1887 | 421 |
if (children) XFree( children ); |
422 |
} |
|
18 | 423 |
} |
90 | 424 |
# endif |
18 | 425 |
return root; |
426 |
} |
|
90 | 427 |
#endif |
0 | 428 |
%} |
78 | 429 |
! ! |
0 | 430 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
431 |
!XWorkstation class methodsFor:'documentation'! |
295 | 432 |
|
433 |
copyright |
|
434 |
" |
|
435 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1344 | 436 |
All Rights Reserved |
295 | 437 |
|
438 |
This software is furnished under a license and may be used |
|
439 |
only in accordance with the terms of that license and with the |
|
440 |
inclusion of the above copyright notice. This software may not |
|
441 |
be provided or otherwise made available to, or used by, any |
|
442 |
other person. No title to or ownership of the software is |
|
443 |
hereby transferred. |
|
444 |
" |
|
445 |
! |
|
446 |
||
447 |
documentation |
|
448 |
" |
|
449 |
this class provides the interface to X11. It redefines all required methods |
|
450 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
451 |
limited to one display - in theory, you can create Views on many displays |
|
452 |
simultanously. However, the default setup is for one display only. |
|
453 |
To support multiple displays, you will have to start another event dispatcher |
|
454 |
process for the other display(s) and create the other views with a slightly |
|
455 |
different protocol. However, 'normal' applications do not have to care for |
|
456 |
all of this ... |
|
457 |
||
458 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 459 |
|
460 |
[author:] |
|
1344 | 461 |
Claus Gittinger |
295 | 462 |
" |
463 |
! ! |
|
464 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
465 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
466 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
467 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
468 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
469 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
470 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
471 |
|
386 | 472 |
RawKeysymTranslation isNil ifTrue:[ |
1344 | 473 |
"/ the following table maps X-keyevents to ST/X |
474 |
"/ device independed events. |
|
475 |
"/ It is NOT meant as a keyboardMap replacement. |
|
476 |
||
477 |
RawKeysymTranslation := d := Dictionary new. |
|
478 |
d at:'Delete_line' put:#DeleteLine. |
|
479 |
d at:'Delete_word' put:#DeleteWord. |
|
480 |
d at:'Down' put:#CursorDown. |
|
481 |
d at:'Up' put:#CursorUp. |
|
482 |
d at:'Left' put:#CursorLeft. |
|
483 |
d at:'Right' put:#CursorRight. |
|
386 | 484 |
] |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
485 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
486 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
487 |
!XWorkstation class methodsFor:'error handling'! |
2 | 488 |
|
129 | 489 |
debug:aBoolean |
490 |
%{ /* NOCONTEXT */ |
|
491 |
||
492 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
493 |
%} |
|
494 |
! |
|
495 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
496 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
497 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
498 |
#ifdef COUNT_RESOURCES |
1404 | 499 |
printf("colors:%d bitmaps:%d views:%d gc:%d cursors:%d fonts:%d\n", |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
500 |
__cnt_color, __cnt_bitmap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
501 |
__cnt_view, __cnt_gc, __cnt_cursor, __cnt_font); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
502 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
503 |
%} |
1404 | 504 |
|
505 |
" |
|
506 |
XWorkstation debugResources |
|
507 |
" |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
508 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
509 |
|
78 | 510 |
errorStringOfLastError |
511 |
%{ |
|
1065
fdc5b9059d82
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
512 |
RETURN ( __MKSTRING(lastErrorMsg) ); |
78 | 513 |
%} |
514 |
! |
|
515 |
||
135 | 516 |
lastErrorString |
2 | 517 |
"return the last X-error string - |
518 |
when buffering is on, this may be |
|
519 |
an error for a long-ago operation" |
|
78 | 520 |
|
521 |
|string requestCode s match line| |
|
522 |
||
523 |
string := self errorStringOfLastError. |
|
524 |
requestCode := self requestCodeOfLastError. |
|
525 |
" |
|
526 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
527 |
and append the name of the corresponding X-request |
|
528 |
" |
|
529 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
530 |
s notNil ifTrue:[ |
|
1344 | 531 |
match := 'XRequest.' , requestCode printString. |
532 |
line := s peekForLineStartingWith:match. |
|
533 |
line notNil ifTrue:[ |
|
534 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
535 |
]. |
|
536 |
s close. |
|
78 | 537 |
]. |
538 |
^ string |
|
295 | 539 |
! |
540 |
||
541 |
minorCodeOfLastError |
|
542 |
%{ /* NOCONTEXT */ |
|
543 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
544 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 545 |
%} |
546 |
! |
|
547 |
||
548 |
requestCodeOfLastError |
|
152 | 549 |
%{ /* NOCONTEXT */ |
550 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
551 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 552 |
%} |
135 | 553 |
! |
554 |
||
295 | 555 |
resourceIdOfLastError |
0 | 556 |
%{ /* NOCONTEXT */ |
295 | 557 |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
558 |
RETURN ( __MKEXTERNALADDRESS(lastResource) ); |
0 | 559 |
%} |
560 |
! ! |
|
561 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
562 |
!XWorkstation class methodsFor:'queries'! |
104 | 563 |
|
564 |
platformName |
|
133 | 565 |
"ST-80 compatibility. |
566 |
Return a string describing the display systems platform." |
|
567 |
||
715 | 568 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
569 |
||
570 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 571 |
! ! |
572 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
573 |
!XWorkstation methodsFor:'Signal constants'! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
574 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
575 |
deviceErrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
576 |
"return the per-device signal, which is raised when some |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
577 |
X-Error occurs." |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
578 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
579 |
^ deviceErrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
580 |
! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
581 |
|
1974 | 582 |
deviceIOErrorSignal |
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
583 |
"return the per-device signal, which is raised when a fatal |
1974 | 584 |
IO error (i.e. broken connection) occurs." |
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
585 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
586 |
^ deviceIOErrorSignal |
1974 | 587 |
! |
588 |
||
589 |
deviceIOTimeoutErrorSignal |
|
590 |
"return the per-device signal, which is raised when a timeout |
|
591 |
IO error (i.e. broken connection) occurs." |
|
592 |
||
593 |
^ deviceIOTimeoutErrorSignal |
|
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
594 |
! ! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
595 |
|
0 | 596 |
!XWorkstation methodsFor:'accessing & queries'! |
597 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
598 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
599 |
"return the state-mask for any button in motion events' state-field. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
600 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
601 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
602 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
603 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
604 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
605 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
606 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
607 |
|
295 | 608 |
blackpixel |
609 |
"return the colornumber of black" |
|
610 |
||
611 |
^ blackpixel |
|
612 |
! |
|
613 |
||
614 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
615 |
"return the state-mask for button1 in motion events' state-field. |
295 | 616 |
For backward compatibility." |
617 |
||
618 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
619 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 620 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
621 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
622 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
623 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
624 |
" |
295 | 625 |
! |
626 |
||
627 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
628 |
"return the state-mask for button2 in motion events' state-field |
295 | 629 |
For backward compatibility." |
630 |
||
631 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
632 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 633 |
%} |
634 |
! |
|
635 |
||
636 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
637 |
"return the state-mask for button3 in motion events' state-field |
295 | 638 |
For backward compatibility." |
639 |
||
640 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
641 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 642 |
%} |
643 |
! |
|
644 |
||
645 |
buttonMotionMask:aButton |
|
646 |
"return the state-mask for button1 in motion events state-field. |
|
647 |
This is the devices mask." |
|
648 |
||
649 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
650 |
if (aButton == __MKSMALLINT(1)) { |
1344 | 651 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
652 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
653 |
if (aButton == __MKSMALLINT(2)) { |
1344 | 654 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
655 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
656 |
if (aButton == __MKSMALLINT(3)) { |
1344 | 657 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 658 |
} |
659 |
%}. |
|
660 |
^ nil |
|
661 |
! |
|
662 |
||
382 | 663 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
664 |
"return the state-mask for the CTRL modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
665 |
|
382 | 666 |
%{ /* NOCONTEXT */ |
667 |
RETURN (__MKSMALLINT(ControlMask)); |
|
668 |
%} |
|
669 |
! |
|
670 |
||
295 | 671 |
defaultEventMask |
672 |
"return a mask to enable some events by default." |
|
673 |
||
674 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
675 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
1344 | 676 |
KeyPressMask | KeyReleaseMask | |
677 |
EnterWindowMask | LeaveWindowMask | |
|
678 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
295 | 679 |
%} |
680 |
! |
|
681 |
||
0 | 682 |
displayFileDescriptor |
683 |
"return the displays fileNumber - for select" |
|
684 |
||
685 |
%{ /* NOCONTEXT */ |
|
686 |
||
150 | 687 |
if (ISCONNECTED) { |
1344 | 688 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 689 |
} |
690 |
RETURN (nil); |
|
0 | 691 |
%} |
692 |
! |
|
693 |
||
133 | 694 |
displayName |
695 |
"return the X-connections display name. |
|
696 |
This is (currently) nil for the default display, |
|
697 |
something like foo:0 for any other remote display. |
|
698 |
Future versions may return non-nil strings for the default display as well." |
|
699 |
||
700 |
^ displayName |
|
701 |
! |
|
702 |
||
341 | 703 |
protocolVersion |
704 |
"return the X-servers protocol version - should normally not be of |
|
705 |
any interest" |
|
706 |
||
707 |
%{ /* NOCONTEXT */ |
|
708 |
if (ISCONNECTED) { |
|
1344 | 709 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
341 | 710 |
} |
711 |
RETURN (nil); |
|
712 |
%} |
|
713 |
||
714 |
" |
|
715 |
Display protocolVersion |
|
716 |
" |
|
717 |
! |
|
718 |
||
719 |
serverVendor |
|
720 |
"return the X-server vendor string - this should normally not be of |
|
721 |
any interest, but can be for special cases |
|
722 |
(to avoid bugs in certain implementations)" |
|
723 |
%{ |
|
724 |
if (ISCONNECTED) { |
|
1344 | 725 |
RETURN ( __MKSTRING(XServerVendor(myDpy)) ); |
341 | 726 |
} |
727 |
RETURN (nil); |
|
728 |
%} |
|
729 |
||
730 |
" |
|
731 |
Display serverVendor |
|
732 |
" |
|
733 |
! |
|
734 |
||
382 | 735 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
736 |
"return the state-mask for the SHIFT modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
737 |
|
382 | 738 |
%{ /* NOCONTEXT */ |
739 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
740 |
%} |
|
741 |
! |
|
742 |
||
341 | 743 |
translatePoint:aPoint from:windowId1 to:windowId2 |
744 |
"given a point in window1, return the coordinate in window2. |
|
745 |
This expects a device coordinate (relative to the first views origin) |
|
746 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
747 |
- use to xlate points from a window to rootwindow" |
|
748 |
||
749 |
|x1 y1 x2 y2| |
|
750 |
||
751 |
x1 := x2 := aPoint x truncated. |
|
752 |
y1 := y2 := aPoint y truncated. |
|
753 |
%{ |
|
754 |
int xpos, ypos; |
|
755 |
Window w1, w2, child_return; |
|
555 | 756 |
int screen = __intVal(__INST(screen)); |
1209 | 757 |
|
758 |
if (ISCONNECTED |
|
759 |
&& __isExternalAddress(windowId1) |
|
341 | 760 |
&& __isExternalAddress(windowId2) |
761 |
&& __bothSmallInteger(x1, y1)) { |
|
1344 | 762 |
Display *dpy = myDpy; |
1974 | 763 |
Window rootWin; |
1344 | 764 |
|
765 |
w1 = _WindowVal(windowId1); |
|
766 |
w2 = _WindowVal(windowId2); |
|
1974 | 767 |
|
341 | 768 |
#ifdef VIRTUAL_ROOT |
1974 | 769 |
rootWin = RootWindow(dpy, screen); |
770 |
if ((w1 == rootWin) || (w2 == rootWin)) { |
|
771 |
if (w1 == rootWin) { |
|
1344 | 772 |
w1 = getRootWindow(dpy, screen); |
773 |
} |
|
1974 | 774 |
if (w2 == rootWin) { |
1344 | 775 |
w2 = getRootWindow(dpy, screen); |
776 |
} |
|
777 |
} |
|
341 | 778 |
#endif |
1344 | 779 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 780 |
ENTER_XLIB(); |
1344 | 781 |
XTranslateCoordinates(dpy, w1, w2, |
782 |
__intVal(x1), __intVal(y1), |
|
783 |
&xpos, &ypos, &child_return); |
|
1974 | 784 |
LEAVE_XLIB(); |
1344 | 785 |
END_INTERRUPTSBLOCKED |
786 |
x2 = __MKSMALLINT(xpos); |
|
787 |
y2 = __MKSMALLINT(ypos); |
|
341 | 788 |
} |
789 |
%}. |
|
790 |
||
791 |
^ (x2 @ y2) |
|
792 |
! |
|
793 |
||
794 |
vendorRelease |
|
795 |
"return the X-servers vendor release - should normally not be of |
|
796 |
any interest, but can be for special cases. |
|
797 |
(to avoid bugs in certain implementations)" |
|
798 |
||
799 |
%{ /* NOCONTEXT */ |
|
800 |
if (ISCONNECTED) { |
|
1344 | 801 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
341 | 802 |
} |
803 |
RETURN (nil); |
|
804 |
%} |
|
805 |
||
806 |
" |
|
807 |
Display vendorRelease |
|
808 |
" |
|
809 |
! |
|
810 |
||
811 |
viewIdFromPoint:aPoint in:windowId |
|
812 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
813 |
hit by this coordinate. Return nil if no view was hit. |
|
814 |
The returned id may be the id of a non ST view. |
|
815 |
- used to find the window to drop objects after a cross-view drag." |
|
816 |
||
817 |
%{ /* NOCONTEXT */ |
|
818 |
||
555 | 819 |
int screen = __intVal(__INST(screen)); |
341 | 820 |
OBJ xp, yp; |
821 |
int xpos, ypos; |
|
822 |
Window child_return; |
|
823 |
||
1209 | 824 |
if (ISCONNECTED |
825 |
&& __isExternalAddress(windowId) |
|
341 | 826 |
&& __isPoint(aPoint)) { |
1344 | 827 |
Display *dpy = myDpy; |
828 |
||
829 |
xp = _point_X(aPoint); |
|
830 |
yp = _point_Y(aPoint); |
|
831 |
if (__bothSmallInteger(xp, yp)) { |
|
832 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 833 |
ENTER_XLIB(); |
1344 | 834 |
XTranslateCoordinates(dpy, |
835 |
RootWindow(dpy, screen), |
|
836 |
_WindowVal(windowId), |
|
837 |
__intVal(xp), __intVal(yp), |
|
838 |
&xpos, &ypos, &child_return); |
|
1974 | 839 |
LEAVE_XLIB(); |
1344 | 840 |
END_INTERRUPTSBLOCKED |
841 |
if (child_return) { |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
842 |
RETURN ( __MKEXTERNALADDRESS(child_return) ); |
1344 | 843 |
} |
844 |
RETURN ( nil ); |
|
845 |
} |
|
341 | 846 |
} |
847 |
%}. |
|
848 |
windowId notNil ifTrue:[ |
|
1344 | 849 |
aPoint isPoint ifTrue:[ |
850 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
851 |
] |
|
341 | 852 |
]. |
853 |
||
854 |
^ nil |
|
855 |
! |
|
856 |
||
857 |
virtualExtent |
|
858 |
"return the virtual extent of the display (in pixels). |
|
859 |
On most systems, this is the same as the physical width; |
|
860 |
except, if a window manager with a virtual desktop like olvwm |
|
861 |
(simulating a bigger screen) is running." |
|
862 |
||
863 |
%{ |
|
1209 | 864 |
if (ISCONNECTED |
865 |
&& (__INST(rootId) != __INST(virtualRootId)) |
|
555 | 866 |
&& __isExternalAddress(__INST(virtualRootId))) { |
1344 | 867 |
Window vRootWin; |
868 |
Window root; |
|
869 |
int x, y; |
|
870 |
unsigned int width, height; |
|
871 |
unsigned int dummy; |
|
1974 | 872 |
int ret; |
1344 | 873 |
|
874 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
|
1974 | 875 |
ENTER_XLIB(); |
876 |
ret = XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
877 |
&dummy, &dummy); |
|
878 |
LEAVE_XLIB(); |
|
879 |
if (ret) { |
|
1344 | 880 |
RETURN ( __MKPOINT_INT(width, height) ); |
881 |
} |
|
341 | 882 |
} |
883 |
%}. |
|
884 |
^ width @ height |
|
885 |
! |
|
886 |
||
887 |
whitepixel |
|
888 |
"return the colornumber of white" |
|
889 |
||
890 |
^ whitepixel |
|
891 |
! ! |
|
892 |
||
893 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
894 |
||
0 | 895 |
hasDPS |
186 | 896 |
"return true, if this workstation supports display postscript. |
897 |
Both the server must support it, and the feature must have been |
|
898 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 899 |
|
900 |
^ hasDPSExtension |
|
186 | 901 |
|
902 |
" |
|
903 |
Display hasDPS |
|
904 |
" |
|
905 |
! |
|
906 |
||
150 | 907 |
hasExtension:extensionString |
908 |
"query for an X extension. The argument, extensionString |
|
909 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 910 |
Return true, if that extension is available in the server. |
911 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 912 |
|
913 |
%{ |
|
914 |
int dummy; |
|
1974 | 915 |
OBJ rslt = false; |
150 | 916 |
|
917 |
if (__isString(extensionString) && ISCONNECTED) { |
|
1974 | 918 |
ENTER_XLIB(); |
1344 | 919 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
1974 | 920 |
rslt = true; |
921 |
} |
|
922 |
LEAVE_XLIB(); |
|
923 |
} |
|
924 |
RETURN (rslt); |
|
925 |
%} |
|
186 | 926 |
|
927 |
" |
|
928 |
Display hasExtension:'XVideo' |
|
929 |
Display hasExtension:'Input' |
|
930 |
Display hasExtension:'GLX' |
|
931 |
Display hasExtension:'X3D-PEX' |
|
932 |
Display hasExtension:'XInputExtension' |
|
933 |
Display hasExtension:'SHAPE' |
|
934 |
Display hasExtension:'MIT-SHM' |
|
935 |
Display hasExtension:'SGIFullScreenStereo' |
|
936 |
" |
|
150 | 937 |
! |
938 |
||
295 | 939 |
hasImageExtension |
940 |
"return true, if this workstation supports the X image extension. |
|
941 |
Both the server must support it, and the feature must have been |
|
942 |
enabled in the smalltalk system, for true to be returned." |
|
943 |
||
944 |
^ hasImageExtension |
|
945 |
||
946 |
" |
|
947 |
Display hasImageExtension |
|
948 |
" |
|
949 |
! |
|
950 |
||
951 |
hasInputExtension |
|
952 |
"return true, if this workstation supports the X input extension. |
|
953 |
Both the server must support it, and the feature must have been |
|
954 |
enabled in the smalltalk system, for true to be returned." |
|
955 |
||
956 |
^ hasInputExtension |
|
957 |
||
958 |
" |
|
959 |
Display hasInputExtension |
|
960 |
" |
|
961 |
! |
|
962 |
||
963 |
hasMultibuffer |
|
964 |
"return true, if this workstation supports the multibuffer extension. |
|
965 |
Both the server must support it, and the feature must have been |
|
966 |
enabled in the smalltalk system, for true to be returned." |
|
967 |
||
968 |
^ hasMbufExtension |
|
969 |
||
970 |
" |
|
971 |
Display hasMultibuffer |
|
972 |
" |
|
973 |
! |
|
974 |
||
975 |
hasPEX |
|
976 |
"return true, if this workstation supports PEX 3D graphics. |
|
977 |
Both the server must support it, and the feature must have been |
|
978 |
enabled in the smalltalk system, for true to be returned." |
|
979 |
||
980 |
^ hasPEXExtension |
|
981 |
||
982 |
" |
|
983 |
Display hasPEX |
|
984 |
" |
|
985 |
! |
|
986 |
||
987 |
hasShape |
|
988 |
"return true, if this workstation supports non-rectangular windows. |
|
989 |
Both the server must support it, and the feature must have been |
|
990 |
enabled in the smalltalk system, for true to be returned." |
|
991 |
||
992 |
^ hasShapeExtension |
|
993 |
||
994 |
" |
|
995 |
Display hasShape |
|
996 |
" |
|
997 |
! |
|
998 |
||
999 |
hasShm |
|
1000 |
"return true, if this workstation supports the shared pixmap extension. |
|
1001 |
Both the server must support it, and the feature must have been |
|
1002 |
enabled in the smalltalk system, for true to be returned." |
|
1003 |
||
1004 |
^ hasShmExtension |
|
1005 |
||
1006 |
" |
|
1007 |
Display hasShm |
|
1008 |
" |
|
1009 |
! |
|
1010 |
||
1011 |
hasXVideo |
|
1012 |
"return true, if this workstation supports the XVideo extension. |
|
1013 |
Both the server must support it, and the feature must have been |
|
1014 |
enabled in the smalltalk system, for true to be returned." |
|
1015 |
||
1016 |
^ hasXVideoExtension |
|
1017 |
||
1018 |
" |
|
1019 |
Display hasXVideo |
|
1020 |
" |
|
1021 |
! |
|
1022 |
||
1023 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
1024 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 1025 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 1026 |
|
1027 |
|xIconSizes count ret| |
|
1028 |
||
1029 |
%{ |
|
555 | 1030 |
int screen = __intVal(__INST(screen)); |
295 | 1031 |
XIconSize *sizeList; |
1032 |
int cnt; |
|
1033 |
||
1034 |
if (ISCONNECTED) { |
|
1344 | 1035 |
Display *dpy = myDpy; |
1974 | 1036 |
int status; |
1037 |
||
1038 |
ENTER_XLIB(); |
|
1039 |
status = XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt); |
|
1040 |
LEAVE_XLIB(); |
|
1041 |
if (status > 0) { |
|
1344 | 1042 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
1043 |
count = __MKSMALLINT(cnt); |
|
1044 |
} |
|
295 | 1045 |
} |
1046 |
%}. |
|
1047 |
xIconSizes isNil ifTrue:[^ nil]. |
|
1048 |
||
1049 |
ret := OrderedCollection new:count. |
|
1050 |
1 to:count do:[ :i | |
|
1344 | 1051 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 1052 |
|
1053 |
%{ |
|
1344 | 1054 |
XIconSize *slp; |
1055 |
||
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1056 |
slp = &((XIconSize *)__externalAddressVal(xIconSizes))[__intVal(i)-1]; |
1344 | 1057 |
minWidth = __MKSMALLINT(slp->min_width); |
1058 |
minHeight = __MKSMALLINT(slp->min_height); |
|
1059 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
1060 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
1061 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
1062 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 1063 |
%}. |
1344 | 1064 |
d := IdentityDictionary new. |
1065 |
d at:#minWidth put:minWidth. |
|
1066 |
d at:#maxWidth put:maxWidth. |
|
1067 |
d at:#widthStep put:widthStep. |
|
1068 |
d at:#minHeight put:minHeight. |
|
1069 |
d at:#maxHeight put:maxHeight. |
|
1070 |
d at:#heightStep put:heightStep. |
|
1071 |
||
1072 |
ret add:d |
|
295 | 1073 |
]. |
1074 |
||
1075 |
xIconSizes free. |
|
1076 |
^ ret |
|
1077 |
||
1078 |
" |
|
819 | 1079 |
Display iconSizes |
295 | 1080 |
" |
1081 |
! |
|
1082 |
||
341 | 1083 |
ignoreBackingStore:aBoolean |
1084 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
1085 |
no backing store used - this can be used on servers where backing store is |
|
1086 |
very slow or is broken (can be put into display-rc-file)" |
|
1087 |
||
1088 |
ignoreBackingStore := aBoolean |
|
295 | 1089 |
! |
1090 |
||
823 | 1091 |
preferredIconSize |
1092 |
"return the displays preferred size for icons. |
|
1093 |
Redefined to return a special value on SGI servers." |
|
1094 |
||
1095 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
1344 | 1096 |
^ 86@68 |
823 | 1097 |
]. |
1098 |
^ super preferredIconSize |
|
1099 |
||
1100 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
1101 |
! |
|
1102 |
||
1025 | 1103 |
scrollsAsynchronous |
1008
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1104 |
"return true, if this display asynchronously sends expose events after a |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1105 |
scroll operation. False otherwise. Asynchronous expose events are an X |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1106 |
speciality, which affects a few methods outside of the display class (sorry)" |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1107 |
|
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1108 |
^ true |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1109 |
! |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1110 |
|
43 | 1111 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1112 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1113 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1114 |
depth, bitsPerPixel and padding values." |
43 | 1115 |
|
150 | 1116 |
|nFormats "{ Class: SmallInteger }" |
1117 |
formatArray| |
|
43 | 1118 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1119 |
Display *dpy; |
150 | 1120 |
|
1121 |
if (! ISCONNECTED) { |
|
1344 | 1122 |
RETURN (nil); |
150 | 1123 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1124 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1125 |
dpy = myDpy; |
1898 | 1126 |
#ifdef NO_PRIVATE_DISPLAY_ACCESS |
1891 | 1127 |
nFormats = __MKSMALLINT(1); |
1128 |
#else |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1129 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
1891 | 1130 |
#endif |
43 | 1131 |
%}. |
1132 |
formatArray := Array new:nFormats. |
|
150 | 1133 |
1 to:nFormats do:[:index | |
1344 | 1134 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
1135 |
||
1136 |
i := index. |
|
43 | 1137 |
%{ |
1344 | 1138 |
ScreenFormat *format; |
1139 |
Display *dpy = myDpy; |
|
1140 |
||
1898 | 1141 |
#ifdef NO_PRIVATE_DISPLAY_ACCESS |
1891 | 1142 |
depthInfo = __MKSMALLINT(1); |
1143 |
bitsPerPixelInfo = __MKSMALLINT(1); |
|
1144 |
paddingInfo = __MKSMALLINT(8); |
|
1145 |
#else |
|
1344 | 1146 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
1147 |
format += (__intVal(i)-1); |
|
1148 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
|
1149 |
depthInfo = __MKSMALLINT(format->depth); |
|
1150 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
|
1891 | 1151 |
#endif |
43 | 1152 |
%}. |
1344 | 1153 |
info := IdentityDictionary new. |
1154 |
info at:#depth put:depthInfo. |
|
1155 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
|
1156 |
info at:#padding put:paddingInfo. |
|
1157 |
formatArray at:index put:info. |
|
43 | 1158 |
]. |
1159 |
^ formatArray |
|
1160 |
||
1161 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1162 |
Display supportedImageFormats |
43 | 1163 |
" |
1164 |
! |
|
1165 |
||
823 | 1166 |
supportsIconViews |
1167 |
"return true, if this device supports views as icons. |
|
1168 |
Only Xservers (currently) support this." |
|
1169 |
||
1170 |
^ true |
|
1171 |
||
1172 |
" |
|
1173 |
Display supportsIconViews |
|
1174 |
" |
|
1175 |
||
1176 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1177 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1178 |
! |
|
1179 |
||
81 | 1180 |
supportsViewGravity |
1181 |
"return true, if this device supports gravity attributes. |
|
82 | 1182 |
We do not depend on it being implemented, but some resizing operations |
81 | 1183 |
are faster, it is is." |
1184 |
||
1185 |
^ true |
|
0 | 1186 |
! ! |
1187 |
||
1188 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1189 |
||
295 | 1190 |
createBitmapFromArray:anArray width:w height:h |
1191 |
|bitmapId| |
|
1192 |
||
1193 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1194 |
bitmapId isNil ifTrue:[ |
|
1344 | 1195 |
self primitiveFailed |
295 | 1196 |
]. |
1197 |
^ bitmapId |
|
1198 |
! |
|
1199 |
||
1200 |
createBitmapFromFile:aString for:aForm |
|
1201 |
|id w h| |
|
1202 |
||
1203 |
%{ |
|
555 | 1204 |
int screen = __intVal(__INST(screen)); |
295 | 1205 |
Pixmap newBitmap; |
1206 |
char *filename; |
|
1207 |
unsigned b_width, b_height; |
|
1208 |
int b_x_hot, b_y_hot; |
|
1209 |
int status; |
|
1210 |
||
1211 |
if (ISCONNECTED) { |
|
1344 | 1212 |
Display *dpy = myDpy; |
1213 |
||
1214 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1831 | 1215 |
filename = (char *) __stringVal(aString); |
1344 | 1216 |
|
1217 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1218 |
ENTER_XLIB(); |
1344 | 1219 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
1220 |
filename, &b_width, &b_height, &newBitmap, |
|
1221 |
&b_x_hot, &b_y_hot); |
|
1974 | 1222 |
LEAVE_XLIB(); |
1344 | 1223 |
END_INTERRUPTSBLOCKED |
1224 |
||
1225 |
if ((status == BitmapSuccess) && newBitmap) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1226 |
#ifdef COUNT_RESOURCES |
1344 | 1227 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1228 |
#endif |
1344 | 1229 |
w = __MKSMALLINT(b_width); |
1230 |
h = __MKSMALLINT(b_height); |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1231 |
id = __MKEXTERNALADDRESS(newBitmap); |
1344 | 1232 |
} |
1233 |
} |
|
295 | 1234 |
} |
1235 |
%}. |
|
1236 |
id notNil ifTrue:[ |
|
1344 | 1237 |
aForm setWidth:w height:h |
295 | 1238 |
]. |
1239 |
^ id |
|
1240 |
! |
|
1241 |
||
1242 |
createBitmapWidth:w height:h |
|
1243 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1244 |
(i.e. random). Return a bitmap id or nil" |
|
1245 |
||
1246 |
%{ /* NOCONTEXT */ |
|
1247 |
||
555 | 1248 |
int screen = __intVal(__INST(screen)); |
295 | 1249 |
Pixmap newBitmap; |
1250 |
||
1251 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1344 | 1252 |
Display *dpy = myDpy; |
1253 |
||
1254 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1255 |
ENTER_XLIB(); |
1344 | 1256 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
1257 |
__intVal(w), __intVal(h), 1); |
|
1974 | 1258 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1259 |
#ifdef COUNT_RESOURCES |
1344 | 1260 |
if (newBitmap) |
1261 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1262 |
#endif |
1344 | 1263 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1264 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil ); |
295 | 1265 |
} |
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1266 |
%}. |
295 | 1267 |
self primitiveFailed. |
1268 |
^ nil |
|
1269 |
! |
|
1270 |
||
0 | 1271 |
createPixmapWidth:w height:h depth:d |
1272 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1273 |
(i.e. random). Return a bitmap id or nil" |
|
1274 |
||
1275 |
%{ /* NOCONTEXT */ |
|
1276 |
||
555 | 1277 |
int screen = __intVal(__INST(screen)); |
0 | 1278 |
Pixmap newBitmap; |
1279 |
||
150 | 1280 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
1344 | 1281 |
Display *dpy = myDpy; |
1282 |
||
1283 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1284 |
ENTER_XLIB(); |
1344 | 1285 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
1286 |
__intVal(w), __intVal(h), __intVal(d)); |
|
1974 | 1287 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1288 |
#ifdef COUNT_RESOURCES |
1344 | 1289 |
if (newBitmap) |
1290 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1291 |
#endif |
1344 | 1292 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1293 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil ); |
0 | 1294 |
} |
1424 | 1295 |
%}. |
43 | 1296 |
self primitiveFailed. |
1297 |
^ nil |
|
0 | 1298 |
! |
1299 |
||
1468
9832c4017a70
added type argument to createWindowFor - prepare for native window support (windows)
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1300 |
createWindowFor:aView type:typeSymbol |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1301 |
origin:origin |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1302 |
extent:extent |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1303 |
minExtent:minExt |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1304 |
maxExtent:maxExt |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1305 |
borderWidth:bWidth |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1306 |
subViewOf:wsuperView |
1695
46d9101e4bee
replaced isPopUp flag in #createWindow by a more general #style symbol argument
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
1307 |
style:wStyle |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1308 |
inputOnly:winputOnly |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1309 |
label:wlabel |
1960 | 1310 |
owner:wowner |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1311 |
icon:wicon iconMask:wiconMask |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1312 |
iconView:wiconView |
46 | 1313 |
|
1314 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1960 | 1315 |
bColorId wsuperViewId wiconId wiconMaskId windowId |
46 | 1316 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
150 | 1317 |
vBgForm deepForm preferredVisual preferredDepth| |
1318 |
||
1319 |
displayId isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1320 |
self primitiveFailed. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1321 |
^ nil |
150 | 1322 |
]. |
0 | 1323 |
|
46 | 1324 |
origin notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1325 |
xpos := origin x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1326 |
ypos := origin y. |
46 | 1327 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1328 |
xpos := ypos := 0. |
0 | 1329 |
]. |
46 | 1330 |
extent notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1331 |
wwidth := extent x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1332 |
wheight := extent y. |
46 | 1333 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1334 |
wwidth := wheight := 100. |
46 | 1335 |
]. |
1336 |
minExt notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1337 |
minWidth := minExt x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1338 |
minHeight := minExt y |
0 | 1339 |
]. |
46 | 1340 |
maxExt notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1341 |
maxWidth := maxExt x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1342 |
maxHeight := maxExt y |
46 | 1343 |
]. |
1344 |
||
0 | 1345 |
wsuperView notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1346 |
wsuperViewId := wsuperView id |
0 | 1347 |
]. |
1348 |
||
1349 |
wicon notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1350 |
wiconId := wicon id. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1351 |
wiconMask notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1352 |
wiconMaskId := wiconMask id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1353 |
] |
0 | 1354 |
]. |
1355 |
wiconView notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1356 |
wiconViewId := wiconView id |
0 | 1357 |
]. |
1358 |
weventMask := aView eventMask. |
|
1359 |
||
150 | 1360 |
preferredVisual := aView preferredVisual. |
1361 |
preferredDepth := aView preferredDepth. |
|
23 | 1362 |
|
1898 | 1363 |
%{ /* STACK:64000 */ /* used to be 16000 - but VMS seems to need a lot */ |
0 | 1364 |
Display *dpy = myDpy; |
555 | 1365 |
int screen = __intVal(__INST(screen)); |
0 | 1366 |
Visual visual; |
1367 |
XGCValues xgcv; |
|
1368 |
XSetWindowAttributes xswa; |
|
1369 |
XSizeHints sizehints; |
|
1370 |
XWMHints wmhints; |
|
46 | 1371 |
int bw, bd, bg; |
0 | 1372 |
Window newWindow, parentWindow; |
1373 |
char *windowName; |
|
1374 |
XFontStruct *f; |
|
1537 | 1375 |
Pixmap backPixmap = (Pixmap)0, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1376 |
iconBitmap = (Pixmap)0, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1377 |
iconMask = (Pixmap)0; |
0 | 1378 |
int flags = 0, depth, ioClass; |
1379 |
Window iconWindow; |
|
1380 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1381 |
Atom WmQuitAppAtom; |
|
1382 |
Atom atoms[3]; |
|
1383 |
int atomCount = 0, isTopWindow = 0; |
|
1384 |
||
1385 |
sizehints.flags = 0; |
|
1386 |
sizehints.width = 100; |
|
1387 |
sizehints.height = 100; |
|
1388 |
sizehints.x = 0; |
|
1389 |
sizehints.y = 0; |
|
1390 |
||
97 | 1391 |
if (__bothSmallInteger(wwidth, wheight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1392 |
sizehints.flags |= PSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1393 |
sizehints.width = __intVal(wwidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1394 |
sizehints.height = __intVal(wheight); |
0 | 1395 |
} |
97 | 1396 |
if (__bothSmallInteger(xpos, ypos)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1397 |
sizehints.flags |= PPosition; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1398 |
sizehints.x = __intVal(xpos); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1399 |
sizehints.y = __intVal(ypos); |
0 | 1400 |
} |
97 | 1401 |
if (__bothSmallInteger(minWidth, minHeight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1402 |
sizehints.flags |= PMinSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1403 |
sizehints.min_width = __intVal(minWidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1404 |
sizehints.min_height = __intVal(minHeight); |
0 | 1405 |
} |
97 | 1406 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1407 |
sizehints.flags |= PMaxSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1408 |
sizehints.max_width = __intVal(maxWidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1409 |
sizehints.max_height = __intVal(maxHeight); |
0 | 1410 |
} |
1411 |
||
37 | 1412 |
bg = WhitePixel(dpy, screen); |
0 | 1413 |
|
97 | 1414 |
if (__isSmallInteger(bWidth)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1415 |
bw = __intVal(bWidth); |
46 | 1416 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1417 |
bw = 0; |
0 | 1418 |
} |
1419 |
||
72 | 1420 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1421 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1422 |
if (__isExternalAddress(wsuperViewId)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1423 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1424 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1425 |
parentWindow = RootWindow(dpy, screen); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1426 |
isTopWindow = 1; |
0 | 1427 |
} |
1428 |
||
1695
46d9101e4bee
replaced isPopUp flag in #createWindow by a more general #style symbol argument
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
1429 |
if (wStyle == @symbol(popUp)) |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1430 |
xswa.override_redirect = 1; |
0 | 1431 |
else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1432 |
xswa.override_redirect = 0; |
0 | 1433 |
|
1434 |
if (winputOnly == true) |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1435 |
ioClass = InputOnly; |
0 | 1436 |
else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1437 |
ioClass = InputOutput; |
0 | 1438 |
|
97 | 1439 |
if (__isSmallInteger(weventMask)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1440 |
xswa.event_mask = __intVal(weventMask); |
0 | 1441 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1442 |
xswa.event_mask = 0; |
0 | 1443 |
} |
1444 |
||
1445 |
if (ioClass == InputOnly) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1446 |
bw = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1447 |
depth = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1448 |
flags |= CWEventMask; |
0 | 1449 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1450 |
depth = DefaultDepth(dpy,screen); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1451 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1452 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1453 |
if (backPixmap != (Pixmap)0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1454 |
xswa.background_pixmap = backPixmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1455 |
flags |= CWBackPixmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1456 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1457 |
xswa.background_pixel = bg; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1458 |
flags |= CWBackPixel; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1459 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1460 |
xswa.border_pixel = bd; |
0 | 1461 |
} |
23 | 1462 |
|
0 | 1463 |
visual.visualid = CopyFromParent; |
150 | 1464 |
if (__isSmallInteger(preferredDepth)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1465 |
depth = __intVal(preferredDepth); |
23 | 1466 |
} |
54 | 1467 |
|
1468 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1469 |
if (preferredVisual != nil) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1470 |
XVisualInfo vi; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1471 |
int cls; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1472 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1473 |
if (preferredVisual == @symbol(StaticGray)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1474 |
cls = StaticGray; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1475 |
else if (preferredVisual == @symbol(GrayScale)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1476 |
cls = GrayScale; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1477 |
else if (preferredVisual == @symbol(StaticColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1478 |
cls = StaticColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1479 |
else if (preferredVisual == @symbol(PseudoColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1480 |
cls = PseudoColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1481 |
else if (preferredVisual == @symbol(TrueColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1482 |
cls = TrueColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1483 |
else if (preferredVisual == @symbol(DirectColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1484 |
cls = DirectColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1485 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1486 |
cls = PseudoColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1487 |
|
1974 | 1488 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1489 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1490 |
visual.visualid = vi.visualid; |
163 | 1491 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1492 |
printf("visualId=%x\n", vi.visualid); |
163 | 1493 |
*/ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1494 |
} |
1974 | 1495 |
LEAVE_XLIB(); |
1496 |
} |
|
1497 |
||
1498 |
ENTER_XLIB(); |
|
0 | 1499 |
newWindow = XCreateWindow(dpy, parentWindow, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1500 |
sizehints.x, sizehints.y, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1501 |
sizehints.width, sizehints.height, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1502 |
bw, depth, ioClass, &visual, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1503 |
flags, &xswa); |
1974 | 1504 |
LEAVE_XLIB(); |
54 | 1505 |
END_INTERRUPTSBLOCKED |
0 | 1506 |
|
1507 |
if (! newWindow) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1508 |
RETURN ( nil ); |
0 | 1509 |
} |
1510 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1511 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1512 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1513 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1514 |
|
54 | 1515 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1516 |
|
1517 |
/* |
|
1518 |
* define its icon and name |
|
1519 |
* (only makes sense for topWindows) |
|
1520 |
*/ |
|
1521 |
if (isTopWindow) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1522 |
if (__isExternalAddress(wiconId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1523 |
iconBitmap = _PixmapVal(wiconId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1524 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1525 |
iconBitmap = (Pixmap)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1526 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1527 |
if (__isExternalAddress(wiconMaskId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1528 |
iconMask = _PixmapVal(wiconMaskId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1529 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1530 |
iconMask = (Pixmap)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1531 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1532 |
if (__isExternalAddress(wiconViewId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1533 |
iconWindow = _WindowVal(wiconViewId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1534 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1535 |
iconWindow = (Window)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1536 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1537 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
1831 | 1538 |
windowName = (char *) __stringVal(wlabel); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1539 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1540 |
windowName = ""; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1541 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1542 |
if (iconBitmap || windowName) { |
1974 | 1543 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1544 |
XSetStandardProperties(dpy, newWindow, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1545 |
windowName, windowName, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1546 |
iconBitmap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1547 |
0, 0, &sizehints); |
1974 | 1548 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1549 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1550 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1551 |
wmhints.flags = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1552 |
if (iconBitmap) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1553 |
wmhints.flags |= IconPixmapHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1554 |
wmhints.icon_pixmap = iconBitmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1555 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1556 |
if (iconMask) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1557 |
wmhints.flags |= IconMaskHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1558 |
wmhints.icon_mask = iconMask; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1559 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1560 |
if (iconWindow) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1561 |
wmhints.flags |= IconWindowHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1562 |
wmhints.icon_window = iconWindow; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1563 |
} |
0 | 1564 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1565 |
wmhints.flags |= InputHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1566 |
wmhints.input = True; |
0 | 1567 |
*/ |
1974 | 1568 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1569 |
XSetWMHints(dpy, newWindow, &wmhints); |
1974 | 1570 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1571 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1572 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1573 |
* tell window manager to not kill us but send an event instead |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1574 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1575 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1576 |
* get atoms first (if not already known) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1577 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1578 |
if (__INST(protocolsAtom) == nil) { |
1974 | 1579 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1580 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1581 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1582 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1583 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1584 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1585 |
#endif |
1586 |
#ifdef USE_QUIT_APP_ATOM |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1587 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1588 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1589 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1590 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1591 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
1974 | 1592 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1593 |
} else { |
0 | 1594 |
#ifdef USE_QUIT_APP_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1595 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1596 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1597 |
WmQuitAppAtom = 0; |
0 | 1598 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1599 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1600 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
0 | 1601 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1602 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1603 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1604 |
WmSaveYourselfAtom = 0; |
0 | 1605 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1606 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1607 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1608 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
0 | 1609 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1610 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1611 |
#endif |
1612 |
#ifdef USE_QUIT_APP_ATOM |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1613 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1614 |
#endif |
1974 | 1615 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1616 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1617 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
1974 | 1618 |
LEAVE_XLIB(); |
0 | 1619 |
} |
1620 |
||
54 | 1621 |
END_INTERRUPTSBLOCKED |
1622 |
||
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1623 |
windowId = __MKEXTERNALADDRESS(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1624 |
%}. |
0 | 1625 |
self addKnownView:aView withId:windowId. |
1626 |
^ windowId |
|
1627 |
! |
|
1628 |
||
1629 |
destroyGC:aGCId |
|
1630 |
||
1631 |
%{ /* NOCONTEXT */ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1632 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1633 |
if (! ISCONNECTED) { |
1344 | 1634 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1635 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1636 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1637 |
if (__isExternalAddress(aGCId)) { |
1344 | 1638 |
GC gc = _GCVal(aGCId); |
1639 |
||
1640 |
if (gc) { |
|
1641 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1642 |
ENTER_XLIB(); |
1344 | 1643 |
XFreeGC(myDpy, gc); |
1974 | 1644 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1645 |
#ifdef COUNT_RESOURCES |
1344 | 1646 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1647 |
#endif |
1344 | 1648 |
END_INTERRUPTSBLOCKED |
1649 |
} |
|
1650 |
RETURN ( self ); |
|
0 | 1651 |
} |
118 | 1652 |
%}. |
0 | 1653 |
self primitiveFailed |
1654 |
! |
|
1655 |
||
295 | 1656 |
destroyPixmap:aDrawableId |
0 | 1657 |
|
1658 |
%{ /* NOCONTEXT */ |
|
1659 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1660 |
if (! ISCONNECTED) { |
1344 | 1661 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1662 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1663 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1664 |
if (__isExternalAddress(aDrawableId)) { |
1344 | 1665 |
Pixmap pix = _PixmapVal(aDrawableId); |
1666 |
||
1667 |
if (pix) { |
|
1668 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1669 |
ENTER_XLIB(); |
1344 | 1670 |
XFreePixmap(myDpy, pix); |
1974 | 1671 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1672 |
#ifdef COUNT_RESOURCES |
1344 | 1673 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1674 |
#endif |
1344 | 1675 |
END_INTERRUPTSBLOCKED |
1676 |
} |
|
1677 |
RETURN ( self ); |
|
0 | 1678 |
} |
118 | 1679 |
%}. |
295 | 1680 |
self primitiveFailed |
1681 |
! |
|
1682 |
||
1683 |
destroyView:aView withId:aWindowId |
|
1684 |
%{ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1685 |
if (! ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1686 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1687 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1688 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1689 |
if (__isExternalAddress(aWindowId)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1690 |
Window win = _WindowVal(aWindowId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1691 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1692 |
if (win) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1693 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 1694 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1695 |
XDestroyWindow(myDpy, win); |
1974 | 1696 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1697 |
#ifdef COUNT_RESOURCES |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1698 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1699 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1700 |
END_INTERRUPTSBLOCKED |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1701 |
} |
295 | 1702 |
} |
1703 |
%}. |
|
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1704 |
self removeKnownView:aView withId:aWindowId |
0 | 1705 |
! |
1706 |
||
1707 |
dpsContextFor:aDrawableId and:aGCId |
|
1708 |
||
1709 |
%{ /* NOCONTEXT */ |
|
1710 |
#ifdef XXDPS |
|
555 | 1711 |
int screen = __intVal(__INST(screen)); |
0 | 1712 |
DPSContext dps; |
1713 |
int height; |
|
1714 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1715 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1716 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1717 |
&& ISCONNECTED) { |
1344 | 1718 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 1719 |
ENTER_XLIB(); |
1344 | 1720 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
1721 |
_GCVal(aGCId), |
|
1722 |
0, height, 0, colormap, NULL, 0, |
|
1723 |
XDPSDefaultTextBackstop, |
|
1724 |
XDPSDefaultErrorProc, |
|
1725 |
NULL); |
|
1974 | 1726 |
LEAVE_XLIB(); |
1344 | 1727 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1728 |
RETURN ( dps ? __MKEXTERNALADDRESS(dps) : nil ); |
0 | 1729 |
} |
1730 |
#endif |
|
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1731 |
%}. |
43 | 1732 |
self primitiveFailed. |
1733 |
^ nil |
|
295 | 1734 |
! |
1735 |
||
1736 |
gcFor:aDrawableId |
|
132 | 1737 |
|
1738 |
%{ /* NOCONTEXT */ |
|
555 | 1739 |
int screen = __intVal(__INST(screen)); |
295 | 1740 |
GC gc; |
1741 |
||
1742 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1344 | 1743 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 1744 |
ENTER_XLIB(); |
1344 | 1745 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
1746 |
0L, (XGCValues *)0); |
|
1974 | 1747 |
LEAVE_XLIB(); |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1748 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1749 |
#ifdef COUNT_RESOURCES |
1344 | 1750 |
if (gc) |
1751 |
__cnt_gc++; |
|
1089 | 1752 |
#endif |
1753 |
||
1344 | 1754 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1755 |
RETURN ( gc ? __MKEXTERNALADDRESS(gc) : nil ); |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1756 |
} |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1757 |
%}. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1758 |
self primitiveFailed. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1759 |
^ nil |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1760 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1761 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1762 |
gcForBitmap:aDrawableId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1763 |
"with X, this is the same as a normal gc" |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1764 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1765 |
%{ /* NOCONTEXT */ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1766 |
int screen = __intVal(__INST(screen)); |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1767 |
GC gc; |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1768 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1769 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
1344 | 1770 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 1771 |
ENTER_XLIB(); |
1344 | 1772 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
1773 |
0L, (XGCValues *)0); |
|
1974 | 1774 |
LEAVE_XLIB(); |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1775 |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1776 |
#ifdef COUNT_RESOURCES |
1344 | 1777 |
if (gc) |
1778 |
__cnt_gc++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1779 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1780 |
|
1344 | 1781 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1782 |
RETURN ( gc ? __MKEXTERNALADDRESS(gc) : nil ); |
200 | 1783 |
} |
1784 |
%}. |
|
1785 |
self primitiveFailed. |
|
1786 |
^ nil |
|
295 | 1787 |
! |
1788 |
||
1789 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1790 |
|
1791 |
%{ /* UNLIMITEDSTACK */ |
|
1792 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1793 |
Display *dpy; |
555 | 1794 |
int screen = __intVal(__INST(screen)); |
295 | 1795 |
Pixmap newBitmap; |
1796 |
unsigned int b_width, b_height; |
|
1797 |
REGISTER unsigned char *cp; |
|
1798 |
REGISTER unsigned char *pBits; |
|
1799 |
unsigned char *b_bits, *allocatedBits; |
|
1800 |
int index, row; |
|
1801 |
REGISTER int col; |
|
1802 |
unsigned bits; |
|
1803 |
static char reverseBitTable[256]; |
|
1804 |
static firstCall = 1; |
|
1805 |
int nBytes; |
|
1806 |
unsigned char fastBits[10000]; |
|
1807 |
OBJ num, *op; |
|
1808 |
int bytesPerRow; |
|
1809 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1810 |
if (! ISCONNECTED) { |
1344 | 1811 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1812 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1813 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1814 |
dpy = myDpy; |
295 | 1815 |
if (firstCall) { |
1344 | 1816 |
for (index=0; index < 256; index++) { |
1817 |
reverseBitTable[index] = 0; |
|
1818 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1819 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1820 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1821 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1822 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1823 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1824 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1825 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1826 |
} |
|
1827 |
firstCall = 0; |
|
295 | 1828 |
} |
1829 |
||
1830 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1344 | 1831 |
newBitmap = (Pixmap)0; |
1832 |
b_width = __intVal(w); |
|
1833 |
b_height = __intVal(h); |
|
1834 |
bytesPerRow = (b_width + 7) / 8; |
|
1835 |
nBytes = b_height * bytesPerRow; |
|
1836 |
if (nBytes < sizeof(fastBits)) { |
|
1837 |
cp = b_bits = fastBits; |
|
1838 |
allocatedBits = 0; |
|
1839 |
} else { |
|
1840 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1841 |
if (! cp) goto fail; |
|
1842 |
} |
|
1843 |
||
1844 |
if (__qClass(anArray) == @global(Array)) { |
|
1845 |
index = 1; |
|
1846 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1847 |
for (row = b_height; row; row--) { |
|
1848 |
for (col = bytesPerRow; col; col--) { |
|
1849 |
num = *op++; |
|
1850 |
if (! __isSmallInteger(num)) goto fail; |
|
1851 |
bits = __intVal(num); |
|
1852 |
*cp++ = reverseBitTable[bits]; |
|
1853 |
} |
|
1854 |
} |
|
1855 |
} else { |
|
1856 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1857 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1858 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1859 |
*cp++ = reverseBitTable[*pBits++]; |
|
1860 |
} |
|
1861 |
} else { |
|
1862 |
goto fail; |
|
1863 |
} |
|
1864 |
} |
|
1865 |
||
1866 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 1867 |
ENTER_XLIB(); |
1344 | 1868 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
1869 |
(char *)b_bits, |
|
1870 |
b_width, b_height); |
|
1974 | 1871 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1872 |
#ifdef COUNT_RESOURCES |
1344 | 1873 |
if (newBitmap) |
1874 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1875 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1876 |
|
1344 | 1877 |
END_INTERRUPTSBLOCKED |
295 | 1878 |
fail: ; |
1344 | 1879 |
if (allocatedBits) |
1880 |
free(allocatedBits); |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1881 |
RETURN ( newBitmap ? __MKEXTERNALADDRESS(newBitmap) : nil ); |
0 | 1882 |
} |
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1883 |
%}. |
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1884 |
self primitiveFailed. |
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1885 |
^ nil |
295 | 1886 |
! |
1887 |
||
1888 |
realRootWindowFor:aView |
|
1889 |
"the name of this method is historic; |
|
1890 |
- it will vanish" |
|
1891 |
||
1892 |
|id| |
|
1893 |
||
1894 |
id := self realRootWindowId. |
|
1895 |
self addKnownView:aView withId:id. |
|
1896 |
^ id |
|
1897 |
! |
|
1898 |
||
1899 |
realRootWindowId |
|
1900 |
"return the id of the real root window. |
|
1901 |
This may not be the window you see as background, |
|
1902 |
since some window managers install a virtual root window on top |
|
1903 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1904 |
care of any virtual root." |
|
0 | 1905 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
1906 |
%{ |
555 | 1907 |
int screen = __intVal(__INST(screen)); |
295 | 1908 |
Window root; |
1909 |
OBJ id; |
|
1910 |
||
555 | 1911 |
if (__INST(rootId) != nil) { |
1344 | 1912 |
RETURN (__INST(rootId)); |
295 | 1913 |
} |
0 | 1914 |
|
150 | 1915 |
if (ISCONNECTED) { |
1344 | 1916 |
root = RootWindow(myDpy, screen); |
1917 |
if (! root) { |
|
1918 |
id = nil; |
|
1919 |
} else { |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
1920 |
__INST(rootId) = id = __MKEXTERNALADDRESS(root); __STORE(self, id); |
1344 | 1921 |
} |
1922 |
RETURN (id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1923 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1924 |
%}. |
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1925 |
self primitiveFailed. |
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
1926 |
^ nil |
295 | 1927 |
! |
1928 |
||
1929 |
rootWindowFor:aView |
|
1930 |
|id| |
|
1931 |
||
1932 |
id := self rootWindowId. |
|
1933 |
self addKnownView:aView withId:id. |
|
0 | 1934 |
^ id |
1935 |
! |
|
1936 |
||
295 | 1937 |
rootWindowId |
1938 |
"return the id of the root window. |
|
1939 |
This is the window you see as background, |
|
1940 |
however, it may or may not be the real physical root window, |
|
1941 |
since some window managers install a virtual root window on top |
|
1942 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1943 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
1944 |
%{ |
555 | 1945 |
int screen = __intVal(__INST(screen)); |
295 | 1946 |
Window rootWin, vRootWin; |
1947 |
OBJ id; |
|
1948 |
||
555 | 1949 |
if (__INST(virtualRootId) != nil) { |
1344 | 1950 |
RETURN (__INST(virtualRootId)); |
295 | 1951 |
} |
0 | 1952 |
|
169 | 1953 |
if (ISCONNECTED) { |
1344 | 1954 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
295 | 1955 |
#ifndef IRIS |
1344 | 1956 |
BEGIN_INTERRUPTSBLOCKED |
1957 |
/* |
|
1958 |
* on IRIS, this creates a badwindow error - why ? |
|
1959 |
* children contains a funny window (000034) |
|
1960 |
*/ |
|
1961 |
||
1962 |
/* |
|
1963 |
* care for virtual root windows (tvtwm & friends) |
|
1964 |
*/ |
|
1965 |
{ |
|
1966 |
Atom vRootAtom = None; |
|
1967 |
int i; |
|
1968 |
Window rootReturn, parentReturn; |
|
1969 |
Window* children = (Window *)0; |
|
1970 |
unsigned int numChildren; |
|
1971 |
||
1972 |
if (XQueryTree(myDpy, rootWin, |
|
1973 |
&rootReturn, &parentReturn, |
|
1974 |
&children, &numChildren)) { |
|
1975 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1976 |
if (vRootAtom != None) { |
|
1977 |
for (i=0; i < numChildren; i++) { |
|
1978 |
Atom actual_type; |
|
1979 |
int actual_format; |
|
1980 |
unsigned long nitems, bytesafter; |
|
1981 |
Window* newRoot = (Window*) 0; |
|
1982 |
||
1983 |
if (children[i]) { |
|
1984 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1985 |
0L, 1L, False, XA_WINDOW, |
|
1986 |
&actual_type, &actual_format, |
|
1987 |
&nitems, &bytesafter, |
|
1988 |
(unsigned char**) &newRoot |
|
1989 |
) == Success && newRoot) { |
|
1990 |
vRootWin = *newRoot; |
|
1991 |
XFree(newRoot); /* XXX */ |
|
1992 |
break; |
|
1993 |
} |
|
1994 |
} |
|
1995 |
} |
|
1996 |
} |
|
1997 |
if (children) XFree( children ); |
|
1998 |
} |
|
1999 |
} |
|
2000 |
END_INTERRUPTSBLOCKED |
|
295 | 2001 |
#endif |
2002 |
} |
|
2003 |
||
2004 |
/* cannot happen */ |
|
2005 |
if (! vRootWin) { |
|
1344 | 2006 |
vRootWin = rootWin; |
2007 |
if (! rootWin) { |
|
2008 |
RETURN ( nil ); |
|
2009 |
} |
|
295 | 2010 |
} |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
2011 |
__INST(rootId) = id = __MKEXTERNALADDRESS(rootWin); __STORE(self, id); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
2012 |
__INST(virtualRootId) = id = __MKEXTERNALADDRESS(vRootWin); __STORE(self, id); |
295 | 2013 |
RETURN ( id ); |
63 | 2014 |
%} |
0 | 2015 |
! ! |
2016 |
||
2017 |
!XWorkstation methodsFor:'color stuff'! |
|
2018 |
||
295 | 2019 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2020 |
"allocate a color cell - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2021 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2022 |
|
2023 |
%{ /* NOCONTEXT */ |
|
2024 |
||
555 | 2025 |
int screen = __intVal(__INST(screen)); |
295 | 2026 |
XColor color; |
2027 |
unsigned long dummy; |
|
2028 |
Status ok; |
|
2029 |
||
1209 | 2030 |
if (ISCONNECTED) { |
1344 | 2031 |
Display *dpy = myDpy; |
2032 |
||
2033 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2034 |
ENTER_XLIB(); |
1344 | 2035 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
2036 |
&dummy, 0, &color.pixel, 1); |
|
1974 | 2037 |
LEAVE_XLIB(); |
1344 | 2038 |
END_INTERRUPTSBLOCKED |
2039 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2040 |
#ifdef COUNT_RESOURCES |
1344 | 2041 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2042 |
#endif |
1344 | 2043 |
RETURN ( __MKSMALLINT(color.pixel) ); |
2044 |
} |
|
0 | 2045 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2046 |
%}. |
43 | 2047 |
^ nil |
0 | 2048 |
! |
2049 |
||
2050 |
colorNamed:aString |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2051 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 2052 |
Dont use this method, colornames are mostly X specific" |
2053 |
||
2054 |
%{ /* NOCONTEXT */ |
|
2055 |
||
2056 |
char *colorname; |
|
2057 |
XColor scolor, ecolor; |
|
555 | 2058 |
int screen = __intVal(__INST(screen)); |
850 | 2059 |
int id; |
54 | 2060 |
Status ok; |
0 | 2061 |
|
150 | 2062 |
if (ISCONNECTED) { |
1344 | 2063 |
Display *dpy = myDpy; |
2064 |
||
2065 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1831 | 2066 |
colorname = (char *) __stringVal(aString); |
1344 | 2067 |
|
2068 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2069 |
ENTER_XLIB(); |
1344 | 2070 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
1974 | 2071 |
LEAVE_XLIB(); |
1344 | 2072 |
if (ok) { |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
2073 |
#ifdef QUICK_TRUE_COLORS |
1344 | 2074 |
if (__INST(visualType) == @symbol(TrueColor)) { |
2075 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
2076 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
2077 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
2078 |
RETURN ( __MKSMALLINT(id) ); |
|
2079 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
2080 |
#endif |
1974 | 2081 |
ENTER_XLIB(); |
1344 | 2082 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1974 | 2083 |
LEAVE_XLIB(); |
1344 | 2084 |
} |
2085 |
END_INTERRUPTSBLOCKED |
|
2086 |
if (! ok) { |
|
2087 |
RETURN ( nil ); |
|
2088 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2089 |
#ifdef COUNT_RESOURCES |
1344 | 2090 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2091 |
#endif |
1344 | 2092 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
2093 |
} |
|
0 | 2094 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2095 |
%}. |
43 | 2096 |
self primitiveFailed. |
2097 |
^ nil |
|
0 | 2098 |
! |
2099 |
||
295 | 2100 |
colorRed:redVal green:greenVal blue:blueVal |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2101 |
"allocate a color with rgb values (0..100) - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2102 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 2103 |
|
2104 |
|r g b| |
|
2105 |
||
2106 |
r := self percentToXColorValue:redVal. |
|
2107 |
g := self percentToXColorValue:greenVal. |
|
2108 |
b := self percentToXColorValue:blueVal. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2109 |
^ self colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2110 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2111 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2112 |
colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2113 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 2114 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
2115 |
Display *dpy; |
295 | 2116 |
XColor ecolor; |
555 | 2117 |
int screen = __intVal(__INST(screen)); |
295 | 2118 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2119 |
int id; |
295 | 2120 |
|
2121 |
if (__bothSmallInteger(r, g) |
|
2122 |
&& __isSmallInteger(b) |
|
2123 |
&& ISCONNECTED) { |
|
1344 | 2124 |
ecolor.red = __intVal(r); |
2125 |
ecolor.green= __intVal(g); |
|
2126 |
ecolor.blue = __intVal(b); |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2127 |
#ifdef QUICK_TRUE_COLORS |
1344 | 2128 |
if (__INST(visualType) == @symbol(TrueColor)) { |
2129 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
2130 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
2131 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
2132 |
RETURN ( __MKSMALLINT(id) ); |
|
2133 |
} |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2134 |
#endif |
1344 | 2135 |
dpy = myDpy; |
2136 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2137 |
ENTER_XLIB(); |
1344 | 2138 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1974 | 2139 |
LEAVE_XLIB(); |
1344 | 2140 |
END_INTERRUPTSBLOCKED |
2141 |
if (! ok) { |
|
2142 |
RETURN ( nil ); |
|
2143 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2144 |
#ifdef COUNT_RESOURCES |
1344 | 2145 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2146 |
#endif |
1344 | 2147 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 2148 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2149 |
%}. |
295 | 2150 |
self primitiveFailed. |
2151 |
^ nil |
|
2152 |
! |
|
2153 |
||
2154 |
freeColor:colorIndex |
|
2155 |
"free a display color when its no longer needed" |
|
0 | 2156 |
|
2157 |
%{ /* NOCONTEXT */ |
|
2158 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
2159 |
Display *dpy; |
295 | 2160 |
unsigned long color; |
555 | 2161 |
int screen = __intVal(__INST(screen)); |
295 | 2162 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2163 |
#ifdef QUICK_TRUE_COLORS |
555 | 2164 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1344 | 2165 |
/* no need to do anything on TrueColor displays ... */ |
2166 |
RETURN (self); |
|
295 | 2167 |
} |
2168 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2169 |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2170 |
if (! ISCONNECTED) { |
1344 | 2171 |
RETURN (self); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2172 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2173 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2174 |
if (__isSmallInteger(colorIndex)) { |
1344 | 2175 |
dpy = myDpy; |
2176 |
color = (long) __intVal(colorIndex); |
|
2177 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2178 |
ENTER_XLIB(); |
1344 | 2179 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
1974 | 2180 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2181 |
#ifdef COUNT_RESOURCES |
1344 | 2182 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2183 |
#endif |
1344 | 2184 |
END_INTERRUPTSBLOCKED |
2185 |
RETURN ( self ); |
|
0 | 2186 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2187 |
%}. |
295 | 2188 |
self primitiveFailed |
2189 |
! |
|
2190 |
||
2191 |
getRGBFrom:index into:aBlock |
|
2192 |
"get rgb components (0..100) of color in map at:index, |
|
2193 |
and evaluate the 3-arg block, aBlock with them" |
|
2194 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2195 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2196 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2197 |
self getScaledRGBFrom:index into:[:r :g :b | |
1344 | 2198 |
val := aBlock |
2199 |
value:(r * 100.0 / 16rFFFF) |
|
2200 |
value:(g * 100.0 / 16rFFFF) |
|
2201 |
value:(b * 100.0 / 16rFFFF) |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2202 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2203 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2204 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2205 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2206 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2207 |
"get rgb components (0..100) of color named colorName, |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2208 |
and evaluate the 3-arg block, aBlock with them" |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2209 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2210 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2211 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2212 |
r isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2213 |
^ nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2214 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2215 |
val := aBlock |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2216 |
value:(r * 100.0 / 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2217 |
value:(g * 100.0 / 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2218 |
value:(b * 100.0 / 16rFFFF) |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2219 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2220 |
^ val |
1056 | 2221 |
|
1430 | 2222 |
"Modified: 6.3.1997 / 02:36:43 / cg" |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2223 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2224 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2225 |
getScaledRGBFrom:index into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2226 |
"get rgb components (0 .. 16rFFFF) of color in map at:index, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2227 |
and evaluate the 3-arg block, aBlock with them" |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2228 |
|
295 | 2229 |
|r g b| |
2230 |
%{ |
|
555 | 2231 |
int screen = __intVal(__INST(screen)); |
295 | 2232 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2233 |
int sr, sg, sb; |
295 | 2234 |
int bits, scale, shift; |
2235 |
||
1209 | 2236 |
if (ISCONNECTED |
2237 |
&& __isSmallInteger(index)) { |
|
1344 | 2238 |
Display *dpy = myDpy; |
2239 |
||
2240 |
color.pixel = __intVal(index); |
|
2241 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2242 |
ENTER_XLIB(); |
1344 | 2243 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
1974 | 2244 |
LEAVE_XLIB(); |
1344 | 2245 |
END_INTERRUPTSBLOCKED |
2246 |
||
2247 |
/* |
|
2248 |
* have to compensate for an error in X ?, which does not scale |
|
2249 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2250 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2251 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2252 |
*/ |
|
2253 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2254 |
scale = (1<<bits) - 1; |
|
2255 |
shift = 16 - bits; |
|
2256 |
||
2257 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2258 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2259 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2260 |
r = __MKSMALLINT(sr); |
|
2261 |
g = __MKSMALLINT(sg); |
|
2262 |
b = __MKSMALLINT(sb); |
|
295 | 2263 |
} |
2264 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2265 |
^ aBlock value:r value:g value:b |
295 | 2266 |
! |
2267 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2268 |
getScaledRGBFromName:colorName into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2269 |
"get rgb components (0..16rFFFF) of color named colorName, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2270 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2271 |
|
2272 |
|r g b| |
|
2273 |
||
2274 |
displayId isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2275 |
self pimitiveFailed. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2276 |
^ nil |
295 | 2277 |
]. |
2278 |
%{ |
|
555 | 2279 |
int screen = __intVal(__INST(screen)); |
295 | 2280 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2281 |
int sr, sg, sb; |
295 | 2282 |
double floor(); |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2283 |
int bits, scale, shift; |
295 | 2284 |
|
1209 | 2285 |
if (ISCONNECTED |
2286 |
&& __isString(colorName) || __isSymbol(colorName)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2287 |
Display *dpy = myDpy; |
1209 | 2288 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2289 |
BEGIN_INTERRUPTSBLOCKED |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2290 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
1831 | 2291 |
(char *) __stringVal(colorName), &color)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2292 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2293 |
* have to compensate for an error in X ?, which does not scale |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2294 |
* colors correctly if lesser than 16bits are valid in a color, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2295 |
* (for example, color white on a 4bitsPerRGB server will return |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2296 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2297 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2298 |
bits = __intVal(__INST(bitsPerRGB)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2299 |
scale = (1<<bits) - 1; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2300 |
shift = 16 - bits; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2301 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2302 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2303 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2304 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2305 |
r = __MKSMALLINT(sr); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2306 |
g = __MKSMALLINT(sg); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2307 |
b = __MKSMALLINT(sb); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2308 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2309 |
END_INTERRUPTSBLOCKED |
295 | 2310 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2311 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2312 |
^ aBlock value:r value:g value:b |
295 | 2313 |
! |
2314 |
||
2315 |
listOfAvailableColors |
|
2316 |
"return a list of all available colornames. |
|
2317 |
This should not be used, since colornames are very |
|
2318 |
display-specific (here X-specific)." |
|
2319 |
||
2320 |
|aStream list line index colorName| |
|
2321 |
||
2322 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2323 |
aStream isNil ifTrue:[^ nil]. |
|
2324 |
list := OrderedCollection new. |
|
2325 |
[aStream atEnd] whileFalse:[ |
|
1344 | 2326 |
line := aStream nextLine. |
2327 |
line notNil ifTrue:[ |
|
2328 |
"skip the r/g/b numbers" |
|
2329 |
index := 1. |
|
2330 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2331 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2332 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2333 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2334 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2335 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2336 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2337 |
colorName := line copyFrom:index. |
|
2338 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2339 |
list add:colorName |
|
2340 |
] |
|
2341 |
] |
|
295 | 2342 |
]. |
2343 |
aStream close. |
|
2344 |
^ list sort |
|
1047 | 2345 |
|
2346 |
" |
|
2347 |
Screen current listOfAvailableColors |
|
2348 |
" |
|
2349 |
||
2350 |
"Modified: 11.9.1996 / 15:26:28 / stefan" |
|
295 | 2351 |
! |
2352 |
||
2353 |
percentToXColorValue:aPercentage |
|
2354 |
"given a color-component value in percent (0..100), return the corresponding |
|
2355 |
x-component value (0..65k) as an integer" |
|
2356 |
||
2357 |
%{ /* NOCONTEXT */ |
|
2358 |
||
2359 |
if (__isSmallInteger(aPercentage)) { |
|
1344 | 2360 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2361 |
} |
2362 |
if (__isFloat(aPercentage)) { |
|
1344 | 2363 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2364 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2365 |
%}. |
295 | 2366 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2367 |
! |
2368 |
||
892 | 2369 |
setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2370 |
"change color in map at:index to rgb (0..16rFFFF). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2371 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2372 |
|
2373 |
%{ /* NOCONTEXT */ |
|
2374 |
||
2375 |
char *colorname; |
|
2376 |
XColor color; |
|
555 | 2377 |
int screen = __intVal(__INST(screen)); |
0 | 2378 |
int r, g, b; |
2379 |
int ok = 1; |
|
2380 |
||
892 | 2381 |
if (__isSmallInteger(sred)) |
1344 | 2382 |
r = __intVal(sred); |
0 | 2383 |
else ok = 0; |
2384 |
||
892 | 2385 |
if (__isSmallInteger(sgreen)) |
1344 | 2386 |
g = __intVal(sgreen); |
0 | 2387 |
else ok = 0; |
2388 |
||
892 | 2389 |
if (__isSmallInteger(sblue)) |
1344 | 2390 |
b = __intVal(sblue); |
0 | 2391 |
else ok = 0; |
2392 |
||
1209 | 2393 |
if (ISCONNECTED |
2394 |
&& __isSmallInteger(index) && ok) { |
|
1344 | 2395 |
Display *dpy = myDpy; |
2396 |
||
2397 |
color.pixel = __intVal(index); |
|
2398 |
color.red = r; |
|
2399 |
color.green = g; |
|
2400 |
color.blue = b; |
|
2401 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2402 |
||
2403 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2404 |
ENTER_XLIB(); |
1344 | 2405 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
1974 | 2406 |
LEAVE_XLIB(); |
1344 | 2407 |
END_INTERRUPTSBLOCKED |
2408 |
RETURN ( self ); |
|
0 | 2409 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2410 |
%}. |
0 | 2411 |
self primitiveFailed |
295 | 2412 |
! ! |
2413 |
||
2414 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2415 |
||
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2416 |
builtInCursorShapes |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2417 |
"return a collection of standard cursor names. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2418 |
Those are built into the XServer and need not be created as |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2419 |
user cursors. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2420 |
(actually, there are more than those below ...)" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2421 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2422 |
"/ if you add something here, also add to #shapeNumberFromCursor ... |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2423 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2424 |
^ #( |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2425 |
#upLeftArrow "/ XC_top_left_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2426 |
#upRightHand "/ XC_hand1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2427 |
#upDownArrow "/ XC_sb_v_double_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2428 |
#leftRightArrow "/ XC_sb_h_double_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2429 |
#upLimitArrow "/ XC_top_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2430 |
#downLimitArrow "/ XC_bottom_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2431 |
#leftLimitArrow "/ XC_left_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2432 |
#rightLimitArrow "/ XC_right_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2433 |
#text "/ XC_xterm |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2434 |
#upRightArrow "/ XC_draft_large |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2435 |
#leftHand "/ XC_hand2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2436 |
#questionMark "/ XC_question_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2437 |
#cross "/ XC_X_cursor |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2438 |
#wait "/ XC_watch |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2439 |
#crossHair "/ XC_tcross |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2440 |
#origin "/ XC_ul_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2441 |
#topLeft "/ XC_ul_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2442 |
#corner "/ XC_lr_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2443 |
#bottomRight "/ XC_lr_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2444 |
#topRight "/ XC_ur_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2445 |
#bottomLeft "/ XC_ll_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2446 |
#square "/ XC_dotbox |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2447 |
#fourWay "/ XC_fleur |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2448 |
#crossCursor "/ XC_X_cursor |
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2449 |
) |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2450 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2451 |
"Created: 8.4.1997 / 10:12:30 / cg" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2452 |
"Modified: 8.4.1997 / 10:31:46 / cg" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2453 |
! |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2454 |
|
295 | 2455 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
2456 |
"change a cursors colors" |
|
2457 |
||
2458 |
|fgR fgG fgB bgR bgG bgB| |
|
2459 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2460 |
fgR := fgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2461 |
fgG := fgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2462 |
fgB := fgColor scaledBlue. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2463 |
bgR := bgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2464 |
bgG := bgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2465 |
bgB := bgColor scaledBlue. |
0 | 2466 |
%{ |
295 | 2467 |
XColor fgcolor, bgcolor; |
2468 |
||
1209 | 2469 |
if (ISCONNECTED |
2470 |
&& __isExternalAddress(aCursorId) |
|
295 | 2471 |
&& __bothSmallInteger(fgG, fgB) |
2472 |
&& __bothSmallInteger(bgR, bgG) |
|
2473 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2474 |
||
1344 | 2475 |
fgcolor.red = __intVal(fgR); |
2476 |
fgcolor.green= __intVal(fgG); |
|
2477 |
fgcolor.blue = __intVal(fgB); |
|
2478 |
bgcolor.red = __intVal(bgR); |
|
2479 |
bgcolor.green= __intVal(bgG); |
|
2480 |
bgcolor.blue = __intVal(bgB); |
|
2481 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2482 |
ENTER_XLIB(); |
1344 | 2483 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
1974 | 2484 |
LEAVE_XLIB(); |
1344 | 2485 |
END_INTERRUPTSBLOCKED |
2486 |
RETURN ( self ); |
|
72 | 2487 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2488 |
%}. |
0 | 2489 |
self primitiveFailed |
70 | 2490 |
! |
2491 |
||
295 | 2492 |
createCursorShape:aShape |
974 | 2493 |
"create a cursor given a shape-symbol. This only works |
2494 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
2495 |
Senders must always care for a fallBack, in case of a nil return." |
295 | 2496 |
|
2497 |
|number id| |
|
2498 |
||
2499 |
number := self shapeNumberFromSymbol:aShape. |
|
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
2500 |
number isNil ifTrue:[^ nil]. |
295 | 2501 |
%{ |
2502 |
Cursor newCursor; |
|
2503 |
||
1209 | 2504 |
if (ISCONNECTED |
2505 |
&& __isSmallInteger(number)) { |
|
1344 | 2506 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 2507 |
ENTER_XLIB(); |
1344 | 2508 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
1974 | 2509 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2510 |
#ifdef COUNT_RESOURCES |
1344 | 2511 |
if (newCursor) |
2512 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2513 |
#endif |
1344 | 2514 |
END_INTERRUPTSBLOCKED |
2515 |
if (newCursor != (Cursor)0) { |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
2516 |
id = __MKEXTERNALADDRESS(newCursor); |
1344 | 2517 |
} |
0 | 2518 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2519 |
%}. |
295 | 2520 |
^ id |
2521 |
! |
|
2522 |
||
974 | 2523 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2524 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2525 |
||
2526 |
|id sourceId maskId| |
|
2527 |
||
2528 |
sourceId := sourceForm id. |
|
2529 |
maskId := maskForm id. |
|
2530 |
%{ |
|
2531 |
Cursor newCursor; |
|
2532 |
XColor fgColor, bgColor; |
|
2533 |
||
1209 | 2534 |
if (ISCONNECTED |
2535 |
&& __isExternalAddress(sourceId) |
|
295 | 2536 |
&& __isExternalAddress(maskId) |
2537 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2538 |
fgColor.red = 0; /* fg is black */ |
2539 |
fgColor.green = 0; |
|
2540 |
fgColor.blue = 0; |
|
2541 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2542 |
bgColor.green = 0xFFFF; |
|
2543 |
bgColor.blue = 0xFFFF; |
|
2544 |
||
2545 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2546 |
ENTER_XLIB(); |
1344 | 2547 |
newCursor = XCreatePixmapCursor(myDpy, |
2548 |
_PixmapVal(sourceId), |
|
2549 |
_PixmapVal(maskId), |
|
2550 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
1974 | 2551 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2552 |
#ifdef COUNT_RESOURCES |
1344 | 2553 |
if (newCursor) |
2554 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2555 |
#endif |
1344 | 2556 |
END_INTERRUPTSBLOCKED |
2557 |
if (newCursor != (Cursor)0) { |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
2558 |
id = __MKEXTERNALADDRESS(newCursor); |
1344 | 2559 |
} |
0 | 2560 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2561 |
%}. |
1838
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
2562 |
id isNil ifTrue:[ |
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
2563 |
self primitiveFailed. |
040e4689dfcd
oops - do not return self from failing primCreateBitmap
Claus Gittinger <cg@exept.de>
parents:
1835
diff
changeset
|
2564 |
]. |
295 | 2565 |
^ id |
2566 |
! |
|
2567 |
||
2568 |
destroyCursor:aCursorId |
|
974 | 2569 |
"release a cursor - frees any device resources" |
0 | 2570 |
|
2571 |
%{ /* NOCONTEXT */ |
|
2572 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2573 |
if (! ISCONNECTED) { |
1344 | 2574 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2575 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2576 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2577 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2578 |
Cursor curs = _CursorVal(aCursorId); |
2579 |
||
2580 |
if (curs) { |
|
2581 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 2582 |
ENTER_XLIB(); |
1344 | 2583 |
XFreeCursor(myDpy, curs); |
1974 | 2584 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2585 |
#ifdef COUNT_RESOURCES |
1344 | 2586 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2587 |
#endif |
1344 | 2588 |
END_INTERRUPTSBLOCKED |
2589 |
} |
|
2590 |
RETURN ( self ); |
|
0 | 2591 |
} |
974 | 2592 |
%}. |
0 | 2593 |
self primitiveFailed |
295 | 2594 |
! |
2595 |
||
974 | 2596 |
needDeviceFormsForCursor |
2597 |
^ true |
|
2598 |
! |
|
2599 |
||
295 | 2600 |
shapeNumberFromSymbol:shape |
974 | 2601 |
"given a shape-symbol, return the corresponding cursor-number, |
2602 |
or nil if no such standard cursor exists." |
|
295 | 2603 |
|
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2604 |
"/this is pure X-knowlegde - but you may easily add more |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2605 |
"/ if you add something here, also add to #builtInCursorShapes ... |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2606 |
|
295 | 2607 |
|
2608 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2609 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2610 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2611 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2612 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2613 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2614 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2615 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2616 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2617 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2618 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2619 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2620 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2621 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2622 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2623 |
((shape == #origin) |
|
2624 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2625 |
((shape == #corner) |
|
2626 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2627 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2628 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2629 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2630 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2631 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2632 |
|
2633 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2634 |
^ nil |
0 | 2635 |
! ! |
2636 |
||
1543 | 2637 |
!XWorkstation methodsFor:'drag & drop'! |
2638 |
||
1556 | 2639 |
dndDrop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
2640 |
"drop something in some alien view, using the DND protocol. |
|
2641 |
Returns false, if the drop could not be performed." |
|
2642 |
||
2643 |
|msgType dropColl anyFile anyDir anyText anyOther |
|
2644 |
dropType dropTypeCode strings sz idx val| |
|
2645 |
||
2646 |
(msgType := self atomIDOf:'DndProtocol') notNil ifTrue:[ |
|
2647 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2648 |
"/ DND can drop files, file, dir, links, dirLink and text |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2649 |
"/ check for this. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2650 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2651 |
dropObjects isCollection ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2652 |
dropColl := Array with:dropObjects |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2653 |
] ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2654 |
dropColl := dropObjects |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2655 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2656 |
anyFile := anyDir := anyText := anyOther := false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2657 |
dropColl do:[:aDropObject | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2658 |
aDropObject isFileObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2659 |
aDropObject theObject isDirectory ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2660 |
anyDir := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2661 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2662 |
anyFile := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2663 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2664 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2665 |
aDropObject isTextObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2666 |
anyText := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2667 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2668 |
anyOther := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2669 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2670 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2671 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2672 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2673 |
anyOther ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2674 |
"/ DND does not support this ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2675 |
'XWorkstation [info]: DND can only drop files or text' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2676 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2677 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2678 |
anyText ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2679 |
(anyFile or:[anyDir]) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2680 |
"/ DND does not support mixed types |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2681 |
'XWorkstation [info]: DND cannot drop both files and text' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2682 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2683 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2684 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2685 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2686 |
anyFile ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2687 |
dropType := #DndFiles. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2688 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2689 |
dropType := #DndFile |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2690 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2691 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2692 |
anyDir ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2693 |
dropType := #DndFiles. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2694 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2695 |
dropType := #DndDir |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2696 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2697 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2698 |
anyText ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2699 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2700 |
dropType := #DndText |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2701 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2702 |
"/ can only drop a single text object |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2703 |
'XWorkstation [info]: DND can only drop a single text' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2704 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2705 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2706 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2707 |
"/ mhmh ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2708 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2709 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2710 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2711 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2712 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2713 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2714 |
dropTypeCode := self dndDropTypes indexOf:dropType. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2715 |
dropTypeCode == 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2716 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2717 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2718 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2719 |
dropTypeCode := dropTypeCode - 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2720 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2721 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2722 |
"/ place the selection inTo the DndSelection property |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2723 |
"/ of the rootView ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2724 |
"/ ... need a single string, with 0-terminated parts. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2725 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2726 |
strings := OrderedCollection new. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2727 |
sz := 0. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2728 |
dropColl do:[:anObject | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2729 |
|s| |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2730 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2731 |
anObject isFileObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2732 |
s := anObject theObject pathName asString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2733 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2734 |
s := anObject theObject asString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2735 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2736 |
strings add:s. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2737 |
sz := sz + (s size) + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2738 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2739 |
val := String new:sz. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2740 |
idx := 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2741 |
strings do:[:aString | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2742 |
val replaceFrom:idx to:(idx + aString size - 1) with:aString startingAt:1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2743 |
idx := idx + aString size. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2744 |
val at:idx put:(Character value:0). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2745 |
idx := idx + 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2746 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2747 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2748 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2749 |
setProperty:(self atomIDOf:'DndSelection') |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2750 |
type:(stringAtom) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2751 |
value:val |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2752 |
for:rootId. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2753 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2754 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2755 |
sendClientEvent:msgType |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2756 |
format:32 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2757 |
to:destinationId |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2758 |
data1:dropTypeCode |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2759 |
data2:0 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2760 |
data3:(destinationId) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2761 |
data4:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2762 |
data5:nil. |
1556 | 2763 |
]. |
2764 |
||
2765 |
^ false |
|
2766 |
||
2767 |
"Created: 6.4.1997 / 13:39:37 / cg" |
|
1558 | 2768 |
"Modified: 6.4.1997 / 14:30:43 / cg" |
1556 | 2769 |
! |
2770 |
||
2771 |
dndDropTypes |
|
2772 |
"return the dropTypes as supported by DND" |
|
2773 |
||
2774 |
^ #( |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2775 |
DndUnknown "/ 0 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2776 |
DndRawData "/ 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2777 |
DndFile "/ 2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2778 |
DndFiles "/ 3 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2779 |
DndText "/ 4 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2780 |
DndDir "/ 5 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2781 |
DndLink "/ 6 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2782 |
DndExe "/ 7 |
1556 | 2783 |
) |
2784 |
||
2785 |
"Created: 6.4.1997 / 12:57:56 / cg" |
|
2786 |
"Modified: 6.4.1997 / 13:38:52 / cg" |
|
2787 |
! |
|
2788 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2789 |
drop:aCollectionOfDropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
1556 | 2790 |
"drop something in some alien view. |
2791 |
Returns false, if the drop could not be performed." |
|
2792 |
||
2793 |
"/ |
|
1543 | 2794 |
"/ see, if the display supports the DND protocol ... |
1556 | 2795 |
"/ |
1543 | 2796 |
(self atomIDOf:'DndProtocol') notNil ifTrue:[ |
1694 | 2797 |
^ self |
2798 |
dndDrop:aCollectionOfDropObjects |
|
2799 |
inWindowID:destinationId |
|
2800 |
position:destinationPoint |
|
2801 |
rootPosition:rootPoint |
|
1543 | 2802 |
]. |
2803 |
||
1556 | 2804 |
"/ add more drag&drop protocols here. |
2805 |
||
2806 |
^ false |
|
2807 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2808 |
"Modified: 11.4.1997 / 12:44:50 / cg" |
1543 | 2809 |
! ! |
2810 |
||
0 | 2811 |
!XWorkstation methodsFor:'drawing'! |
2812 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2813 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2814 |
"do a bit-blt; copy bits from the rectangle defined by |
2815 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2816 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2817 |
argument is not integer." |
|
0 | 2818 |
|
2819 |
%{ /* NOCONTEXT */ |
|
2820 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2821 |
GC gc; |
0 | 2822 |
Drawable source, dest; |
2823 |
||
1209 | 2824 |
if (ISCONNECTED |
2825 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2826 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2827 |
&& __isExternalAddress(destId) |
97 | 2828 |
&& __bothSmallInteger(w, h) |
2829 |
&& __bothSmallInteger(srcX, srcY) |
|
2830 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1848 | 2831 |
int _sX, _sY, _w, _h, _dX, _dY; |
2832 |
||
2833 |
_sX = __intVal(srcX); |
|
2834 |
_sY = __intVal(srcY); |
|
2835 |
_w = __intVal(w); |
|
2836 |
_h = __intVal(h); |
|
2837 |
_dX = __intVal(dstX); |
|
2838 |
_dY = __intVal(dstY); |
|
2839 |
||
1344 | 2840 |
gc = _GCVal(dstGCId); |
2841 |
source = (Drawable) _WindowVal(sourceId); |
|
2842 |
dest = (Drawable) _WindowVal(destId); |
|
1974 | 2843 |
ENTER_XLIB(); |
1848 | 2844 |
XCopyArea(myDpy, source, dest, gc, _sX, _sY, _w, _h, _dX, _dY); |
1974 | 2845 |
LEAVE_XLIB(); |
1344 | 2846 |
RETURN ( self ); |
0 | 2847 |
} |
118 | 2848 |
%}. |
2849 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2850 |
or any non integer coordinate" |
|
2851 |
||
0 | 2852 |
self primitiveFailed |
2853 |
! |
|
2854 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2855 |
copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2856 |
"do a bit-blt from a pix- or bitmap; copy bits from the rectangle defined by |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2857 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2858 |
below dstX/dstY in the destId drawable. Trigger an error if any |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2859 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2860 |
This is basically the same as copyFromId:..., but does not generate expose events." |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2861 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2862 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2863 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2864 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2865 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2866 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2867 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2868 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2869 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2870 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2871 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2872 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2873 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2874 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2875 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2876 |
gc = _GCVal(dstGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2877 |
source = (Drawable) _WindowVal(sourceId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2878 |
dest = (Drawable) _WindowVal(destId); |
1974 | 2879 |
ENTER_XLIB(); |
1344 | 2880 |
XSetGraphicsExposures(dpy, gc, 0); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2881 |
XCopyArea(dpy, source, dest, gc, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2882 |
__intVal(srcX), __intVal(srcY), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2883 |
__intVal(w), __intVal(h), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2884 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2885 |
XSetGraphicsExposures(dpy, gc, 1); |
1974 | 2886 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2887 |
RETURN ( self ); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2888 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2889 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2890 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2891 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2892 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2893 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2894 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2895 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2896 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2897 |
"do a bit-blt, but only copy the low-bit plane; |
2898 |
copy bits from the rectangle defined by |
|
2899 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2900 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2901 |
argument is not integer." |
|
0 | 2902 |
|
2903 |
%{ /* NOCONTEXT */ |
|
2904 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2905 |
GC gc; |
0 | 2906 |
Drawable source, dest; |
2907 |
||
1209 | 2908 |
if (ISCONNECTED |
2909 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2910 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2911 |
&& __isExternalAddress(destId) |
97 | 2912 |
&& __bothSmallInteger(w, h) |
2913 |
&& __bothSmallInteger(srcX, srcY) |
|
2914 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2915 |
gc = _GCVal(dstGCId); |
2916 |
source = (Drawable) _WindowVal(sourceId); |
|
2917 |
dest = (Drawable) _WindowVal(destId); |
|
1974 | 2918 |
ENTER_XLIB(); |
1344 | 2919 |
XCopyPlane(myDpy, source, dest, gc, |
2920 |
__intVal(srcX), __intVal(srcY), |
|
2921 |
__intVal(w), __intVal(h), |
|
2922 |
__intVal(dstX), __intVal(dstY), 1); |
|
1974 | 2923 |
LEAVE_XLIB(); |
1344 | 2924 |
RETURN ( self ); |
0 | 2925 |
} |
118 | 2926 |
%}. |
2927 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2928 |
or any non integer coordinate" |
|
2929 |
||
0 | 2930 |
self primitiveFailed |
2931 |
! |
|
2932 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2933 |
copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2934 |
"do a bit-blt from a pix- or bitmap, but only copy the low-bit plane; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2935 |
copy bits from the rectangle defined by |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2936 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2937 |
below dstX/dstY in the destId drawable. Trigger an error if any |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2938 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2939 |
This is the same as copyPlaneFromId:..., but does not generate graphics exposes" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2940 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2941 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2942 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2943 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2944 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2945 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2946 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2947 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2948 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2949 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2950 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2951 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2952 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2953 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2954 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2955 |
gc = _GCVal(dstGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2956 |
source = (Drawable) _WindowVal(sourceId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2957 |
dest = (Drawable) _WindowVal(destId); |
1974 | 2958 |
ENTER_XLIB(); |
1344 | 2959 |
XSetGraphicsExposures(dpy, gc, 0); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2960 |
XCopyPlane(dpy, source, dest, gc, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2961 |
__intVal(srcX), __intVal(srcY), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2962 |
__intVal(w), __intVal(h), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2963 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2964 |
XSetGraphicsExposures(dpy, gc, 1); |
1974 | 2965 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2966 |
RETURN ( self ); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2967 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2968 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2969 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2970 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2971 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2972 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2973 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2974 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2975 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2976 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2977 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2978 |
|
2979 |
%{ /* NOCONTEXT */ |
|
2980 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2981 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2982 |
Window win; |
0 | 2983 |
int w, h, angle1, angle2; |
2984 |
double f; |
|
2985 |
||
97 | 2986 |
if (__isSmallInteger(startAngle)) |
1344 | 2987 |
angle1 = __intVal(startAngle) * 64; |
36 | 2988 |
else if (__isFloat(startAngle)) { |
1344 | 2989 |
f = __floatVal(startAngle); |
2990 |
angle1 = f * 64; |
|
0 | 2991 |
} |
97 | 2992 |
if (__isSmallInteger(angle)) |
1344 | 2993 |
angle2 = __intVal(angle) * 64; |
36 | 2994 |
else if (__isFloat(angle)) { |
1344 | 2995 |
f = __floatVal(angle); |
2996 |
angle2 = f * 64; |
|
0 | 2997 |
} |
1209 | 2998 |
if (ISCONNECTED |
2999 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3000 |
&& __isExternalAddress(aDrawableId) |
97 | 3001 |
&& __bothSmallInteger(x, y) |
3002 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3003 |
win = _WindowVal(aDrawableId); |
3004 |
gc = _GCVal(aGCId); |
|
3005 |
w = __intVal(width); |
|
3006 |
h = __intVal(height); |
|
3007 |
/* |
|
3008 |
* need this check here: some servers simply dump core with bad args |
|
3009 |
*/ |
|
3010 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
1974 | 3011 |
ENTER_XLIB(); |
1344 | 3012 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
3013 |
w, h, angle1, angle2); |
|
1974 | 3014 |
LEAVE_XLIB(); |
1344 | 3015 |
} |
3016 |
RETURN ( self ); |
|
0 | 3017 |
} |
73 | 3018 |
%}. |
3019 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3020 |
self primitiveFailed |
3021 |
! |
|
3022 |
||
295 | 3023 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
3024 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
3025 |
||
3026 |
%{ /* NOCONTEXT */ |
|
3027 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3028 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3029 |
Window win; |
295 | 3030 |
|
1209 | 3031 |
if (ISCONNECTED |
3032 |
&& __isExternalAddress(aGCId) |
|
295 | 3033 |
&& __isExternalAddress(aDrawableId) |
3034 |
&& __bothSmallInteger(x0, y0) |
|
3035 |
&& __bothSmallInteger(x1, y1)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3036 |
gc = _GCVal(aGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3037 |
win = _WindowVal(aDrawableId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3038 |
|
1974 | 3039 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3040 |
if ((x0 == x1) && (y0 == y1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3041 |
XDrawPoint(myDpy, win, gc, __intVal(x0), __intVal(y0)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3042 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3043 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3044 |
__intVal(x1), __intVal(y1)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3045 |
} |
1974 | 3046 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3047 |
RETURN ( self ); |
295 | 3048 |
} |
3049 |
%}. |
|
3050 |
"badGC, badDrawable or coordinates not integer" |
|
3051 |
self primitiveFailed |
|
3052 |
! |
|
3053 |
||
1978 | 3054 |
displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId |
3055 |
"draw a polygon starting at x; the y values derives from the collection yValues. |
|
3056 |
The associated x is a multiple of step. Each y value will be scaled and translated |
|
3057 |
" |
|
3058 |
||
3059 |
|noY| |
|
3060 |
||
3061 |
(noY := yValues size) < 2 ifTrue:[ |
|
3062 |
^ self |
|
3063 |
]. |
|
3064 |
||
3065 |
%{ |
|
3066 |
OBJ yA, t; |
|
3067 |
int i, num; |
|
3068 |
float y, x, sY, tY, step; |
|
3069 |
GC gc; |
|
3070 |
XPoint * points; |
|
3071 |
XPoint qPoints[200]; |
|
3072 |
int mustFree = 0; |
|
3073 |
||
3074 |
Window win; |
|
3075 |
||
3076 |
if (ISCONNECTED |
|
3077 |
&& __isExternalAddress(aGCId) |
|
3078 |
&& __isExternalAddress(aDrawableId) ) { |
|
3079 |
gc = _GCVal(aGCId); |
|
3080 |
win = _WindowVal(aDrawableId); |
|
3081 |
||
3082 |
if( __isSmallInteger(scaleY) ) sY = (float) __intVal( scaleY ); |
|
3083 |
else if (__isFloat(scaleY)) sY = __floatVal( scaleY ); |
|
3084 |
else { |
|
3085 |
t = __SSEND0(scaleY, @symbol(asFloat), 0); |
|
3086 |
if (! __isFloat(t)) goto fail; |
|
3087 |
sY = __floatVal( t ); |
|
3088 |
} |
|
3089 |
||
3090 |
if( __isSmallInteger(transY) ) tY = (float) __intVal( transY ); |
|
3091 |
else if (__isFloat(transY)) tY = __floatVal( transY ); |
|
3092 |
else { |
|
3093 |
t = __SSEND0(transY, @symbol(asFloat), 0); |
|
3094 |
if (! __isFloat(t)) goto fail; |
|
3095 |
tY = __floatVal( t ); |
|
3096 |
} |
|
3097 |
||
3098 |
if( __isSmallInteger(startX) ) x = (float) __intVal( startX ); |
|
3099 |
else if (__isFloat(startX)) x = __floatVal( startX ); |
|
3100 |
else { |
|
3101 |
t = __SSEND0(startX, @symbol(asFloat), 0); |
|
3102 |
if (! __isFloat(t)) goto fail; |
|
3103 |
x = __floatVal( t ); |
|
3104 |
} |
|
3105 |
||
3106 |
if( __isSmallInteger(stepX) ) step = (float) __intVal( stepX ); |
|
3107 |
else if (__isFloat(stepX)) step = __floatVal( stepX ); |
|
3108 |
else { |
|
3109 |
t = __SSEND0(stepX, @symbol(asFloat), 0); |
|
3110 |
if (! __isFloat(t)) goto fail; |
|
3111 |
step = __floatVal( t ); |
|
3112 |
} |
|
3113 |
||
3114 |
num = __intVal( noY ); |
|
3115 |
||
3116 |
if( num > 200 ) |
|
3117 |
{ |
|
3118 |
if( ! (points = (XPoint *) malloc ( sizeof(XPoint) * num )) ) |
|
3119 |
goto fail; |
|
3120 |
||
3121 |
mustFree = 1; |
|
3122 |
} |
|
3123 |
else |
|
3124 |
points = qPoints; |
|
3125 |
||
3126 |
for( i = 0; i < num; ++i ) |
|
3127 |
{ |
|
3128 |
yA = __AT_(yValues, __MKSMALLINT(i+1) ); |
|
3129 |
||
3130 |
if( __isFloat(yA) ) |
|
3131 |
y = __floatVal( yA ); |
|
3132 |
else if( __isSmallInteger(yA) ) |
|
3133 |
y = (float) __intVal( yA ); |
|
3134 |
else { |
|
3135 |
t = __SSEND0(yA, @symbol(asFloat), 0); |
|
3136 |
if (! __isFloat(t)) goto fail; |
|
3137 |
y = __floatVal( t ); |
|
3138 |
} |
|
3139 |
||
3140 |
points[i].x = (int) (x + 0.5); |
|
3141 |
points[i].y = (int) ((y * sY) + tY + 0.5); |
|
3142 |
x = x + step; |
|
3143 |
} |
|
3144 |
||
1979 | 3145 |
ENTER_XLIB(); |
1978 | 3146 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
1979 | 3147 |
LEAVE_XLIB(); |
1978 | 3148 |
|
3149 |
if( mustFree ) |
|
3150 |
free( points ); |
|
3151 |
||
3152 |
RETURN ( self ); |
|
3153 |
} |
|
3154 |
||
3155 |
fail: |
|
3156 |
if( mustFree ) |
|
3157 |
free( points ); |
|
3158 |
%}. |
|
3159 |
||
3160 |
self primitiveFailed |
|
3161 |
||
3162 |
! |
|
3163 |
||
295 | 3164 |
displayPointX:x y:y in:aDrawableId with:aGCId |
3165 |
"draw a point. If x/y are not integers, an error is triggered." |
|
3166 |
||
3167 |
%{ /* NOCONTEXT */ |
|
3168 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3169 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3170 |
Window win; |
295 | 3171 |
|
1209 | 3172 |
if (ISCONNECTED |
3173 |
&& __isExternalAddress(aGCId) |
|
295 | 3174 |
&& __isExternalAddress(aDrawableId) |
3175 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3176 |
gc = _GCVal(aGCId); |
3177 |
win = _WindowVal(aDrawableId); |
|
1974 | 3178 |
|
3179 |
ENTER_XLIB(); |
|
1344 | 3180 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
1974 | 3181 |
LEAVE_XLIB(); |
3182 |
||
1344 | 3183 |
RETURN ( self ); |
295 | 3184 |
} |
3185 |
%}. |
|
3186 |
"badGC, badDrawable or x/y not integer" |
|
3187 |
self primitiveFailed |
|
3188 |
! |
|
3189 |
||
3190 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
3191 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
3192 |
define the polygon. |
|
3193 |
If any coordinate is not integer, an error is triggered." |
|
3194 |
||
3195 |
|numberOfPoints newPoints| |
|
3196 |
||
3197 |
numberOfPoints := aPolygon size. |
|
3198 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3199 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3200 |
Window win; |
295 | 3201 |
OBJ point, x, y; |
3202 |
int i, num; |
|
3203 |
XPoint *points; |
|
3204 |
XPoint qPoints[100]; |
|
377 | 3205 |
int mustFree = 0; |
295 | 3206 |
|
1209 | 3207 |
if (ISCONNECTED |
3208 |
&& __isExternalAddress(aGCId) |
|
295 | 3209 |
&& __isExternalAddress(aDrawableId) |
3210 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 3211 |
gc = _GCVal(aGCId); |
3212 |
win = _WindowVal(aDrawableId); |
|
3213 |
num = __intVal(numberOfPoints); |
|
3214 |
/* |
|
3215 |
* avoid a (slow) malloc, if the number of points is small |
|
3216 |
*/ |
|
3217 |
if (num > 100) { |
|
3218 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
3219 |
if (! points) goto fail; |
|
3220 |
mustFree = 1; |
|
3221 |
} else |
|
3222 |
points = qPoints; |
|
3223 |
||
3224 |
for (i=0; i<num; i++) { |
|
3225 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3226 |
if (! __isPoint(point)) goto fail; |
|
3227 |
x = _point_X(point); |
|
3228 |
y = _point_Y(point); |
|
3229 |
if (! __bothSmallInteger(x, y)) |
|
3230 |
goto fail; |
|
3231 |
points[i].x = __intVal(x); |
|
3232 |
points[i].y = __intVal(y); |
|
3233 |
} |
|
1974 | 3234 |
|
3235 |
ENTER_XLIB(); |
|
1344 | 3236 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
1974 | 3237 |
LEAVE_XLIB(); |
3238 |
||
1344 | 3239 |
if (mustFree) |
3240 |
free(points); |
|
3241 |
RETURN ( self ); |
|
295 | 3242 |
} |
3243 |
fail: ; |
|
377 | 3244 |
if (mustFree) |
1344 | 3245 |
free(points); |
295 | 3246 |
%}. |
3247 |
"badGC, badDrawable or coordinates not integer" |
|
3248 |
self primitiveFailed |
|
3249 |
! |
|
3250 |
||
3251 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
3252 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
3253 |
||
3254 |
%{ /* NOCONTEXT */ |
|
3255 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3256 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3257 |
Window win; |
295 | 3258 |
int w, h; |
3259 |
||
1209 | 3260 |
if (ISCONNECTED |
3261 |
&& __isExternalAddress(aGCId) |
|
295 | 3262 |
&& __isExternalAddress(aDrawableId) |
3263 |
&& __bothSmallInteger(x, y) |
|
3264 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3265 |
gc = _GCVal(aGCId); |
3266 |
win = _WindowVal(aDrawableId); |
|
3267 |
w = __intVal(width); |
|
3268 |
h = __intVal(height); |
|
3269 |
/* |
|
3270 |
* need this check here: some servers simply dump core with bad args |
|
3271 |
*/ |
|
3272 |
if ((w >= 0) && (h >= 0)) { |
|
1974 | 3273 |
ENTER_XLIB(); |
1344 | 3274 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
1974 | 3275 |
LEAVE_XLIB(); |
1344 | 3276 |
} |
3277 |
RETURN ( self ); |
|
295 | 3278 |
} |
3279 |
%}. |
|
3280 |
"badGC, badDrawable or coordinates not integer" |
|
3281 |
self primitiveFailed |
|
3282 |
! |
|
3283 |
||
3284 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3285 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
3286 |
foreground and background characters. |
|
3287 |
If the coordinates are not integers, an error is triggered." |
|
3288 |
||
3289 |
%{ /* NOCONTEXT */ |
|
3290 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3291 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3292 |
Window win; |
1831 | 3293 |
char *cp; |
295 | 3294 |
OBJ cls; |
3295 |
int i1, i2, l, n; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3296 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3297 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3298 |
int nInstBytes; |
295 | 3299 |
|
1209 | 3300 |
if (ISCONNECTED |
3301 |
&& __isExternalAddress(aGCId) |
|
295 | 3302 |
&& __isExternalAddress(aDrawableId) |
3303 |
&& __isNonNilObject(aString) |
|
3304 |
&& __bothSmallInteger(index1, index2) |
|
3305 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3306 |
gc = _GCVal(aGCId); |
3307 |
win = _WindowVal(aDrawableId); |
|
3308 |
cls = __qClass(aString); |
|
3309 |
||
3310 |
i1 = __intVal(index1) - 1; |
|
3311 |
if (i1 >= 0) { |
|
3312 |
i2 = __intVal(index2) - 1; |
|
3313 |
if (i2 < i1) { |
|
3314 |
RETURN (self); |
|
3315 |
} |
|
3316 |
||
1831 | 3317 |
cp = (char *) __stringVal(aString); |
1344 | 3318 |
l = i2 - i1 + 1; |
3319 |
||
3320 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3321 |
n = _stringSize(aString); |
|
3322 |
if (i2 < n) { |
|
3323 |
cp += i1; |
|
3324 |
if (l > 1000) l = 1000; |
|
1974 | 3325 |
ENTER_XLIB(); |
1344 | 3326 |
if (opaque == true) |
1831 | 3327 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), cp, l); |
1344 | 3328 |
else |
1831 | 3329 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), cp, l); |
1974 | 3330 |
LEAVE_XLIB(); |
1344 | 3331 |
RETURN ( self ); |
3332 |
} |
|
3333 |
} |
|
3334 |
||
3335 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3336 |
cp += nInstBytes; |
|
3337 |
||
3338 |
if (__isBytes(aString)) { |
|
3339 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3340 |
||
3341 |
if (i2 < n) { |
|
3342 |
cp += i1; |
|
3343 |
if (l > 1000) l = 1000; |
|
1974 | 3344 |
ENTER_XLIB(); |
1344 | 3345 |
if (opaque == true) |
1831 | 3346 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), cp, l); |
1344 | 3347 |
else |
1831 | 3348 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), cp, l); |
1974 | 3349 |
LEAVE_XLIB(); |
1344 | 3350 |
RETURN ( self ); |
3351 |
} |
|
3352 |
} |
|
3353 |
||
3354 |
/* TWOBYTESTRINGS */ |
|
3355 |
if (__isWords(aString)) { |
|
3356 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3357 |
||
3358 |
if (i2 < n) { |
|
3359 |
union { |
|
3360 |
char b[2]; |
|
3361 |
unsigned short s; |
|
3362 |
} u; |
|
3363 |
int i; |
|
3364 |
XChar2b *cp2 = (XChar2b *)0; |
|
3365 |
int mustFree = 0; |
|
3366 |
||
3367 |
cp += (i1 * 2); |
|
3368 |
if (l > 1000) l = 1000; |
|
3369 |
||
3370 |
/* |
|
3371 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3372 |
* X expects them MSB first |
|
3373 |
* convert as required |
|
3374 |
*/ |
|
3375 |
||
3376 |
u.s = 0x1234; |
|
3377 |
if (u.b[0] != 0x12) { |
|
3378 |
if (l <= NLOCALBUFFER) { |
|
3379 |
cp2 = xlatebuffer; |
|
3380 |
} else { |
|
3381 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
3382 |
mustFree = 1; |
|
3383 |
} |
|
3384 |
for (i=0; i<l; i++) { |
|
3385 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3386 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3387 |
} |
|
3388 |
cp = (char *) cp2; |
|
3389 |
} |
|
3390 |
||
1974 | 3391 |
ENTER_XLIB(); |
1344 | 3392 |
if (opaque == true) |
3393 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3394 |
else |
|
3395 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
1974 | 3396 |
LEAVE_XLIB(); |
1344 | 3397 |
|
3398 |
if (mustFree) { |
|
3399 |
free(cp2); |
|
3400 |
} |
|
3401 |
||
3402 |
RETURN ( self ); |
|
3403 |
} |
|
3404 |
} |
|
3405 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3406 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3407 |
#undef NLOCALBUFFER |
295 | 3408 |
%}. |
3409 |
"x/y not integer, badGC or drawable, or not a string" |
|
3410 |
self primitiveFailed |
|
3411 |
! |
|
3412 |
||
3413 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3414 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
3415 |
foreground and background characters. |
|
3416 |
If the coordinates are not integers, an error is triggered." |
|
3417 |
||
3418 |
%{ /* NOCONTEXT */ |
|
3419 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3420 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3421 |
Window win; |
1831 | 3422 |
char *cp; |
295 | 3423 |
int n; |
3424 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3425 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3426 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3427 |
int nInstBytes; |
295 | 3428 |
|
1209 | 3429 |
if (ISCONNECTED |
3430 |
&& __isExternalAddress(aGCId) |
|
295 | 3431 |
&& __isExternalAddress(aDrawableId) |
3432 |
&& __isNonNilObject(aString) |
|
3433 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3434 |
gc = _GCVal(aGCId); |
3435 |
win = _WindowVal(aDrawableId); |
|
3436 |
cls = __qClass(aString); |
|
3437 |
||
1831 | 3438 |
cp = (char *) __stringVal(aString); |
1344 | 3439 |
|
3440 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3441 |
n = _stringSize(aString); |
|
3442 |
if (n > 1000) n = 1000; |
|
1974 | 3443 |
ENTER_XLIB(); |
1344 | 3444 |
if (opaque == true) |
1831 | 3445 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), cp, n); |
1344 | 3446 |
else |
1831 | 3447 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), cp, n); |
1974 | 3448 |
LEAVE_XLIB(); |
1344 | 3449 |
RETURN ( self ); |
3450 |
} |
|
3451 |
||
3452 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3453 |
cp += nInstBytes; |
|
3454 |
||
3455 |
if (__isBytes(aString)) { |
|
3456 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3457 |
||
3458 |
if (n > 1000) n = 1000; |
|
1974 | 3459 |
ENTER_XLIB(); |
1344 | 3460 |
if (opaque == true) |
1831 | 3461 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), cp, n); |
1344 | 3462 |
else |
1831 | 3463 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), cp, n); |
1974 | 3464 |
LEAVE_XLIB(); |
1344 | 3465 |
RETURN ( self ); |
3466 |
} |
|
3467 |
||
3468 |
/* TWOBYTESTRINGS */ |
|
3469 |
if (__isWords(aString)) { |
|
3470 |
union { |
|
3471 |
char b[2]; |
|
3472 |
unsigned short s; |
|
3473 |
} u; |
|
3474 |
int i; |
|
3475 |
XChar2b *cp2; |
|
3476 |
int mustFree = 0; |
|
3477 |
||
3478 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3479 |
if (n > 1000) n = 1000; |
|
3480 |
||
3481 |
/* |
|
3482 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3483 |
* X expects them MSB first |
|
3484 |
* convert as required |
|
3485 |
*/ |
|
3486 |
||
3487 |
u.s = 0x1234; |
|
3488 |
if (u.b[0] != 0x12) { |
|
3489 |
if (n <= NLOCALBUFFER) { |
|
3490 |
cp2 = xlatebuffer; |
|
3491 |
} else { |
|
3492 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
3493 |
mustFree = 1; |
|
3494 |
} |
|
3495 |
||
3496 |
for (i=0; i<n; i++) { |
|
3497 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3498 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3499 |
} |
|
3500 |
cp = (char *) cp2; |
|
3501 |
} |
|
3502 |
||
1974 | 3503 |
ENTER_XLIB(); |
1344 | 3504 |
if (opaque == true) |
3505 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3506 |
else |
|
3507 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
1974 | 3508 |
LEAVE_XLIB(); |
1344 | 3509 |
|
3510 |
||
3511 |
if (mustFree) { |
|
3512 |
free(cp2); |
|
3513 |
} |
|
3514 |
||
3515 |
RETURN ( self ); |
|
3516 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3517 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3518 |
#undef NLOCALBUFFER |
295 | 3519 |
%}. |
3520 |
"x/y not integer, badGC or drawable, or not a string" |
|
3521 |
self primitiveFailed |
|
3522 |
! |
|
3523 |
||
3524 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3525 |
width:imageWidth height:imageHeight |
3526 |
x:srcx y:srcy |
|
3527 |
into:aDrawableId |
|
3528 |
x:dstx y:dsty |
|
3529 |
width:w height:h |
|
3530 |
with:aGCId |
|
295 | 3531 |
|
3532 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3533 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3534 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3535 |
depth and pixel-units to be different. |
|
3536 |
It has to be checked elsewhere, that the server can do it with the given |
|
3537 |
depth - otherwise, primitive failure will be signalled. |
|
3538 |
Also it is assumed, that the colormap is setup correctly and the |
|
3539 |
colors are allocated - otherwise the colors may be wrong." |
|
3540 |
||
3541 |
" |
|
3542 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3543 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3544 |
" |
|
3545 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3546 |
width:imageWidth height:imageHeight |
3547 |
x:srcx y:srcy |
|
3548 |
into:aDrawableId |
|
3549 |
x:dstx y:dsty |
|
3550 |
width:w height:h |
|
3551 |
with:aGCId) |
|
295 | 3552 |
ifFalse:[ |
1344 | 3553 |
" |
3554 |
also happens, if a segmentation violation occurs in the |
|
3555 |
XPutImage ... |
|
3556 |
" |
|
3557 |
self primitiveFailed |
|
295 | 3558 |
]. |
3559 |
! |
|
3560 |
||
3561 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3562 |
width:imageWidth height:imageHeight |
3563 |
x:srcx y:srcy |
|
3564 |
into:aDrawableId |
|
3565 |
x:dstx y:dsty |
|
3566 |
width:w height:h |
|
3567 |
with:aGCId |
|
295 | 3568 |
|
3569 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3570 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3571 |
Individual source pixels must have imageDepth bits. |
|
3572 |
It has to be checked elsewhere, that the server can do it with the given |
|
3573 |
depth - otherwise, primitive failure will be signalled. |
|
3574 |
Also it is assumed, that the colormap is setup correctly and the |
|
3575 |
colors are allocated - otherwise the colors may be wrong." |
|
3576 |
||
3577 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3578 |
width:imageWidth height:imageHeight |
3579 |
x:srcx y:srcy |
|
3580 |
into:aDrawableId |
|
3581 |
x:dstx y:dsty |
|
3582 |
width:w height:h |
|
3583 |
with:aGCId |
|
295 | 3584 |
|
3585 |
! |
|
3586 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3587 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3588 |
in:aDrawableId with:aGCId |
90 | 3589 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3590 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3591 |
|
3592 |
%{ /* NOCONTEXT */ |
|
3593 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3594 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3595 |
Window win; |
0 | 3596 |
int w, h, angle1, angle2; |
3597 |
double f; |
|
3598 |
||
97 | 3599 |
if (__isSmallInteger(startAngle)) |
1344 | 3600 |
angle1 = __intVal(startAngle) * 64; |
36 | 3601 |
else if (__isFloat(startAngle)) { |
1344 | 3602 |
f = __floatVal(startAngle); |
3603 |
angle1 = f * 64; |
|
0 | 3604 |
} |
97 | 3605 |
if (__isSmallInteger(angle)) |
1344 | 3606 |
angle2 = __intVal(angle) * 64; |
36 | 3607 |
else if (__isFloat(angle)) { |
1344 | 3608 |
f = __floatVal(angle); |
3609 |
angle2 = f * 64; |
|
0 | 3610 |
} |
1209 | 3611 |
if (ISCONNECTED |
3612 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3613 |
&& __isExternalAddress(aDrawableId) |
97 | 3614 |
&& __bothSmallInteger(x, y) |
3615 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3616 |
gc = _GCVal(aGCId); |
3617 |
win = _WindowVal(aDrawableId); |
|
3618 |
w = __intVal(width); |
|
3619 |
h = __intVal(height); |
|
3620 |
/* |
|
3621 |
* need this check here: some servers simply dump core with bad args |
|
3622 |
*/ |
|
3623 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
1974 | 3624 |
ENTER_XLIB(); |
1344 | 3625 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
3626 |
w, h, angle1, angle2); |
|
1974 | 3627 |
LEAVE_XLIB(); |
1344 | 3628 |
} |
3629 |
RETURN ( self ); |
|
0 | 3630 |
} |
73 | 3631 |
%}. |
3632 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3633 |
self primitiveFailed |
3634 |
! |
|
3635 |
||
3636 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3637 |
"fill a polygon given by its points. |
3638 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3639 |
|
3640 |
|numberOfPoints| |
|
0 | 3641 |
|
3642 |
numberOfPoints := aPolygon size. |
|
3643 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3644 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3645 |
Window win; |
73 | 3646 |
OBJ point, x, y; |
3647 |
int i, num; |
|
3648 |
XPoint *points; |
|
3649 |
XPoint qPoints[100]; |
|
377 | 3650 |
int mustFree = 0; |
73 | 3651 |
|
1209 | 3652 |
if (ISCONNECTED |
3653 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3654 |
&& __isExternalAddress(aDrawableId) |
97 | 3655 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3656 |
gc = _GCVal(aGCId); |
3657 |
win = _WindowVal(aDrawableId); |
|
3658 |
num = __intVal(numberOfPoints); |
|
3659 |
if (num < 3) { |
|
3660 |
RETURN ( self ); |
|
3661 |
} |
|
3662 |
/* |
|
3663 |
* avoid (slow) malloc, if not many points |
|
3664 |
*/ |
|
3665 |
if (num > 100) { |
|
3666 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3667 |
if (! points) goto fail; |
|
3668 |
mustFree = 1; |
|
3669 |
} else |
|
3670 |
points = qPoints; |
|
3671 |
for (i=0; i<num; i++) { |
|
3672 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3673 |
if (! __isPoint(point)) goto fail; |
|
3674 |
x = _point_X(point); |
|
3675 |
y = _point_Y(point); |
|
3676 |
if (! __bothSmallInteger(x, y)) |
|
3677 |
goto fail; |
|
3678 |
points[i].x = __intVal(x); |
|
3679 |
points[i].y = __intVal(y); |
|
3680 |
} |
|
1974 | 3681 |
ENTER_XLIB(); |
1344 | 3682 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
1974 | 3683 |
LEAVE_XLIB(); |
1344 | 3684 |
if (mustFree) |
3685 |
free(points); |
|
3686 |
RETURN ( self ); |
|
377 | 3687 |
|
0 | 3688 |
fail: ; |
1344 | 3689 |
if (mustFree) |
3690 |
free(points); |
|
0 | 3691 |
} |
73 | 3692 |
%}. |
3693 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3694 |
self primitiveFailed |
3695 |
! |
|
3696 |
||
295 | 3697 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3698 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3699 |
||
3700 |
%{ /* NOCONTEXT */ |
|
3701 |
||
3702 |
int w, h; |
|
3703 |
||
1209 | 3704 |
if (ISCONNECTED |
3705 |
&& __isExternalAddress(aGCId) |
|
295 | 3706 |
&& __isExternalAddress(aDrawableId) |
3707 |
&& __bothSmallInteger(x, y) |
|
3708 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3709 |
w = __intVal(width); |
3710 |
h = __intVal(height); |
|
3711 |
/* |
|
3712 |
* need this check here: some servers simply dump core with bad args |
|
3713 |
*/ |
|
3714 |
if ((w >= 0) && (h >= 0)) { |
|
1974 | 3715 |
ENTER_XLIB(); |
1344 | 3716 |
XFillRectangle(myDpy, |
3717 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3718 |
__intVal(x), __intVal(y), w, h); |
|
1974 | 3719 |
LEAVE_XLIB(); |
1344 | 3720 |
} |
3721 |
RETURN ( self ); |
|
295 | 3722 |
} |
3723 |
%}. |
|
3724 |
"badGC, badDrawable or coordinates not integer" |
|
3725 |
self primitiveFailed |
|
43 | 3726 |
! |
3727 |
||
3728 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3729 |
width:imageWidth height:imageHeight |
3730 |
x:srcx y:srcy |
|
3731 |
into:aDrawableId |
|
3732 |
x:dstx y:dsty |
|
3733 |
width:w height:h |
|
3734 |
with:aGCId |
|
0 | 3735 |
|
132 | 3736 |
"since XPutImage may allocate huge amount of stack space |
3737 |
(some implementations use alloca), this must run with unlimited stack." |
|
3738 |
||
12 | 3739 |
%{ /* UNLIMITEDSTACK */ |
0 | 3740 |
|
43 | 3741 |
/* |
3742 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3743 |
* XPutImage |
|
3744 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3745 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3746 |
Window win; |
43 | 3747 |
XImage image; |
377 | 3748 |
int imgWdth; |
43 | 3749 |
|
1209 | 3750 |
if (ISCONNECTED |
3751 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3752 |
&& __isExternalAddress(aDrawableId) |
97 | 3753 |
&& __bothSmallInteger(srcx, srcy) |
3754 |
&& __bothSmallInteger(dstx, dsty) |
|
3755 |
&& __bothSmallInteger(w, h) |
|
3756 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3757 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3758 |
&& __isByteArray(imageBits)) { |
1344 | 3759 |
Display *dpy = myDpy; |
3760 |
||
3761 |
gc = _GCVal(aGCId); |
|
3762 |
win = _WindowVal(aDrawableId); |
|
3763 |
if (! gc || !win) |
|
3764 |
goto fail; |
|
46 | 3765 |
#ifdef ARGDEBUG |
1344 | 3766 |
printf("args ok\n"); |
46 | 3767 |
#endif |
1344 | 3768 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3769 |
image.width = imgWdth = __intVal(imageWidth); |
|
3770 |
image.height = __intVal(imageHeight); |
|
3771 |
image.xoffset = 0; |
|
3772 |
image.format = ZPixmap; |
|
3773 |
image.byte_order = MSBFirst; |
|
3774 |
image.bitmap_unit = 8; |
|
3775 |
image.bitmap_bit_order = MSBFirst; |
|
3776 |
image.bitmap_pad = 8; |
|
3777 |
image.depth = __intVal(imageDepth); |
|
3778 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3779 |
switch (image.bits_per_pixel) { |
|
3780 |
case 1: |
|
3781 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3782 |
break; |
|
3783 |
case 2: |
|
3784 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3785 |
break; |
|
3786 |
case 4: |
|
3787 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3788 |
break; |
|
3789 |
case 8: |
|
3790 |
image.bytes_per_line = imgWdth; |
|
3791 |
break; |
|
3792 |
case 16: |
|
3793 |
image.bytes_per_line = imgWdth*2; |
|
3794 |
break; |
|
3795 |
case 24: |
|
3796 |
image.bytes_per_line = imgWdth*3; |
|
3797 |
break; |
|
3798 |
case 32: |
|
3799 |
image.bytes_per_line = imgWdth*4; |
|
3800 |
break; |
|
3801 |
default: |
|
46 | 3802 |
#ifdef ARGDEBUG |
1344 | 3803 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3804 |
#endif |
1344 | 3805 |
goto fail; |
3806 |
} |
|
3807 |
image.red_mask = 0xFFFF; |
|
3808 |
image.green_mask = 0xFFFF; |
|
3809 |
image.blue_mask = 0xFFFF; |
|
1974 | 3810 |
ENTER_XLIB(); |
1344 | 3811 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
3812 |
__intVal(dstx), __intVal(dsty), |
|
3813 |
__intVal(w), __intVal(h)); |
|
1974 | 3814 |
LEAVE_XLIB(); |
1344 | 3815 |
RETURN ( true ); |
43 | 3816 |
} |
46 | 3817 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3818 |
if (!! __isExternalAddress(aGCId)) printf("GC\n"); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3819 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3820 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3821 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3822 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3823 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3824 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3825 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3826 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3827 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3828 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3829 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3830 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3831 |
#endif |
3832 |
||
0 | 3833 |
fail: ; |
3834 |
%} |
|
3835 |
. |
|
12 | 3836 |
^ false |
0 | 3837 |
! ! |
3838 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3839 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3840 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3841 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3842 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3843 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3844 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3845 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3846 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3847 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3848 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3849 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3850 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3851 |
|
1540 | 3852 |
clientMessage:event dataOffset:offs view:targetView |
1757 | 3853 |
self halt:'debug halt: unimplemented client message'. |
1540 | 3854 |
|
3855 |
"Created: 4.4.1997 / 17:23:12 / cg" |
|
1757 | 3856 |
"Modified: 17.6.1997 / 18:04:24 / cg" |
1540 | 3857 |
! |
3858 |
||
1543 | 3859 |
clientMessage:event type:type format:format dataOffset:offs view:targetView |
3860 |
|sensor data| |
|
3861 |
||
3862 |
data := event copyFrom:offs + 1. |
|
3863 |
||
3864 |
"/ DND drag&drop protocol |
|
3865 |
type == (self atomIDOf:'DndProtocol') ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3866 |
format == 32 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3867 |
self dndMessage:event data:data view:targetView. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3868 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3869 |
] |
1543 | 3870 |
]. |
3871 |
||
3872 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3873 |
sensor clientMessage:type format:format eventData:data view:targetView |
1543 | 3874 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3875 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3876 |
not posted, if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3877 |
" |
1543 | 3878 |
] |
3879 |
||
3880 |
"Created: 4.4.1997 / 17:49:26 / cg" |
|
3881 |
"Modified: 4.4.1997 / 18:00:18 / cg" |
|
3882 |
! |
|
3883 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3884 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3885 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3886 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3887 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3888 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3889 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3890 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3891 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3892 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3893 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3894 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3895 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3896 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3897 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3898 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3899 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3900 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3901 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3902 |
|
1543 | 3903 |
dndMessage:event data:data view:targetView |
3904 |
"handle a DND drag&drop protocol message" |
|
3905 |
||
1553 | 3906 |
|sensor dropType dropValue names i1 i2 t| |
1543 | 3907 |
|
3908 |
dropType := data doubleWordAt:1. |
|
3909 |
||
3910 |
"/ see def's in DragAndDropTypes.h |
|
1556 | 3911 |
dropType := (self dndDropTypes) at:dropType+1 ifAbsent:#DndNotDnd. |
1543 | 3912 |
|
3913 |
self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3914 |
getProperty:(self atomIDOf:'DndSelection') |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3915 |
from:rootId |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3916 |
into:[:type :value | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3917 |
t := type. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3918 |
dropValue := value |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3919 |
]. |
1543 | 3920 |
|
1558 | 3921 |
"/ preconvert into a collection |
3922 |
"/ of fileNames, string or byteArray |
|
3923 |
"/ Notice: we do not yet convert into dropObjects |
|
3924 |
"/ here, to allow arbitrary data to be handled by |
|
3925 |
"/ redefined dropMessage methods in applications. |
|
3926 |
"/ Conversion is done for some well known types |
|
3927 |
"/ in the default dropMessage handling of SimpleView. |
|
3928 |
||
1543 | 3929 |
dropType == #DndFiles ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3930 |
"/ actually, a list of fileNames |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3931 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3932 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3933 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3934 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3935 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3936 |
names := OrderedCollection new. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3937 |
i1 := 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3938 |
[i1 ~~ 0] whileTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3939 |
i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3940 |
i2 ~~ 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3941 |
names add:(dropValue copyFrom:i1 to:(i2-1)). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3942 |
i1 := i2 + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3943 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3944 |
i1 := i2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3945 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3946 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3947 |
dropValue := names. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3948 |
dropValue := dropValue collect:[:nm | nm asFilename]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3949 |
dropType := #files. |
1558 | 3950 |
] ifFalse:[ (dropType == #DndFile) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3951 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3952 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3953 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3954 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3955 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3956 |
dropValue := dropValue asFilename. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3957 |
dropType := #file. |
1558 | 3958 |
] ifFalse:[ (dropType == #DndDir) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3959 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3960 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3961 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3962 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3963 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3964 |
dropValue := dropValue asFilename. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3965 |
dropType := #directory. |
1558 | 3966 |
] ifFalse:[ (dropType == #DndText) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3967 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3968 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3969 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3970 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3971 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3972 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3973 |
dropType := #text. |
1558 | 3974 |
] ifFalse:[ (dropType == #DndExe) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3975 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3976 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3977 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3978 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3979 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3980 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3981 |
dropType := #executable. |
1558 | 3982 |
] ifFalse:[ (dropType == #DndLink) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3983 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3984 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3985 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3986 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3987 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3988 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3989 |
dropType := #link. |
1558 | 3990 |
] ifFalse:[ (dropType == #DndRawData) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3991 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3992 |
dropType := #rawData. |
1552 | 3993 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3994 |
'XWorkstation [info]: unsupported dropType: ' infoPrint. dropType infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3995 |
'XWorkstation [info]: data: ' infoPrint. dropValue infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3996 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3997 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3998 |
dropType := #unknown. |
1558 | 3999 |
]]]]]]]. |
1543 | 4000 |
|
4001 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4002 |
sensor dropMessage:dropType data:dropValue view:targetView |
1543 | 4003 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4004 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4005 |
not posted, if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4006 |
" |
1543 | 4007 |
] |
4008 |
||
4009 |
"Created: 4.4.1997 / 17:59:37 / cg" |
|
1558 | 4010 |
"Modified: 6.4.1997 / 14:50:44 / cg" |
1543 | 4011 |
! |
4012 |
||
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4013 |
gravityNotifyView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4014 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4015 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4016 |
"/ aView gravityNotify |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4017 |
! |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4018 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4019 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4020 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4021 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4022 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4023 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4024 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4025 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4026 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4027 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4028 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4029 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4030 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4031 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4032 |
reparentedView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4033 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4034 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4035 |
"/ aView reparented |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4036 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4037 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4038 |
resizeRequestView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4039 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4040 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4041 |
"/ aView resizeRequest |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4042 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
4043 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4044 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4045 |
"sent when another X-client has created a selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4046 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4047 |
|
1344 | 4048 |
"/ |
4049 |
"/ workaround a bug in olvwm: it clears selections |
|
4050 |
"/ on window raise. |
|
4051 |
"/ In this case, keep my last own selection. |
|
4052 |
"/ |
|
4053 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4054 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4055 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4056 |
|
1795 | 4057 |
"/ noone is interested in that ... |
1344 | 4058 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4059 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4060 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4061 |
selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4062 |
"sent when the server returns an answer from a request for a selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4063 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4064 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4065 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4066 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4067 |
propertyID == 0 ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4068 |
"invalid olvwm behavior" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4069 |
s := self getLastCopyBuffer |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4070 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4071 |
targetID == self atomIDOfSTRING ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4072 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4073 |
a returned string |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4074 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4075 |
s := self getTextProperty:propertyID from:requestorID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4076 |
s notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4077 |
(s endsWith:Character cr) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4078 |
s := s asStringCollection copyWith:'' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4079 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4080 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4081 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4082 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4083 |
a returned object |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4084 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4085 |
s := self getObjectProperty:propertyID from:requestorID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4086 |
]. |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4087 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4088 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4089 |
s notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4090 |
(sensor := aView sensor) notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4091 |
sensor pasteFromClipBoard:s view:aView |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4092 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4093 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4094 |
if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4095 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4096 |
aView pasteFromClipBoard:s |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4097 |
] |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4098 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4099 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4100 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4101 |
selectionRequest:propertyID target:targetID selection:selectionID from:windowID view:aView |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4102 |
"sent by some other X-client to ask for the selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4103 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4104 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4105 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4106 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4107 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4108 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4109 |
"/ the other one wants to know the size of our selection ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4110 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4111 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4112 |
s := self selectionAsString. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4113 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4114 |
setLengthProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4115 |
value:s size |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4116 |
for:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4117 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4118 |
sendSelectionNotifySelection:selectionID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4119 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4120 |
target:targetID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4121 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4122 |
to:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4123 |
^ self |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4124 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4125 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4126 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4127 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4128 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4129 |
"/ the other view wants the selection as string |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4130 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4131 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4132 |
s := self selectionAsString. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4133 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4134 |
sendSelection:s |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4135 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4136 |
target:targetID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4137 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4138 |
to:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4139 |
^ self |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4140 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4141 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4142 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4143 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4144 |
"/ (assuming, that the other view knows how to handle it) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4145 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4146 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4147 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4148 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4149 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
4150 |
self |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4151 |
sendSelection:(stream contents) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4152 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4153 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4154 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4155 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4156 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4157 |
|
86 | 4158 |
!XWorkstation methodsFor:'event handling'! |
0 | 4159 |
|
4160 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
4161 |
"central event handling method: |
|
54 | 4162 |
get next event and send appropriate message to the sensor or view. |
0 | 4163 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 4164 |
otherwise only events for the view with given id are processed. |
4165 |
If the argument aMask is nonNil, only events for this eventMask are |
|
1871 | 4166 |
handled. |
4167 |
WARNING: this may block to wait for an event - you better check for a |
|
1906 | 4168 |
pending event before calling this." |
12 | 4169 |
|
54 | 4170 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
1906 | 4171 |
AbortSignal handle:[:ex | |
4172 |
ex return |
|
4173 |
] do:[ |
|
4174 |
self dispatchLastEvent. |
|
4175 |
] |
|
54 | 4176 |
]. |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4177 |
|
1871 | 4178 |
"Modified: 19.8.1997 / 17:10:42 / cg" |
12 | 4179 |
! |
4180 |
||
295 | 4181 |
dispatchExposeEventFor:aViewIdOrNil |
4182 |
"get next expose event and send appropriate message to the sensor or view. |
|
4183 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
1871 | 4184 |
otherwise only events for the view with given id are processed. |
4185 |
WARNING: this may block to wait for an event - you better check for a |
|
1906 | 4186 |
pending event before calling this." |
295 | 4187 |
|
4188 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
1871 | 4189 |
|
4190 |
"Modified: 19.8.1997 / 17:10:26 / cg" |
|
12 | 4191 |
! |
4192 |
||
4193 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4194 |
|theView symS arg butt sibling windowID siblingID propertyID selectionID targetID requestorID |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4195 |
eventType| |
12 | 4196 |
|
4197 |
%{ /* STACK: 8000 */ |
|
4198 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 4199 |
|
1209 | 4200 |
Display *dpy; |
135 | 4201 |
OBJ eB; |
4202 |
XEvent *ev; |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4203 |
int ev_x, ev_y; |
135 | 4204 |
|
4205 |
# define ae ((XAnyEvent *)ev) |
|
4206 |
# define ee ((XExposeEvent *)ev) |
|
4207 |
# define ke ((XKeyPressedEvent *)ev) |
|
4208 |
# define be ((XButtonPressedEvent *)ev) |
|
4209 |
# define ce ((XConfigureEvent *)ev) |
|
4210 |
# define me ((XMotionEvent *)ev) |
|
4211 |
# define ewe ((XEnterWindowEvent *)ev) |
|
4212 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
4213 |
# define de ((XDestroyWindowEvent *)ev) |
|
4214 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4215 |
# define mape ((XMappingEvent *)ev) |
135 | 4216 |
|
0 | 4217 |
KeySym keySym; |
4218 |
unsigned char buffer[10]; |
|
4219 |
int i, nchars; |
|
4220 |
char *keySymString; |
|
4221 |
char keySymStringBuffer[32]; |
|
1832 | 4222 |
unsigned INT nextMultiClickTime; |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
4223 |
OBJ upDown, t; |
115 | 4224 |
|
4225 |
struct inlineCache *ipS; |
|
0 | 4226 |
static struct inlineCache vid = _ILC1; |
12 | 4227 |
|
4228 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
4229 |
static struct inlineCache gexpS = _ILC6; |
12 | 4230 |
static struct inlineCache nexpS = _ILC1; |
4231 |
static struct inlineCache motS = _ILC4; |
|
4232 |
static struct inlineCache bpS = _ILC4; |
|
4233 |
static struct inlineCache bmpS = _ILC4; |
|
4234 |
static struct inlineCache bspS = _ILC4; |
|
4235 |
static struct inlineCache brS = _ILC4; |
|
4236 |
static struct inlineCache focInS = _ILC1; |
|
4237 |
static struct inlineCache focOutS = _ILC1; |
|
4238 |
static struct inlineCache peS = _ILC4; |
|
4239 |
static struct inlineCache plS = _ILC2; |
|
54 | 4240 |
static struct inlineCache termS = _ILC1; |
4241 |
static struct inlineCache savtermS = _ILC1; |
|
4242 |
static struct inlineCache destrS = _ILC1; |
|
4243 |
static struct inlineCache unmapS = _ILC1; |
|
4244 |
static struct inlineCache mapS = _ILC1; |
|
4245 |
static struct inlineCache confS = _ILC5; |
|
70 | 4246 |
static struct inlineCache coveredS = _ILC2; |
1543 | 4247 |
static struct inlineCache clientMsg = _ILC5; |
12 | 4248 |
|
4249 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4250 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4251 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4252 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4253 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4254 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
4255 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
4256 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4257 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4258 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4259 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4260 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4261 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
4262 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4263 |
static struct inlineCache mapping = _ILC2; |
70 | 4264 |
static struct inlineCache vis = _ILC1; |
12 | 4265 |
|
4266 |
static struct inlineCache skpS = _ILC4; |
|
63 | 4267 |
static struct inlineCache skrS = _ILC4; |
12 | 4268 |
|
1209 | 4269 |
if (! ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4270 |
RETURN (false); |
1209 | 4271 |
} |
4272 |
||
4273 |
dpy = myDpy; |
|
4274 |
||
1210 | 4275 |
eB = __INST(eventBuffer); |
4276 |
||
135 | 4277 |
if (__isByteArray(eB)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4278 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 4279 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4280 |
printf("DISPLAY: no eventBuffer\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4281 |
RETURN (false); |
135 | 4282 |
} |
4283 |
||
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4284 |
/* |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4285 |
* very often, its another event for the same view ... |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4286 |
* avoid creation & lookup then. |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4287 |
*/ |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4288 |
if ((t = __INST(lastId)) != nil) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4289 |
if (__isExternalAddress(t)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4290 |
if (_WindowVal(t) == ae->window) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4291 |
theView = __INST(lastView); |
1610
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
4292 |
if (__isNonNilObject(theView)) { |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
4293 |
if (__qClass(theView) == nil) { |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
4294 |
theView = nil; |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
4295 |
} |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
4296 |
} |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4297 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4298 |
} |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4299 |
} |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4300 |
|
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4301 |
if (theView == nil) { |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4302 |
windowID = __MKEXTERNALADDRESS(ae->window); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4303 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4304 |
/* |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4305 |
* MKEXTERNALADDRESS and/or #viewFromId: could lead to a GC - refetch event ptr |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4306 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4307 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4308 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4309 |
} |
12 | 4310 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4311 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4312 |
RETURN (nil); |
12 | 4313 |
} |
4314 |
||
4315 |
/* |
|
4316 |
* key, button and pointer events are sent to the sensor, |
|
4317 |
* or (if there is none) to the delegate. |
|
4318 |
* or (if there is none) to the view. |
|
26 | 4319 |
* |
4320 |
* expose events are sent to the sensor, |
|
4321 |
* or (if there is none) to the view |
|
4322 |
* |
|
12 | 4323 |
* sensor and delegate get view as additional argument |
115 | 4324 |
* all of this has been taken out of here to corresponding methods |
4325 |
* in DeviceWorkstation. |
|
12 | 4326 |
*/ |
90 | 4327 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4328 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4329 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4330 |
#endif |
135 | 4331 |
switch (ev->type) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4332 |
case KeyRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4333 |
symS = @symbol(keyRelease:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4334 |
ipS = &skrS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4335 |
upDown = false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4336 |
goto keyPressAndRelease; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4337 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4338 |
case KeyPress: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4339 |
symS = @symbol(keyPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4340 |
ipS = &skpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4341 |
upDown = true; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4342 |
/* FALL INTO */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4343 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4344 |
keyPressAndRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4345 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4346 |
__INST(eventRootY) = __MKSMALLINT(ke->y_root); |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4347 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4348 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4349 |
__INST(metaDown) = (ke->state & Mod1Mask) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4350 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4351 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4352 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4353 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4354 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4355 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4356 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4357 |
ev_x = ke->x; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4358 |
ev_y = ke->y; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4359 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4360 |
arg = nil; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4361 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4362 |
if (nchars |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4363 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4364 |
|| (buffer[0] >= 0x80))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4365 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4366 |
keySymString = NULL; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4367 |
} else { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4368 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4369 |
switch (keySym) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4370 |
case XK_Control_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4371 |
case XK_Control_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4372 |
__INST(ctrlDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4373 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4374 |
case XK_Shift_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4375 |
case XK_Shift_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4376 |
__INST(shiftDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4377 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4378 |
case XK_Meta_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4379 |
case XK_Meta_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4380 |
__INST(metaDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4381 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4382 |
case XK_Alt_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4383 |
case XK_Alt_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4384 |
__INST(altDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4385 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4386 |
} |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4387 |
#endif |
150 | 4388 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4389 |
keySymString = XKeysymToString(keySym); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4390 |
if (keySymString) { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4391 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4392 |
if (keySymString[0] == 'D') { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4393 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4394 |
* remove underscore, dont want it in symbols |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4395 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4396 |
if (strcmp(keySymString, "Delete_line") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4397 |
keySymString = "DeleteLine"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4398 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4399 |
keySymString = "DeleteWord"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4400 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4401 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4402 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4403 |
* make names compatible |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4404 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4405 |
if (strcmp(keySymString, "Down") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4406 |
keySymString = "CursorDown"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4407 |
} else if (strcmp(keySymString, "Up") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4408 |
keySymString = "CursorUp"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4409 |
} else if (strcmp(keySymString, "Left") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4410 |
keySymString = "CursorLeft"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4411 |
} else if (strcmp(keySymString, "Right") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4412 |
keySymString = "CursorRight"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4413 |
} |
1694 | 4414 |
arg = __MKSYMBOL(keySymString, (OBJ *)0); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4415 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4416 |
arg = __MKSTRING(keySymString); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4417 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4418 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4419 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4420 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4421 |
if (arg == nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4422 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4423 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4424 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4425 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4426 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4427 |
arg, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4428 |
__MKSMALLINT(ev_x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4429 |
__MKSMALLINT(ev_y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4430 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4431 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4432 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4433 |
case ButtonPress: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4434 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4435 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4436 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4437 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4438 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4439 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4440 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4441 |
nextMultiClickTime = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4442 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4443 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4444 |
if ((t = __INST(multiClickTime)) != nil) { |
1835 | 4445 |
INT _multiClickTime; |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4446 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4447 |
_multiClickTime = __longIntVal(t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4448 |
if (be->time < _multiClickTime) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4449 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4450 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4451 |
* MKUINT could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4452 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4453 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4454 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4455 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4456 |
ipS = &bmpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4457 |
symS = @symbol(buttonMultiPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4458 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4459 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4460 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4461 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4462 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4463 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4464 |
* MKUINT could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4465 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4466 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4467 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
4468 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4469 |
#ifdef NO_LONGER |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4470 |
if (be->state & ShiftMask) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4471 |
ipS = &bspS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4472 |
symS = @symbol(buttonShiftPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4473 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4474 |
} |
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4475 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4476 |
ipS = &bpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4477 |
symS = @symbol(buttonPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4478 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4479 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4480 |
/* NOT REACHED */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4481 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4482 |
case ButtonRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4483 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4484 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4485 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4486 |
ipS = &brS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4487 |
symS = @symbol(buttonRelease:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4488 |
/* fall into */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4489 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4490 |
sendButtonEvent: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4491 |
butt = __MKSMALLINT(be->button); |
12 | 4492 |
#ifdef NOTDEF |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4493 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4494 |
* this allows operation with single button mouses: meta-click is always Button 2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4495 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4496 |
if (__INST(metaDown) == true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4497 |
butt = __MKSMALLINT(2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4498 |
else |
0 | 4499 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4500 |
butt = __AT_(__INST(buttonTranslation), butt); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4501 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4502 |
* #at: could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4503 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4504 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4505 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4506 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4507 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4508 |
(*(*ipS).ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4509 |
symS, nil, ipS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4510 |
butt, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4511 |
__MKSMALLINT(ke->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4512 |
__MKSMALLINT(ke->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4513 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4514 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4515 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4516 |
case MotionNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4517 |
if (__INST(motionEventCompression) != false) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4518 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4519 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4520 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4521 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4522 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 4523 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4524 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4525 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4526 |
__INST(metaDown) = (me->state & Mod1Mask) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4527 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4528 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4529 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4530 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4531 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4532 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4533 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4534 |
(*motS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4535 |
@symbol(buttonMotion:x:y:view:), nil, &motS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4536 |
__MKSMALLINT(me->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4537 |
__MKSMALLINT(me->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4538 |
__MKSMALLINT(me->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4539 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4540 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4541 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4542 |
case FocusIn: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4543 |
(*focInS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4544 |
@symbol(focusInView:), nil, &focInS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4545 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4546 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4547 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4548 |
case FocusOut: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4549 |
(*focOutS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4550 |
@symbol(focusOutView:), nil, &focOutS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4551 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4552 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4553 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4554 |
case EnterNotify: |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4555 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4556 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4557 |
__INST(metaDown) = (ewe->state & Mod1Mask) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4558 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4559 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4560 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4561 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4562 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4563 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4564 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4565 |
(*peS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4566 |
@symbol(pointerEnter:x:y:view:), nil, &peS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4567 |
__MKSMALLINT(ewe->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4568 |
__MKSMALLINT(ewe->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4569 |
__MKSMALLINT(ewe->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4570 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4571 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4572 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4573 |
case LeaveNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4574 |
(*plS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4575 |
@symbol(pointerLeave:view:), nil, &plS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4576 |
__MKSMALLINT(lwe->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4577 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4578 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4579 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4580 |
case GraphicsExpose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4581 |
(*gexpS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4582 |
@symbol(graphicsExposeX:y:width:height:final:view:), nil, &gexpS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4583 |
__MKSMALLINT(ee->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4584 |
__MKSMALLINT(ee->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4585 |
__MKSMALLINT(ee->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4586 |
__MKSMALLINT(ee->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4587 |
ee->count == 0 ? true : false, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4588 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4589 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4590 |
if (ee->count != 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4591 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4592 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4593 |
/* fall into */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4594 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4595 |
case NoExpose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4596 |
(*nexpS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4597 |
@symbol(noExposeView:), nil, &nexpS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4598 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4599 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4600 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4601 |
case Expose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4602 |
(*expS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4603 |
@symbol(exposeX:y:width:height:view:), nil, &expS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4604 |
__MKSMALLINT(ee->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4605 |
__MKSMALLINT(ee->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4606 |
__MKSMALLINT(ee->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4607 |
__MKSMALLINT(ee->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4608 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4609 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4610 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4611 |
case ConfigureNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4612 |
if (ce->above != None) { |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4613 |
siblingID = __MKEXTERNALADDRESS(ce->above); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4614 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, siblingID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4615 |
/* |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4616 |
* MKEXTERNALADDRESS or #viewFromId: could lead to a GC - refetch event ptr |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4617 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4618 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4619 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4620 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4621 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4622 |
(*confS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4623 |
@symbol(configureX:y:width:height:view:), nil, &confS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4624 |
__MKSMALLINT(ce->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4625 |
__MKSMALLINT(ce->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4626 |
__MKSMALLINT(ce->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4627 |
__MKSMALLINT(ce->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4628 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4629 |
if (sibling != nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4630 |
(*coveredS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4631 |
@symbol(coveredBy:view:), nil, &coveredS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4632 |
theView, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4633 |
sibling); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4634 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4635 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4636 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4637 |
case ClientMessage: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4638 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4639 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4640 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4641 |
(*termS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4642 |
@symbol(terminateView:), nil, &termS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4643 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4644 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4645 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4646 |
(*savtermS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4647 |
@symbol(saveAndTerminateView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4648 |
, nil, &savtermS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4649 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4650 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4651 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4652 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4653 |
* any other client message |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4654 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4655 |
i = (char *)(&(ev->xclient.data)) - (char *)ev; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4656 |
(*clientMsg.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4657 |
@symbol(clientMessage:type:format:dataOffset:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4658 |
, nil, &clientMsg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4659 |
, __INST(eventBuffer) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4660 |
,__MKSMALLINT(ev->xclient.message_type) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4661 |
,__MKSMALLINT(ev->xclient.format) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4662 |
,__MKSMALLINT(i), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4663 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4664 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4665 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4666 |
case DestroyNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4667 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4668 |
, nil, &destrS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4669 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4670 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4671 |
case UnmapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4672 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4673 |
, nil, &unmapS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4674 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4675 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4676 |
case MapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4677 |
(*mapS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4678 |
@symbol(mappedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4679 |
, nil, &mapS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4680 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4681 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4682 |
case KeymapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4683 |
(*keymap.ilc_func)(theView, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4684 |
@symbol(keyMapChange) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4685 |
, nil, &keymap); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4686 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4687 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4688 |
case VisibilityNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4689 |
switch (ve->state) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4690 |
case VisibilityUnobscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4691 |
arg = @symbol(unobscured); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4692 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4693 |
case VisibilityPartiallyObscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4694 |
arg = @symbol(partiallyObscured); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4695 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4696 |
case VisibilityFullyObscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4697 |
arg = @symbol(fullyObscured); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4698 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4699 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4700 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:), nil, &vis, arg); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4701 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4702 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4703 |
case CreateNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4704 |
(*created.ilc_func)(self, @symbol(createdView:), nil, &created, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4705 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4706 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4707 |
case MapRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4708 |
(*mapReq.ilc_func)(self, @symbol(mapRequestView:), nil, &mapReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4709 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4710 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4711 |
case ReparentNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4712 |
(*repar.ilc_func)(self, @symbol(reparentedView:), nil, &repar, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4713 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4714 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4715 |
case ConfigureRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4716 |
(*confReq.ilc_func)(self, @symbol(configureRequestView:), nil, &confReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4717 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4718 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4719 |
case GravityNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4720 |
(*gravNotify.ilc_func)(self, @symbol(gravityNotifyView:), nil, &resReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4721 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4722 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4723 |
case ResizeRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4724 |
(*resReq.ilc_func)(self, @symbol(resizeRequestView:), nil, &resReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4725 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4726 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4727 |
case CirculateNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4728 |
(*circNotify.ilc_func)(self, @symbol(circulateNotifyView:), nil, &circNotify, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4729 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4730 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4731 |
case CirculateRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4732 |
(*circReq.ilc_func)(self, @symbol(circulateRequestView:), nil, &circReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4733 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4734 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4735 |
case PropertyNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4736 |
(*prop.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4737 |
@symbol(propertyChangeView) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4738 |
, nil, &prop, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4739 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4740 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4741 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4742 |
case SelectionClear: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4743 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4744 |
(*selClear.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4745 |
@symbol(selectionClear:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4746 |
, nil, &selClear, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4747 |
selectionID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4748 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4749 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4750 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4751 |
case SelectionNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4752 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4753 |
* returned selection value (answer from SelectionRequest) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4754 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4755 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4756 |
ev->xselection.property, ev->xselection.target, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4757 |
ev->xselection.selection, ev->xselection.requestor)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4758 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4759 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4760 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4761 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4762 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4763 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4764 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4765 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4766 |
targetID = __MKATOMOBJ(ev->xselection.target); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4767 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4768 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4769 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4770 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4771 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4772 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4773 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4774 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4775 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4776 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4777 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4778 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4779 |
|
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4780 |
requestorID = __MKEXTERNALADDRESS(ev->xselection.requestor); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4781 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4782 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4783 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4784 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4785 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4786 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4787 |
(*selNotify.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4788 |
@symbol(selectionNotify:target:selection:from:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4789 |
, nil, &selNotify, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4790 |
propertyID, targetID, selectionID, requestorID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4791 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4792 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4793 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4794 |
case SelectionRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4795 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4796 |
* someone wants the selection |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4797 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4798 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4799 |
ev->xselectionrequest.property, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4800 |
ev->xselectionrequest.target, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4801 |
ev->xselectionrequest.selection, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4802 |
ev->xselectionrequest.requestor)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4803 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4804 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4805 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4806 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4807 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4808 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4809 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4810 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4811 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4812 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4813 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4814 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4815 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4816 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4817 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4818 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4819 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4820 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4821 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4822 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4823 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4824 |
|
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4825 |
requestorID = __MKEXTERNALADDRESS(ev->xselectionrequest.requestor); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4826 |
/* |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4827 |
* MKATOMOBJ could lead to a GC - refetch event ptr |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4828 |
*/ |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4829 |
eB = __INST(eventBuffer); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4830 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4831 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4832 |
(*selReq.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4833 |
@symbol(selectionRequest:target:selection:from:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4834 |
, nil, &selReq, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4835 |
propertyID, targetID, selectionID, requestorID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4836 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4837 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4838 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4839 |
case ColormapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4840 |
(*colormap.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4841 |
@symbol(colorMapChangeView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4842 |
, nil, &colormap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4843 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4844 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4845 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4846 |
case MappingNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4847 |
switch(mape->request) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4848 |
case MappingModifier: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4849 |
arg = @symbol(mappingModifier); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4850 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4851 |
case MappingKeyboard: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4852 |
arg = @symbol(mappingKeyboard); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4853 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4854 |
case MappingPointer: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4855 |
arg = @symbol(mappingPointer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4856 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4857 |
default: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4858 |
arg = nil; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4859 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4860 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4861 |
(*mapping.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4862 |
@symbol(mappingChanged:event:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4863 |
, nil, &mapping, arg, eB); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4864 |
break; |
0 | 4865 |
} |
135 | 4866 |
#undef ae |
0 | 4867 |
#undef ee |
4868 |
#undef ke |
|
4869 |
#undef be |
|
4870 |
#undef ce |
|
4871 |
#undef me |
|
4872 |
#undef ewe |
|
4873 |
#undef lwe |
|
4874 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4875 |
#undef mape |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
4876 |
%}. |
0 | 4877 |
^ true |
4878 |
! |
|
4879 |
||
1344 | 4880 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4881 |
"central event handling method for modal operation. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4882 |
(i.e. this is now only used in the modal debugger) |
1871 | 4883 |
Dispatch any pending events; return when no more are pending. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4884 |
This code is somewhat special, since X has a concept of graphic |
295 | 4885 |
expose events (which are sent after a bitblt). After such a bitblt, |
4886 |
we only handle exposes until the graphicsExpose arrives. |
|
4887 |
Other systems may not need such a kludge" |
|
4888 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4889 |
"interested in exposes only ?" |
295 | 4890 |
dispatchingExpose notNil ifTrue:[ |
1906 | 4891 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
4892 |
self dispatchExposeEventFor:dispatchingExpose |
|
4893 |
]. |
|
4894 |
^ self |
|
295 | 4895 |
]. |
4896 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4897 |
[self eventPendingWithSync:false] whileTrue:[ |
1906 | 4898 |
(self getEventFor:nil withMask:nil) ifTrue:[ |
4899 |
AbortSignal handle:[:ex | |
|
4900 |
ex return |
|
4901 |
] do:[ |
|
4902 |
self dispatchLastEvent |
|
4903 |
] |
|
4904 |
]. |
|
295 | 4905 |
] |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4906 |
|
1871 | 4907 |
"Modified: 19.8.1997 / 17:11:18 / cg" |
295 | 4908 |
! |
4909 |
||
1344 | 4910 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4911 |
"dispose (throw away) specific events. If aWindowId is nil, |
4912 |
events matching the mask are thrown away regardless of which |
|
4913 |
view they are for. Otherwise, only matching events for that |
|
4914 |
view are flushed." |
|
0 | 4915 |
|
4916 |
%{ /* NOCONTEXT */ |
|
4917 |
||
4918 |
XEvent ev; |
|
4919 |
Window win; |
|
4920 |
||
1209 | 4921 |
if (ISCONNECTED |
4922 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4923 |
Display *dpy = myDpy; |
4924 |
||
1974 | 4925 |
ENTER_XLIB(); |
1344 | 4926 |
if (__isExternalAddress(aWindowIdOrNil)) { |
4927 |
win = _WindowVal(aWindowIdOrNil); |
|
4928 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4929 |
} else { |
|
4930 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4931 |
} |
|
1974 | 4932 |
LEAVE_XLIB(); |
1344 | 4933 |
RETURN ( self ); |
0 | 4934 |
} |
4935 |
%} |
|
4936 |
. |
|
4937 |
self primitiveFailed |
|
4938 |
! |
|
4939 |
||
1344 | 4940 |
eventMaskFor:anEventSymbol |
295 | 4941 |
"return the eventMask bit-constant corresponding to an event symbol" |
4942 |
||
4943 |
%{ /* NOCONTEXT */ |
|
4944 |
||
4945 |
int m = 0; |
|
4946 |
||
4947 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4948 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4949 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4950 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4951 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4952 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4953 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4954 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4955 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4956 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4957 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4958 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4959 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4960 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4961 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4962 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4963 |
RETURN (__MKSMALLINT(m)); |
295 | 4964 |
%} |
4965 |
! |
|
4966 |
||
1344 | 4967 |
eventPending |
310 | 4968 |
"return true, if any event is pending. |
4969 |
This looks for both the internal queue and the display connection." |
|
12 | 4970 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4971 |
ConservativeSyncing == true ifTrue:[self sync]. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4972 |
|
12 | 4973 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4974 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4975 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4976 |
^ self eventPendingWithSync:false |
0 | 4977 |
! |
4978 |
||
1344 | 4979 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4980 |
"return true, if a specific event is pending" |
4981 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4982 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4983 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4984 |
|
1344 | 4985 |
eventPendingWithSync:doSync |
7 | 4986 |
"return true, if any event is pending. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4987 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4988 |
before checking." |
0 | 4989 |
|
12 | 4990 |
%{ /* UNLIMITEDSTACK */ |
1974 | 4991 |
OBJ rslt = false; |
0 | 4992 |
|
150 | 4993 |
if (ISCONNECTED) { |
1344 | 4994 |
Display *dpy = myDpy; |
4995 |
||
1974 | 4996 |
ENTER_XLIB(); |
1344 | 4997 |
if (doSync == true) { |
4998 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4999 |
} |
|
5000 |
if (XPending(dpy)) { |
|
1974 | 5001 |
rslt = true; |
5002 |
} |
|
5003 |
LEAVE_XLIB(); |
|
5004 |
} |
|
5005 |
RETURN ( rslt ); |
|
0 | 5006 |
%} |
5007 |
! |
|
5008 |
||
1344 | 5009 |
eventQueued |
341 | 5010 |
"return true, if any event is queued" |
5011 |
||
5012 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 5013 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 5014 |
]. |
5015 |
^ self eventQueuedAlready |
|
5016 |
||
5017 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
5018 |
! |
|
5019 |
||
1344 | 5020 |
eventQueuedAlready |
341 | 5021 |
"return true, if any event is queued internally. |
5022 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
5023 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
5024 |
the display connection)." |
|
5025 |
||
5026 |
%{ /* UNLIMITEDSTACK */ |
|
1974 | 5027 |
OBJ rslt = false; |
341 | 5028 |
|
5029 |
if (ISCONNECTED) { |
|
1974 | 5030 |
ENTER_XLIB(); |
1344 | 5031 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
1974 | 5032 |
rslt = true; |
5033 |
} |
|
5034 |
LEAVE_XLIB(); |
|
341 | 5035 |
} |
5036 |
RETURN ( false ); |
|
5037 |
%} |
|
5038 |
! |
|
5039 |
||
1344 | 5040 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 5041 |
"return true, if any of the masked events is pending" |
5042 |
||
5043 |
%{ /* UNLIMITEDSTACK */ |
|
5044 |
||
5045 |
XEvent ev; |
|
5046 |
Window win; |
|
5047 |
int thereIsOne; |
|
1974 | 5048 |
OBJ rslt = false; |
295 | 5049 |
|
5050 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 5051 |
Display *dpy = myDpy; |
5052 |
||
1974 | 5053 |
ENTER_XLIB(); |
1344 | 5054 |
if (doSync == true) { |
5055 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
5056 |
} |
|
5057 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
5058 |
win = _WindowVal(aWindowIdOrNil); |
|
5059 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
5060 |
} else { |
|
5061 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
5062 |
} |
|
5063 |
if (thereIsOne) { |
|
5064 |
XPutBackEvent(dpy, &ev); |
|
1974 | 5065 |
rslt = true; |
5066 |
} |
|
5067 |
LEAVE_XLIB(); |
|
5068 |
} |
|
5069 |
RETURN ( rslt ); |
|
295 | 5070 |
%} |
5071 |
! |
|
5072 |
||
1344 | 5073 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 5074 |
"return true, if any expose event is pending for a specific view, |
5075 |
or any view (if the arg is nil). |
|
5076 |
This is an X specific, only required after a scroll operation." |
|
7 | 5077 |
|
12 | 5078 |
%{ /* UNLIMITEDSTACK */ |
7 | 5079 |
|
5080 |
XEvent ev; |
|
5081 |
Window win; |
|
81 | 5082 |
int thereIsOne; |
1974 | 5083 |
OBJ rslt = false; |
81 | 5084 |
|
150 | 5085 |
if (ISCONNECTED) { |
1344 | 5086 |
Display *dpy = myDpy; |
5087 |
||
1974 | 5088 |
ENTER_XLIB(); |
1344 | 5089 |
if (doSync == true) { |
5090 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
5091 |
} |
|
5092 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
5093 |
win = _WindowVal(aWindowIdOrNil); |
|
5094 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
5095 |
} else { |
|
5096 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
5097 |
} |
|
5098 |
if (thereIsOne) { |
|
5099 |
XPutBackEvent(dpy, &ev); |
|
1974 | 5100 |
rslt = true; |
5101 |
} |
|
5102 |
LEAVE_XLIB(); |
|
5103 |
} |
|
5104 |
RETURN ( rslt ); |
|
81 | 5105 |
%} |
5106 |
! |
|
5107 |
||
1344 | 5108 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 5109 |
"read next event - put into local eventBuffer. |
5110 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
5111 |
otherwise only events for that specific view will be fetched. |
|
5112 |
Returns true, if there was an event, false otherwise. |
|
5113 |
This method may block - so you better check for pending events |
|
5114 |
before calling for it. |
|
5115 |
||
5116 |
Sorry I had to split dispatch into this fetch method and an extra |
|
5117 |
handle method to allow unlimitedstack here. |
|
5118 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
5119 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
5120 |
" |
|
81 | 5121 |
|
5122 |
%{ /* UNLIMITEDSTACK */ |
|
5123 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5124 |
Display *dpy; |
295 | 5125 |
Window win, wWanted; |
5126 |
int evMask; |
|
5127 |
OBJ eB; |
|
5128 |
XEvent *ev; |
|
5129 |
||
5130 |
if (! ISCONNECTED) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5131 |
RETURN (false); |
295 | 5132 |
} |
5133 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5134 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5135 |
|
555 | 5136 |
eB = __INST(eventBuffer); |
295 | 5137 |
if (__isByteArray(eB)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5138 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 5139 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5140 |
printf("DISPLAY: no eventBuffer\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5141 |
RETURN (false); |
295 | 5142 |
} |
5143 |
ev->type = 0; |
|
5144 |
||
5145 |
if (__isSmallInteger(eventMask)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5146 |
evMask = __intVal(eventMask); |
295 | 5147 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5148 |
evMask = ~0; |
295 | 5149 |
} |
5150 |
||
5151 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5152 |
wWanted = _WindowVal(aViewIdOrNil); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5153 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5154 |
RETURN ( true ); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5155 |
} |
295 | 5156 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5157 |
if (evMask == ~0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5158 |
XNextEvent(dpy, ev); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5159 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5160 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5161 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5162 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5163 |
} |
295 | 5164 |
} |
5165 |
%}. |
|
5166 |
^ false |
|
5167 |
! |
|
5168 |
||
1344 | 5169 |
handleAllEvents |
295 | 5170 |
"from now on, handle any kind of event" |
5171 |
||
5172 |
dispatchingExpose := nil |
|
5173 |
! |
|
5174 |
||
1344 | 5175 |
handleExposeOnlyFor:aView |
295 | 5176 |
"from now on, handle expose events only" |
5177 |
||
5178 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5179 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5180 |
|
1344 | 5181 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5182 |
"One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5183 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5184 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5185 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 5186 |
self refreshKeyboardMapping:eB. |
5187 |
"Maybe some of our modifiers have been changed" |
|
5188 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5189 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5190 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
5191 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 5192 |
! |
5193 |
||
1344 | 5194 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
5195 |
"tell X that we are only interested in events from aMask, which |
295 | 5196 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
5197 |
||
5198 |
%{ /* NOCONTEXT */ |
|
5199 |
||
5200 |
int mask; |
|
5201 |
||
1209 | 5202 |
if (ISCONNECTED |
5203 |
&& __isExternalAddress(aWindowId) |
|
295 | 5204 |
&& __isSmallInteger(aMask)) { |
1344 | 5205 |
mask = __intVal(aMask); |
295 | 5206 |
|
5207 |
#ifdef OLD |
|
1344 | 5208 |
/* these may not be disabled */ |
5209 |
mask |= ExposureMask | StructureNotifyMask | |
|
5210 |
KeyPressMask | KeyReleaseMask | |
|
5211 |
EnterWindowMask | LeaveWindowMask | |
|
5212 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 5213 |
#endif |
5214 |
||
1974 | 5215 |
ENTER_XLIB(); |
1344 | 5216 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
1974 | 5217 |
LEAVE_XLIB(); |
1344 | 5218 |
RETURN ( self ); |
295 | 5219 |
} |
5220 |
%} |
|
5221 |
. |
|
5222 |
self primitiveFailed |
|
5223 |
! |
|
5224 |
||
1344 | 5225 |
startDispatch |
295 | 5226 |
"redefined to clear dispatchingExpose, which is a special X feature" |
5227 |
||
5228 |
dispatching ifTrue:[^ self]. |
|
5229 |
dispatchingExpose := nil. |
|
5230 |
super startDispatch |
|
0 | 5231 |
! ! |
295 | 5232 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5233 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5234 |
|
1567 | 5235 |
sendClientEvent:msgType format:msgFormat to:targetWindowID data1:d1 data2:d2 data3:d3 data4:d4 data5:d5 |
1556 | 5236 |
"send a ClientMessage to some other (possibly: non-ST/X) view. |
1567 | 5237 |
The client message gets message_type and msgFormat as specified by |
1556 | 5238 |
the arguments. The additional data arguments specify up to |
5239 |
5 longWords of user data; each may be an integer or nil. |
|
5240 |
It is passed transparently in the events data field. |
|
5241 |
See XProtocol specification for more details." |
|
5242 |
||
5243 |
"/ Event.xclient.type = ClientMessage; |
|
5244 |
"/ Event.xclient.display = dpy; |
|
5245 |
"/ Event.xclient.message_type = msgType; |
|
1567 | 5246 |
"/ Event.xclient.format = msgFormat; |
1556 | 5247 |
"/ Event.xclient.window = targetWindowID; |
5248 |
"/ Event.xclient.data.l[0] = d1 |
|
5249 |
"/ Event.xclient.data.l[1] = d2 |
|
5250 |
"/ Event.xclient.data.l[2] = d3 |
|
5251 |
"/ Event.xclient.data.l[3] = d4 |
|
5252 |
"/ Event.xclient.data.l[4] = d5 |
|
5253 |
"/ |
|
5254 |
"/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event); |
|
5255 |
||
5256 |
%{ /* NOCONTEXT */ |
|
5257 |
int type; |
|
5258 |
int state; |
|
5259 |
||
5260 |
if (ISCONNECTED |
|
5261 |
&& __isInteger(msgType) |
|
1567 | 5262 |
&& __isInteger(msgFormat) |
1556 | 5263 |
&& (__isExternalAddress(targetWindowID) || __isInteger(targetWindowID))) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5264 |
Display *dpy = myDpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5265 |
XEvent ev; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5266 |
Status result; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5267 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5268 |
if (__isInteger(d1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5269 |
ev.xclient.data.l[0] = __longIntVal(d1); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5270 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5271 |
if (__isExternalAddress(d1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5272 |
ev.xclient.data.l[0] = (int)__externalAddressVal(d1); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5273 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5274 |
ev.xclient.data.l[0] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5275 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5276 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5277 |
if (__isInteger(d2)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5278 |
ev.xclient.data.l[1] = __longIntVal(d2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5279 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5280 |
if (__isExternalAddress(d2)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5281 |
ev.xclient.data.l[1] = (int)__externalAddressVal(d2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5282 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5283 |
ev.xclient.data.l[1] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5284 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5285 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5286 |
if (__isInteger(d3)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5287 |
ev.xclient.data.l[2] = __longIntVal(d3); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5288 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5289 |
if (__isExternalAddress(d3)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5290 |
ev.xclient.data.l[2] = (int)__externalAddressVal(d3); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5291 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5292 |
ev.xclient.data.l[2] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5293 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5294 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5295 |
if (__isInteger(d4)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5296 |
ev.xclient.data.l[3] = __longIntVal(d4); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5297 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5298 |
if (__isExternalAddress(d4)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5299 |
ev.xclient.data.l[3] = (int)__externalAddressVal(d4); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5300 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5301 |
ev.xclient.data.l[3] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5302 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5303 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5304 |
if (__isInteger(d5)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5305 |
ev.xclient.data.l[4] = __longIntVal(d5); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5306 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5307 |
if (__isExternalAddress(d5)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5308 |
ev.xclient.data.l[4] = (int)__externalAddressVal(d5); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5309 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5310 |
ev.xclient.data.l[4] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5311 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5312 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5313 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5314 |
if (__isExternalAddress(targetWindowID)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5315 |
ev.xclient.window = _WindowVal(targetWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5316 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5317 |
ev.xclient.window = (Window)__longIntVal(targetWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5318 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5319 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5320 |
ev.xclient.type = ClientMessage; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5321 |
ev.xclient.display = dpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5322 |
ev.xclient.message_type = __longIntVal(msgType); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5323 |
ev.xclient.format = __longIntVal(msgFormat); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5324 |
|
1974 | 5325 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5326 |
result = XSendEvent(dpy, ev.xclient.window, True, NoEventMask , &ev); |
1974 | 5327 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5328 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5329 |
if ((result == BadValue) || (result == BadWindow)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5330 |
DPRINTF(("bad status in sendClientEvent\n")); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5331 |
RETURN ( false ) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5332 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5333 |
RETURN (true) |
1556 | 5334 |
} |
5335 |
%}. |
|
5336 |
self primitiveFailed. |
|
5337 |
^ false |
|
5338 |
! |
|
5339 |
||
1344 | 5340 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5341 |
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5342 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5343 |
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5344 |
for key events, it can be either a symbol (as listen in X's keySyms) |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5345 |
or a numeric keysym code. If state is nil, the modifier bits (shift & control) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5346 |
are computed from the keyboardMap - if non-nil, these are passed as modifierbits. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5347 |
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5348 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5349 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5350 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5351 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5352 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5353 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5354 |
if (__isSmallInteger(stateMask)) { |
1344 | 5355 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5356 |
} else { |
1344 | 5357 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5358 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5359 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5360 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5361 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5362 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5363 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 5364 |
Display *dpy = myDpy; |
5365 |
||
5366 |
XEvent ev; |
|
5367 |
Window target; |
|
5368 |
Status result; |
|
5369 |
KeySym keySym, *syms; |
|
5370 |
int screen = __intVal(__INST(screen)); |
|
5371 |
char s[2]; |
|
5372 |
int nSyms; |
|
5373 |
||
5374 |
if ((typeSymbol == @symbol(keyPress)) |
|
5375 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
5376 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
5377 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
5378 |
} else { |
|
5379 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
5380 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
5381 |
s[1] = '\0'; |
|
5382 |
keySym = XStringToKeysym(s); |
|
5383 |
} else { |
|
5384 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
5385 |
} |
|
5386 |
} |
|
5387 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
5388 |
||
5389 |
if (stateMask == nil) { |
|
5390 |
/* |
|
5391 |
* get the modifier from the keySym |
|
5392 |
*/ |
|
5393 |
nSyms = 0; |
|
5394 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
5395 |
if (syms) { |
|
5396 |
int i; |
|
5397 |
||
5398 |
for (i=0; i<nSyms; i++) { |
|
5399 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5400 |
#ifdef MODIFIERDEBUG |
1344 | 5401 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5402 |
#endif |
1344 | 5403 |
if (i) state = (1 << (i-1)); |
5404 |
break; |
|
5405 |
} |
|
5406 |
} |
|
5407 |
XFree(syms); |
|
5408 |
} |
|
5409 |
} |
|
5410 |
} else { |
|
5411 |
if ((typeSymbol == @symbol(buttonPress)) |
|
5412 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
5413 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
5414 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
5415 |
} else { |
|
5416 |
ev.xbutton.button = 1; |
|
5417 |
} |
|
5418 |
} else { |
|
5419 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
5420 |
RETURN (false); |
|
5421 |
} |
|
5422 |
} |
|
5423 |
||
5424 |
if (typeSymbol == @symbol(keyPress)) |
|
5425 |
ev.xany.type = KeyPress; |
|
5426 |
else if (typeSymbol == @symbol(keyRelease)) |
|
5427 |
ev.xany.type = KeyRelease; |
|
5428 |
else if (typeSymbol == @symbol(buttonPress)) |
|
5429 |
ev.xany.type = ButtonPress; |
|
5430 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
5431 |
ev.xany.type = ButtonRelease; |
|
5432 |
||
5433 |
if (__isExternalAddress(targetId)) { |
|
5434 |
target = _WindowVal(targetId); |
|
5435 |
} else { |
|
5436 |
target = (Window) __longIntVal(targetId); |
|
5437 |
} |
|
5438 |
ev.xkey.window = target; |
|
5439 |
ev.xkey.same_screen = 1; |
|
5440 |
ev.xkey.subwindow = 0; |
|
5441 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
5442 |
ev.xkey.x = __intVal(xPos); |
|
5443 |
ev.xkey.y = __intVal(yPos); |
|
5444 |
ev.xkey.state = state; |
|
5445 |
ev.xkey.time = CurrentTime; |
|
5446 |
||
1974 | 5447 |
ENTER_XLIB(); |
1344 | 5448 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
1974 | 5449 |
LEAVE_XLIB(); |
1344 | 5450 |
if ((result == BadValue) || (result == BadWindow)) { |
5451 |
DPRINTF(("bad status\n")); |
|
5452 |
RETURN ( false ) |
|
5453 |
} |
|
5454 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5455 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5456 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5457 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5458 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5459 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5460 |
|
1344 | 5461 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5462 |
"send input to some other view, by simulating keyPress/keyRelease |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5463 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5464 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5465 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 5466 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5467 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5468 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5469 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5470 |
aCharacterOrString isString ifTrue:[ |
1344 | 5471 |
aCharacterOrString do:[:char | |
5472 |
self simulateKeyboardInput:char inViewId:viewId |
|
5473 |
]. |
|
5474 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5475 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5476 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5477 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5478 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5479 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5480 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 5481 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5482 |
] ifFalse:[ |
1344 | 5483 |
(aCharacterOrString == Character tab) ifTrue:[ |
5484 |
code := #Tab |
|
5485 |
] ifFalse:[ |
|
5486 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
5487 |
code := #Escape |
|
5488 |
] |
|
5489 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5490 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5491 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5492 |
control ifTrue:[ |
1344 | 5493 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5494 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5495 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5496 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5497 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5498 |
"/ (sendKeyOrButtonevent should be able to figure out things itself) |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5499 |
"/ however, on some linux systems it seems to not work correctly. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5500 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5501 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5502 |
code isNumber ifTrue:[ |
1344 | 5503 |
code >= $A asciiValue ifTrue:[ |
5504 |
code <= $Z asciiValue ifTrue:[ |
|
5505 |
state := self shiftMask |
|
5506 |
] |
|
5507 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5508 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5509 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5510 |
self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5511 |
self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5512 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5513 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5514 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5515 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5516 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5517 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5518 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5519 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5520 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5521 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5522 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5523 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5524 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5525 |
|
295 | 5526 |
!XWorkstation methodsFor:'font stuff'! |
5527 |
||
1344 | 5528 |
createFontFor:aFontName |
295 | 5529 |
"a basic method for X-font allocation; this method allows |
5530 |
any font to be aquired (even those not conforming to |
|
5531 |
standard naming conventions, such as cursor, fixed or k14)" |
|
5532 |
||
5533 |
%{ /* UNLIMITEDSTACK */ |
|
5534 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
5535 |
||
5536 |
XFontStruct *newFont; |
|
5537 |
||
5538 |
if (ISCONNECTED) { |
|
1344 | 5539 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
5540 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 5541 |
ENTER_XLIB(); |
1344 | 5542 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
1974 | 5543 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5544 |
#ifdef COUNT_RESOURCES |
1344 | 5545 |
if (newFont) |
5546 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5547 |
#endif |
1344 | 5548 |
END_INTERRUPTSBLOCKED |
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
5549 |
RETURN ( newFont ? __MKEXTERNALADDRESS(newFont) : nil ); |
1344 | 5550 |
} |
295 | 5551 |
} |
5552 |
%}. |
|
5553 |
^ nil |
|
5554 |
! |
|
5555 |
||
1344 | 5556 |
decomposeXFontName:aString into:aBlock |
295 | 5557 |
"extract family, face, style and size from an |
5558 |
X-font name |
|
5559 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
5560 |
evaluate aBlock with these" |
|
5561 |
||
5562 |
|origin family face style moreStyle skip fheight size |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5563 |
resX resY x1 x2 registry encoding coding start end | |
295 | 5564 |
|
5565 |
aString isNil ifTrue:[^ false]. |
|
5566 |
(aString startsWith:'-') ifFalse:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5567 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5568 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5569 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5570 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5571 |
end := aString indexOf:$- startingAt:1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5572 |
family := aString copyFrom:1 to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5573 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5574 |
end := aString indexOf:$- startingAt:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5575 |
style := aString copyFrom:start to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5576 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5577 |
size := aString copyFrom:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5578 |
size := (Number readFromString:size onError:[^false]). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5579 |
aBlock value:family value:nil value:style value:size value:nil. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5580 |
^ true. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5581 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5582 |
('*-[0-9]*' match:aString) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5583 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5584 |
something like lucidasans-24 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5585 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5586 |
end := aString indexOf:$- startingAt:1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5587 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5588 |
family := aString copyFrom:1 to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5589 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5590 |
size := aString copyFrom:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5591 |
size := (Number readFromString:size onError:[^false]). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5592 |
aBlock value:family value:nil value:nil value:size value:nil. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5593 |
^ true. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5594 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5595 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5596 |
^ true. |
295 | 5597 |
]. |
5598 |
||
5599 |
end := aString indexOf:$- startingAt:2. |
|
5600 |
(end == 0) ifTrue:[^ false]. |
|
5601 |
origin := aString copyFrom:2 to:(end - 1). |
|
5602 |
||
5603 |
start := end + 1. |
|
5604 |
end := aString indexOf:$- startingAt:start. |
|
5605 |
(end == 0) ifTrue:[^ false]. |
|
5606 |
family := aString copyFrom:start to:(end - 1). |
|
5607 |
||
5608 |
start := end + 1. |
|
5609 |
end := aString indexOf:$- startingAt:start. |
|
5610 |
(end == 0) ifTrue:[^ false]. |
|
5611 |
face := aString copyFrom:start to:(end - 1). |
|
5612 |
||
5613 |
start := end + 1. |
|
5614 |
end := aString indexOf:$- startingAt:start. |
|
5615 |
(end == 0) ifTrue:[^ false]. |
|
5616 |
style := aString copyFrom:start to:(end - 1). |
|
5617 |
(style = 'o') ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5618 |
style := 'oblique' |
295 | 5619 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5620 |
(style = 'i') ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5621 |
style := 'italic' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5622 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5623 |
(style = 'r') ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5624 |
style := 'roman' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5625 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5626 |
] |
295 | 5627 |
]. |
5628 |
||
5629 |
start := end + 1. |
|
5630 |
end := aString indexOf:$- startingAt:start. |
|
5631 |
(end == 0) ifTrue:[^ false]. |
|
5632 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
5633 |
||
5634 |
start := end + 1. |
|
5635 |
end := aString indexOf:$- startingAt:start. |
|
5636 |
(end == 0) ifTrue:[^ false]. |
|
5637 |
skip := aString copyFrom:start to:(end - 1). |
|
5638 |
||
5639 |
start := end + 1. |
|
5640 |
end := aString indexOf:$- startingAt:start. |
|
5641 |
(end == 0) ifTrue:[^ false]. |
|
5642 |
fheight := aString copyFrom:start to:(end - 1). |
|
5643 |
||
5644 |
start := end + 1. |
|
5645 |
end := aString indexOf:$- startingAt:start. |
|
5646 |
(end == 0) ifTrue:[^ false]. |
|
5647 |
size := aString copyFrom:start to:(end - 1). |
|
5648 |
size := (Number readFromString:size) / 10. |
|
5649 |
||
5650 |
start := end + 1. |
|
5651 |
end := aString indexOf:$- startingAt:start. |
|
5652 |
(end == 0) ifTrue:[^ false]. |
|
5653 |
resX := aString copyFrom:start to:(end - 1). |
|
5654 |
||
5655 |
start := end + 1. |
|
5656 |
end := aString indexOf:$- startingAt:start. |
|
5657 |
(end == 0) ifTrue:[^ false]. |
|
5658 |
resY := aString copyFrom:start to:(end - 1). |
|
5659 |
||
5660 |
start := end + 1. |
|
5661 |
end := aString indexOf:$- startingAt:start. |
|
5662 |
(end == 0) ifTrue:[^ false]. |
|
5663 |
x1 := aString copyFrom:start to:(end - 1). |
|
5664 |
||
5665 |
start := end + 1. |
|
5666 |
end := aString indexOf:$- startingAt:start. |
|
5667 |
(end == 0) ifTrue:[^ false]. |
|
5668 |
x2 := aString copyFrom:start to:(end - 1). |
|
5669 |
||
5670 |
start := end + 1. |
|
5671 |
end := aString indexOf:$- startingAt:start. |
|
5672 |
(end == 0) ifTrue:[^ false]. |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5673 |
registry := aString copyFrom:start to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5674 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5675 |
encoding := aString copyFrom:end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5676 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5677 |
coding := registry , '-' , encoding. |
295 | 5678 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5679 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5680 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5681 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5682 |
|
295 | 5683 |
aBlock value:family value:face value:style value:size value:coding. |
5684 |
^ true |
|
5685 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5686 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5687 |
"Modified: 10.4.1997 / 09:45:36 / cg" |
295 | 5688 |
! |
5689 |
||
1344 | 5690 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5691 |
"the fonts encoding - if the font does not provide that info, |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5692 |
return nil (and assume #ascii, which is a subset of #iso8859)." |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5693 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5694 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5695 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5696 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5697 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5698 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5699 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5700 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5701 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5702 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5703 |
if (ISCONNECTED) { |
1344 | 5704 |
Display *dpy = myDpy; |
5705 |
||
5706 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
5707 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
5708 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
5709 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5710 |
||
5711 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5712 |
|
1344 | 5713 |
f = _FontVal(aFontId); |
5714 |
if (f) { |
|
5715 |
n = f->n_properties; |
|
5716 |
prop = f->properties; |
|
5717 |
if (prop) { |
|
5718 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5719 |
#ifdef SUPERDEBUG |
1344 | 5720 |
cp = XGetAtomName(dpy, prop->name); |
5721 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5722 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5723 |
#endif |
1344 | 5724 |
if (prop->name == XA_FULL_NAME) { |
5725 |
cp = XGetAtomName(dpy, prop->card32); |
|
5726 |
if (cp) { |
|
5727 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5728 |
#ifdef SUPERDEBUG |
1344 | 5729 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5730 |
#endif |
1344 | 5731 |
XFree(cp); |
5732 |
} |
|
5733 |
} else if (prop->name == fontAtom) { |
|
5734 |
cp = XGetAtomName(dpy, prop->card32); |
|
5735 |
if (cp) { |
|
5736 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5737 |
#ifdef SUPERDEBUG |
1344 | 5738 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5739 |
#endif |
1344 | 5740 |
XFree(cp); |
5741 |
} |
|
5742 |
} else if (prop->name == encodingAtom) { |
|
5743 |
cp = XGetAtomName(dpy, prop->card32); |
|
5744 |
if (cp) { |
|
5745 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5746 |
#ifdef SUPERDEBUG |
1344 | 5747 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5748 |
#endif |
1344 | 5749 |
XFree(cp); |
5750 |
} |
|
5751 |
} else if (prop->name == registryAtom) { |
|
5752 |
cp = XGetAtomName(dpy, prop->card32); |
|
5753 |
if (cp) { |
|
5754 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5755 |
#ifdef SUPERDEBUG |
1344 | 5756 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5757 |
#endif |
1344 | 5758 |
XFree(cp); |
5759 |
} |
|
5760 |
} else if (prop->name == charSetCollAtom) { |
|
5761 |
cp = XGetAtomName(dpy, prop->card32); |
|
5762 |
if (cp) { |
|
5763 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5764 |
#ifdef SUPERDEBUG |
1344 | 5765 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5766 |
#endif |
1344 | 5767 |
XFree(cp); |
5768 |
} |
|
5769 |
} |
|
5770 |
prop++; |
|
5771 |
} |
|
5772 |
} |
|
5773 |
} |
|
5774 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5775 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5776 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5777 |
^ self |
1344 | 5778 |
extractEncodingFromRegistry:registry |
5779 |
encoding:encoding |
|
5780 |
charSetCollections:charSetCollections |
|
5781 |
! |
|
5782 |
||
5783 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5784 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5785 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5786 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5787 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5788 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 5789 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5790 |
] ifFalse:[ |
1344 | 5791 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
5792 |
enc := encoding asLowercase asSymbol |
|
5793 |
] ifFalse:[ |
|
5794 |
charSets := charSetCollections. |
|
5795 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
5796 |
charSets := charSets asUppercase asCollectionOfWords. |
|
5797 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
5798 |
enc := #iso8859 |
|
5799 |
] ifFalse:[ |
|
5800 |
(charSets includes:'ISO8859') ifTrue:[ |
|
5801 |
enc := #iso8859 |
|
5802 |
] ifFalse:[ |
|
5803 |
(charSets includes:'ASCII') ifTrue:[ |
|
5804 |
enc := #ascii |
|
5805 |
] ifFalse:[ |
|
5806 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
5807 |
enc := #iso8859 |
|
5808 |
] |
|
5809 |
] |
|
5810 |
] |
|
5811 |
] |
|
5812 |
] |
|
5813 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5814 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5815 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5816 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5817 |
"Created: 17.4.1996 / 14:57:06 / cg" |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5818 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5819 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5820 |
|
1344 | 5821 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5822 |
"flush the cached list of all available fonts on this display. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5823 |
Required if new fonts have been added on the display server." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5824 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5825 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5826 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5827 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5828 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5829 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5830 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5831 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5832 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5833 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5834 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5835 |
|
1344 | 5836 |
fontMetricsOf:fontId into:aBlock |
991 | 5837 |
"evaluate aBlock, passing a fonts metrics as arguments" |
5838 |
||
5839 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5840 |
maxAscent maxDescent minWidth maxWidth avgWidth |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5841 |
res resX resY| |
991 | 5842 |
|
994 | 5843 |
%{ |
991 | 5844 |
XFontStruct *f; |
5845 |
int len; |
|
5846 |
||
5847 |
if (ISCONNECTED) { |
|
1344 | 5848 |
if (__isExternalAddress(fontId)) { |
5849 |
f = _FontVal(fontId); |
|
5850 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5851 |
#ifdef NOTDEF |
1344 | 5852 |
char *cp; |
5853 |
XFontProp *prop; |
|
5854 |
||
5855 |
n = f->n_properties; |
|
5856 |
prop = f->properties; |
|
5857 |
||
5858 |
if (prop) { |
|
5859 |
while (n--) { |
|
5860 |
if (prop->name == RESOLUTION_X) { |
|
5861 |
resX = __MKSMALLINT(prop->card32); |
|
5862 |
} else if (prop->name == RESOLUTION_Y) { |
|
5863 |
resY = __MKSMALLINT(prop->card32); |
|
5864 |
} else if (prop->name == RESOLUTION) { |
|
5865 |
res = __MKSMALLINT(prop->card32); |
|
5866 |
} |
|
5867 |
prop++; |
|
5868 |
} |
|
5869 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5870 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5871 |
|
1344 | 5872 |
avgAscent = __MKSMALLINT(f->ascent); |
5873 |
avgDescent = __MKSMALLINT(f->descent); |
|
5874 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
5875 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
5876 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
5877 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
5878 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 5879 |
ENTER_XLIB(); |
1344 | 5880 |
len = XTextWidth(f, " ", 1); |
1974 | 5881 |
LEAVE_XLIB(); |
1344 | 5882 |
END_INTERRUPTSBLOCKED |
5883 |
avgWidth = __MKSMALLINT( len ); |
|
5884 |
} |
|
5885 |
} |
|
991 | 5886 |
} |
5887 |
%}. |
|
5888 |
encoding := self encodingOf:fontId. |
|
5889 |
aBlock value:encoding |
|
1344 | 5890 |
value:avgAscent |
5891 |
value:avgDescent |
|
5892 |
value:maxAscent |
|
5893 |
value:maxDescent |
|
5894 |
value:minWidth |
|
5895 |
value:maxWidth |
|
5896 |
value:avgWidth |
|
5897 |
! |
|
5898 |
||
5899 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5900 |
"return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution, |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5901 |
but due to errors in some XServer installations, some use 75dpi fonts on higher |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5902 |
resolution displays and vice/versa." |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5903 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5904 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5905 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5906 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5907 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5908 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5909 |
if (ISCONNECTED) { |
1344 | 5910 |
Display *dpy = myDpy; |
5911 |
||
5912 |
if (__isExternalAddress(fontId)) { |
|
5913 |
f = _FontVal(fontId); |
|
5914 |
if (f) { |
|
5915 |
char *cp; |
|
5916 |
XFontProp *prop; |
|
5917 |
Atom resolutionXAtom, resolutionYAtom; |
|
5918 |
int n; |
|
5919 |
||
5920 |
n = f->n_properties; |
|
5921 |
prop = f->properties; |
|
5922 |
||
5923 |
if (prop) { |
|
5924 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
5925 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
5926 |
||
5927 |
while (n--) { |
|
5928 |
if (prop->name == resolutionXAtom) { |
|
5929 |
resX = __MKSMALLINT(prop->card32); |
|
5930 |
} else if (prop->name == resolutionYAtom) { |
|
5931 |
resY = __MKSMALLINT(prop->card32); |
|
5932 |
} else if (prop->name == XA_RESOLUTION) { |
|
5933 |
res = __MKSMALLINT(prop->card32); |
|
5934 |
} |
|
5935 |
prop++; |
|
5936 |
} |
|
5937 |
} |
|
5938 |
} |
|
5939 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5940 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5941 |
%}. |
1046 | 5942 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 5943 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5944 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5945 |
res notNil ifTrue:[ |
1344 | 5946 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5947 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5948 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5949 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5950 |
|
1344 | 5951 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5952 |
"the fonts fullName - this is very device specific and should only be |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5953 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5954 |
If the display/font do not provide that info, return nil." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5955 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5956 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5957 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5958 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5959 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5960 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5961 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5962 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5963 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5964 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5965 |
if (ISCONNECTED) { |
1344 | 5966 |
Display *dpy = myDpy; |
5967 |
||
5968 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5969 |
||
5970 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5971 |
|
1344 | 5972 |
f = _FontVal(aFontId); |
5973 |
if (f) { |
|
5974 |
n = f->n_properties; |
|
5975 |
prop = f->properties; |
|
5976 |
if (prop) { |
|
5977 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5978 |
#ifdef SUPERDEBUG |
1344 | 5979 |
cp = XGetAtomName(dpy, prop->name); |
5980 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5981 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5982 |
#endif |
1344 | 5983 |
if (prop->name == XA_FULL_NAME) { |
5984 |
cp = XGetAtomName(dpy, prop->card32); |
|
5985 |
if (cp) { |
|
5986 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5987 |
#ifdef SUPERDEBUG |
1344 | 5988 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5989 |
#endif |
1344 | 5990 |
XFree(cp); |
5991 |
} |
|
5992 |
} |
|
5993 |
if (prop->name == fontAtom) { |
|
5994 |
cp = XGetAtomName(dpy, prop->card32); |
|
5995 |
if (cp) { |
|
5996 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5997 |
#ifdef SUPERDEBUG |
1344 | 5998 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5999 |
#endif |
1344 | 6000 |
XFree(cp); |
6001 |
} |
|
6002 |
} |
|
6003 |
prop++; |
|
6004 |
} |
|
6005 |
} |
|
6006 |
} |
|
6007 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6008 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6009 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6010 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 6011 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6012 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6013 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6014 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
6015 |
|
1344 | 6016 |
getAvailableFontsMatching:pattern |
295 | 6017 |
"return an Array filled with font names matching aPattern" |
6018 |
||
6019 |
%{ /* UNLIMITEDSTACK */ |
|
6020 |
||
6021 |
int nnames = 1500; |
|
6022 |
int available = nnames + 1; |
|
6023 |
char **fonts; |
|
6024 |
OBJ arr, str; |
|
6025 |
int i; |
|
6026 |
||
6027 |
if (ISCONNECTED) { |
|
1344 | 6028 |
if (__isString(pattern)) { |
6029 |
for (;;) { |
|
6030 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
6031 |
if ((fonts == NULL) || (available < nnames)) break; |
|
6032 |
XFreeFontNames(fonts); |
|
6033 |
nnames = available * 2; |
|
6034 |
} |
|
6035 |
if (fonts == NULL) { |
|
6036 |
RETURN ( nil ); |
|
6037 |
} |
|
6038 |
/* |
|
6039 |
* now, that we know the number of font names, |
|
6040 |
* create the array ... |
|
6041 |
*/ |
|
6042 |
arr = __ARRAY_NEW_INT(available); |
|
6043 |
if (! arr) { |
|
6044 |
RETURN (nil); |
|
6045 |
} |
|
6046 |
/* |
|
6047 |
* ... and fill it |
|
6048 |
*/ |
|
6049 |
for (i=0; i<available; i++) { |
|
6050 |
__PROTECT__(arr); |
|
6051 |
str = __MKSTRING(fonts[i]); |
|
6052 |
__UNPROTECT__(arr); |
|
6053 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
6054 |
} |
|
6055 |
RETURN (arr); |
|
6056 |
} |
|
295 | 6057 |
} |
6058 |
%}. |
|
6059 |
^ nil |
|
6060 |
! |
|
6061 |
||
1344 | 6062 |
getDefaultFont |
295 | 6063 |
"return a default font id - used when class Font cannot |
6064 |
find anything usable" |
|
6065 |
||
6066 |
^ self createFontFor:'fixed' |
|
6067 |
! |
|
6068 |
||
1344 | 6069 |
getFontWithFamily:familyString face:faceString |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6070 |
style:styleArgString size:sizeArg encoding:encoding |
295 | 6071 |
|
6072 |
"try to get the specified font, if not available, try next smaller |
|
6073 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
6074 |
as family and the other parameters as nil. For example, the cursor font |
|
6075 |
can be aquired that way." |
|
6076 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6077 |
|styleString theName theId xlatedStyle |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6078 |
id spacing encodingMatch registryMatch idx| |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6079 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6080 |
styleString := styleArgString. |
295 | 6081 |
|
6082 |
"special: if face is nil, allow access to X-fonts" |
|
6083 |
faceString isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6084 |
sizeArg notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6085 |
theName := familyString , '-' , sizeArg printString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6086 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6087 |
theName := familyString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6088 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6089 |
theName isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6090 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6091 |
mhmh - fall back to the default font |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6092 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6093 |
theName := 'fixed' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6094 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6095 |
theId := self createFontFor:theName. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6096 |
theId isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6097 |
theId := self getDefaultFont |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6098 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6099 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6100 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6101 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6102 |
"/ spacing other than 'normal' is contained as last component |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6103 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6104 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
6105 |
(styleString notNil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
6106 |
and:[(styleString endsWith:'-narrow') |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6107 |
or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6108 |
|i| |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6109 |
i := styleString lastIndexOf:$-. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6110 |
spacing := styleString copyFrom:(i+1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6111 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6112 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6113 |
spacing := 'normal'. |
295 | 6114 |
]. |
6115 |
||
6116 |
xlatedStyle := styleString. |
|
6117 |
xlatedStyle notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6118 |
xlatedStyle := xlatedStyle first asString |
295 | 6119 |
]. |
6120 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6121 |
encodingMatch := encoding. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6122 |
registryMatch := '*'. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6123 |
encoding isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6124 |
encodingMatch := '*'. |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6125 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6126 |
idx := encoding indexOf:$-. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6127 |
idx ~~ 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6128 |
encodingMatch := encoding copyTo:idx - 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6129 |
registryMatch := encoding copyFrom:idx + 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6130 |
]. |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6131 |
]. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6132 |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6133 |
id := self |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6134 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6135 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6136 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6137 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6138 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6139 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6140 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6141 |
registry:encodingMatch |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6142 |
encoding:registryMatch. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6143 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6144 |
id isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6145 |
(encodingMatch notNil and:[encodingMatch ~= '*']) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6146 |
"/ too stupid: encodings come in both cases |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6147 |
"/ and X does not ignore case |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6148 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6149 |
id := self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6150 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6151 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6152 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6153 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6154 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6155 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6156 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6157 |
registry:encodingMatch asUppercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6158 |
encoding:registryMatch. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6159 |
id isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6160 |
id := self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6161 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6162 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6163 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6164 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6165 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6166 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6167 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6168 |
registry:encodingMatch asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6169 |
encoding:registryMatch. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6170 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6171 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6172 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6173 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6174 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
6175 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6176 |
"Modified: 10.4.1997 / 19:20:06 / cg" |
295 | 6177 |
! |
6178 |
||
1344 | 6179 |
getFontWithFoundry:foundry family:family weight:weight |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6180 |
slant:slant spacing:spc pixelSize:pSize size:size |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6181 |
registry:registry encoding:encoding |
295 | 6182 |
|
6183 |
"get the specified font, if not available, return nil. |
|
6184 |
This is the new font creation method - all others will be changed to |
|
6185 |
use this entry. |
|
6186 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
6187 |
||
6188 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
6189 |
family: 'helvetica' 'courier' 'times' ... |
|
6190 |
weight: 'bold' 'medium' 'demi' ... |
|
6191 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
6192 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
6193 |
pixelSize: 16,18 ... usually left empty |
|
6194 |
size: size in point (1/72th of an inch) |
|
6195 |
registry: iso8859, sgi ... '*' |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6196 |
encoding: registry specific encoding (usually '*') |
295 | 6197 |
" |
6198 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6199 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6200 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 6201 |
pSizeMatch registryMatch encodingMatch| |
295 | 6202 |
|
6203 |
"this works only on 'Release >= 3' - X-servers" |
|
6204 |
"name is: |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6205 |
-foundry-family -weight -slant- |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6206 |
sony helvetica bold r |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6207 |
adobe courier medium i |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6208 |
msic fixed o |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6209 |
... ... |
295 | 6210 |
" |
6211 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6212 |
size isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6213 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6214 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6215 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6216 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6217 |
foundry isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6218 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6219 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6220 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6221 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6222 |
family isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6223 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6224 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6225 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6226 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6227 |
weight isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6228 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6229 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6230 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6231 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6232 |
slant isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6233 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6234 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6235 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6236 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6237 |
spc isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6238 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6239 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6240 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6241 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6242 |
pSize isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6243 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6244 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6245 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6246 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6247 |
registry isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6248 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6249 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6250 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6251 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6252 |
encoding isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6253 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6254 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6255 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6256 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6257 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6258 |
theName := ('-' , foundryMatch, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6259 |
'-' , familyMatch, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6260 |
'-' , weightMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6261 |
'-' , slantMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6262 |
'-' , spcMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6263 |
'-*' , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6264 |
'-' , pSizeMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6265 |
'-' , sizeMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6266 |
'-*-*-*-*' , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6267 |
'-' , registryMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6268 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6269 |
|
697 | 6270 |
"/ Transcript showCR:theName; endEntry. |
295 | 6271 |
|
6272 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6273 |
|
295 | 6274 |
|
6275 |
" |
|
6276 |
Display getFontWithFoundry:'*' |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6277 |
family:'courier' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6278 |
weight:'medium' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6279 |
slant:'r' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6280 |
spacing:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6281 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6282 |
size:13 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6283 |
registry:'iso8859' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6284 |
encoding:'*' |
295 | 6285 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
6286 |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
6287 |
"Modified: 10.4.1997 / 19:15:44 / cg" |
295 | 6288 |
! |
6289 |
||
1344 | 6290 |
listOfAvailableFonts |
295 | 6291 |
"return a list with all available fonts on this display. |
6292 |
Since this takes a long time, keep the result of the query for the |
|
6293 |
next time. The elements of the returned collection are instances of |
|
6294 |
FontDescription." |
|
6295 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
6296 |
|"stream aName fntDescr" names| |
295 | 6297 |
|
6298 |
listOfXFonts isNil ifTrue:[ |
|
6299 |
"/ |
|
6300 |
"/ old code; using a pipe to xlsfonts |
|
6301 |
"/ |
|
6302 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
6303 |
"/ stream isNil ifTrue:[^ nil]. |
|
6304 |
"/ listOfXFonts := OrderedCollection new. |
|
6305 |
"/ [stream atEnd] whileFalse:[ |
|
6306 |
"/ aName := stream nextLine. |
|
6307 |
"/ aName notNil ifTrue:[ |
|
6308 |
"/ self decomposeXFontName:aName into: |
|
6309 |
"/ [:family :face :style :size :coding | |
|
6310 |
"/ family notNil ifTrue:[ |
|
6311 |
"/ fntDescr := FontDescription |
|
6312 |
"/ family:family |
|
6313 |
"/ face:face |
|
6314 |
"/ style:style |
|
6315 |
"/ size:size |
|
6316 |
"/ encoding:coding. |
|
6317 |
"/ listOfXFonts add:fntDescr |
|
6318 |
"/ ] |
|
6319 |
"/ ] |
|
6320 |
"/ ] |
|
6321 |
"/ ]. |
|
6322 |
"/ stream close. |
|
6323 |
"/ "if xlsfont is broken ... (hey sco)" |
|
6324 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
6325 |
"/ listOfXFonts := nil |
|
6326 |
"/ ] ifFalse:[ |
|
6327 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
6328 |
"/ ]. |
|
6329 |
||
1344 | 6330 |
"/ |
6331 |
"/ new code: |
|
6332 |
"/ use new primitive to get font names; |
|
6333 |
"/ this is much faster, and also works on systems where |
|
6334 |
"/ a) xlsfonts is broken (sco) |
|
6335 |
"/ b) xlsfonts is not available (aix) |
|
6336 |
"/ |
|
6337 |
names := self getAvailableFontsMatching:'*'. |
|
6338 |
names isNil ifTrue:[ |
|
6339 |
"no names returned ..." |
|
6340 |
^ nil |
|
6341 |
]. |
|
6342 |
listOfXFonts := names collect:[:aName | |
|
6343 |
|fntDescr| |
|
6344 |
||
6345 |
(self decomposeXFontName:aName into: |
|
6346 |
[:family :face :style :size :coding | |
|
6347 |
family notNil ifTrue:[ |
|
6348 |
fntDescr := FontDescription |
|
6349 |
family:family |
|
6350 |
face:face |
|
6351 |
style:style |
|
6352 |
size:size |
|
6353 |
encoding:coding. |
|
6354 |
] ifFalse:[ |
|
6355 |
fntDescr := FontDescription |
|
6356 |
name:aName |
|
6357 |
] |
|
6358 |
] |
|
6359 |
) ifFalse:[ |
|
6360 |
fntDescr := FontDescription name:aName. |
|
6361 |
]. |
|
6362 |
fntDescr |
|
6363 |
]. |
|
295 | 6364 |
|
6365 |
]. |
|
6366 |
^ listOfXFonts |
|
6367 |
||
6368 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
6369 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
6370 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
6371 |
Display getAvailableFontsMatching:'*'. |
295 | 6372 |
" |
6373 |
||
6374 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
6375 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 6376 |
! |
6377 |
||
1344 | 6378 |
releaseFont:aFontId |
295 | 6379 |
|
6380 |
%{ /* NOCONTEXT */ |
|
6381 |
||
6382 |
XFontStruct *f; |
|
6383 |
||
1212 | 6384 |
if (! ISCONNECTED) { |
1344 | 6385 |
RETURN ( self ); |
1212 | 6386 |
} |
6387 |
||
6388 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 6389 |
f = _FontVal(aFontId); |
6390 |
if (f) { |
|
6391 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6392 |
ENTER_XLIB(); |
1344 | 6393 |
XFreeFont(myDpy, f); |
1974 | 6394 |
LEAVE_XLIB(); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
6395 |
#ifdef COUNT_RESOURCES |
1344 | 6396 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
6397 |
#endif |
1344 | 6398 |
END_INTERRUPTSBLOCKED |
6399 |
RETURN ( self ); |
|
6400 |
} |
|
295 | 6401 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6402 |
%}. |
295 | 6403 |
self primitiveFailed |
6404 |
! |
|
6405 |
||
1344 | 6406 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 6407 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
6408 |
on this display. |
|
6409 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
6410 |
||
6411 |
|sizes| |
|
6412 |
||
466 | 6413 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 6414 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 6415 |
"special: in X11R5 and above, size 0 means: |
6416 |
there are scaled versions in all sizes available" |
|
6417 |
||
6418 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 6419 |
]. |
6420 |
^ sizes |
|
6421 |
||
6422 |
" |
|
6423 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
6424 |
" |
|
466 | 6425 |
|
6426 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 6427 |
! |
6428 |
||
1344 | 6429 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 6430 |
|
6431 |
%{ /* NOCONTEXT */ |
|
6432 |
||
6433 |
XFontStruct *f; |
|
6434 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6435 |
int len, n, i1, i2, l; |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
6436 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6437 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6438 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6439 |
int nInstBytes; |
295 | 6440 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6441 |
if (ISCONNECTED) { |
1344 | 6442 |
if (__bothSmallInteger(index1, index2) |
6443 |
&& __isExternalAddress(aFontId) |
|
6444 |
&& __isNonNilObject(aString)) { |
|
6445 |
f = _FontVal(aFontId); |
|
6446 |
if (! f) goto fail; |
|
6447 |
||
6448 |
i1 = __intVal(index1) - 1; |
|
6449 |
cls = __qClass(aString); |
|
6450 |
||
6451 |
if (i1 >= 0) { |
|
6452 |
i2 = __intVal(index2) - 1; |
|
6453 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6454 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 6455 |
} |
6456 |
||
1831 | 6457 |
cp = (char *) __stringVal(aString); |
1344 | 6458 |
l = i2 - i1 + 1; |
6459 |
||
6460 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6461 |
n = _stringSize(aString); |
|
6462 |
if (i2 < n) { |
|
6463 |
cp += i1; |
|
6464 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6465 |
ENTER_XLIB(); |
1344 | 6466 |
len = XTextWidth(f, cp, l); |
1974 | 6467 |
LEAVE_XLIB(); |
1344 | 6468 |
END_INTERRUPTSBLOCKED |
6469 |
RETURN ( __MKSMALLINT(len) ); |
|
6470 |
} |
|
6471 |
} |
|
6472 |
||
6473 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6474 |
cp += nInstBytes; |
|
6475 |
||
6476 |
if (__isBytes(aString)) { |
|
6477 |
n = __byteArraySize(aString) - nInstBytes; |
|
6478 |
if (i2 < n) { |
|
6479 |
cp += i1; |
|
6480 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6481 |
ENTER_XLIB(); |
1344 | 6482 |
len = XTextWidth(f, cp, l); |
1974 | 6483 |
LEAVE_XLIB(); |
1344 | 6484 |
END_INTERRUPTSBLOCKED |
6485 |
RETURN ( __MKSMALLINT(len) ); |
|
6486 |
} |
|
6487 |
} |
|
6488 |
||
6489 |
/* TWOBYTESTRINGS */ |
|
6490 |
if (__isWords(aString)) { |
|
6491 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6492 |
||
6493 |
if (i2 < n) { |
|
6494 |
union { |
|
6495 |
char b[2]; |
|
6496 |
unsigned short s; |
|
6497 |
} u; |
|
6498 |
int i; |
|
6499 |
XChar2b *cp2 = (XChar2b *)0; |
|
6500 |
int mustFree = 0; |
|
6501 |
||
6502 |
cp += (i1 * 2); |
|
6503 |
if (l > 1000) l = 1000; |
|
6504 |
||
6505 |
/* |
|
6506 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6507 |
* X expects them MSB first |
|
6508 |
* convert as required |
|
6509 |
*/ |
|
6510 |
||
6511 |
u.s = 0x1234; |
|
6512 |
if (u.b[0] != 0x12) { |
|
6513 |
if (l <= NLOCALBUFFER) { |
|
6514 |
cp2 = xlatebuffer; |
|
6515 |
} else { |
|
6516 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
6517 |
mustFree = 1; |
|
6518 |
} |
|
6519 |
for (i=0; i<l; i++) { |
|
6520 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6521 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6522 |
} |
|
6523 |
cp = (char *) cp2; |
|
6524 |
} |
|
6525 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6526 |
ENTER_XLIB(); |
1344 | 6527 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
1974 | 6528 |
LEAVE_XLIB(); |
1344 | 6529 |
END_INTERRUPTSBLOCKED |
6530 |
||
6531 |
if (mustFree) { |
|
6532 |
free(cp2); |
|
6533 |
} |
|
6534 |
||
6535 |
RETURN ( __MKSMALLINT(len) ); |
|
6536 |
} |
|
6537 |
} |
|
6538 |
} |
|
6539 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6540 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6541 |
#undef NLOCALBUFFER |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
6542 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6543 |
%}. |
295 | 6544 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6545 |
^ 0 |
295 | 6546 |
! |
6547 |
||
1344 | 6548 |
widthOf:aString inFont:aFontId |
295 | 6549 |
|
6550 |
%{ /* NOCONTEXT */ |
|
6551 |
||
6552 |
XFontStruct *f; |
|
6553 |
char *cp; |
|
6554 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
6555 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6556 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6557 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6558 |
int nInstBytes; |
295 | 6559 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6560 |
if (ISCONNECTED) { |
1344 | 6561 |
if (__isExternalAddress(aFontId) |
6562 |
&& __isNonNilObject(aString)) { |
|
6563 |
f = _FontVal(aFontId); |
|
6564 |
if (! f) goto fail; |
|
6565 |
||
6566 |
cls = __qClass(aString); |
|
6567 |
||
1831 | 6568 |
cp = (char *) __stringVal(aString); |
1344 | 6569 |
|
6570 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6571 |
n = _stringSize(aString); |
|
6572 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6573 |
ENTER_XLIB(); |
1344 | 6574 |
len = XTextWidth(f, cp, n); |
1974 | 6575 |
LEAVE_XLIB(); |
1344 | 6576 |
END_INTERRUPTSBLOCKED |
6577 |
RETURN ( __MKSMALLINT(len) ); |
|
6578 |
} |
|
6579 |
||
6580 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6581 |
cp += nInstBytes; |
|
6582 |
||
6583 |
if (__isBytes(aString)) { |
|
6584 |
n = __byteArraySize(aString) - nInstBytes; |
|
6585 |
||
6586 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6587 |
ENTER_XLIB(); |
1344 | 6588 |
len = XTextWidth(f, cp, n); |
1974 | 6589 |
LEAVE_XLIB(); |
1344 | 6590 |
END_INTERRUPTSBLOCKED |
6591 |
RETURN ( __MKSMALLINT(len) ); |
|
6592 |
} |
|
6593 |
||
6594 |
/* TWOBYTESTRINGS */ |
|
6595 |
if (__isWords(aString)) { |
|
6596 |
union { |
|
6597 |
char b[2]; |
|
6598 |
unsigned short s; |
|
6599 |
} u; |
|
6600 |
int i; |
|
6601 |
XChar2b *cp2; |
|
6602 |
int mustFree = 0; |
|
6603 |
||
6604 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6605 |
if (n > 1000) n = 1000; |
|
6606 |
||
6607 |
/* |
|
6608 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6609 |
* X expects them MSB first |
|
6610 |
* convert as required |
|
6611 |
*/ |
|
6612 |
||
6613 |
u.s = 0x1234; |
|
6614 |
if (u.b[0] != 0x12) { |
|
6615 |
if (n <= NLOCALBUFFER) { |
|
6616 |
cp2 = xlatebuffer; |
|
6617 |
} else { |
|
6618 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
6619 |
mustFree = 1; |
|
6620 |
} |
|
6621 |
||
6622 |
for (i=0; i<n; i++) { |
|
6623 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6624 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6625 |
} |
|
6626 |
cp = (char *) cp2; |
|
6627 |
} |
|
6628 |
||
6629 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6630 |
ENTER_XLIB(); |
1344 | 6631 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
1974 | 6632 |
LEAVE_XLIB(); |
1344 | 6633 |
END_INTERRUPTSBLOCKED |
6634 |
||
6635 |
if (mustFree) { |
|
6636 |
free(cp2); |
|
6637 |
} |
|
6638 |
||
6639 |
RETURN ( __MKSMALLINT(len) ); |
|
6640 |
} |
|
6641 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6642 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6643 |
#undef NLOCALBUFFER |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
6644 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6645 |
%}. |
295 | 6646 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6647 |
^ 0 |
295 | 6648 |
! ! |
6649 |
||
6650 |
!XWorkstation methodsFor:'grabbing '! |
|
6651 |
||
1344 | 6652 |
allowEvents:mode |
295 | 6653 |
%{ /* NOCONTEXT */ |
6654 |
||
6655 |
int _mode, ok = 1; |
|
6656 |
||
6657 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 6658 |
_mode = AsyncPointer; |
295 | 6659 |
else if (mode == @symbol(syncPointer)) |
1344 | 6660 |
_mode = SyncPointer; |
295 | 6661 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 6662 |
_mode = AsyncKeyboard; |
295 | 6663 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 6664 |
_mode = SyncKeyboard; |
295 | 6665 |
else if (mode == @symbol(syncBoth)) |
1344 | 6666 |
_mode = SyncBoth; |
295 | 6667 |
else if (mode == @symbol(asyncBoth)) |
1344 | 6668 |
_mode = AsyncBoth; |
295 | 6669 |
else if (mode == @symbol(replayPointer)) |
1344 | 6670 |
_mode = ReplayPointer; |
295 | 6671 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 6672 |
_mode = ReplayKeyboard; |
295 | 6673 |
else |
1344 | 6674 |
ok = 0; |
295 | 6675 |
|
6676 |
if (ok) { |
|
1344 | 6677 |
if (ISCONNECTED) { |
6678 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6679 |
ENTER_XLIB(); |
1344 | 6680 |
XAllowEvents(myDpy, _mode, CurrentTime); |
1974 | 6681 |
LEAVE_XLIB(); |
1344 | 6682 |
END_INTERRUPTSBLOCKED |
6683 |
RETURN (self); |
|
6684 |
} |
|
295 | 6685 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6686 |
%}. |
295 | 6687 |
self primitiveFailed |
6688 |
! |
|
6689 |
||
1344 | 6690 |
grabKeyboardIn:aWindowId |
295 | 6691 |
"grab the keyboard" |
6692 |
||
6693 |
%{ /* NOCONTEXT */ |
|
6694 |
int result, ok; |
|
6695 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6696 |
if (ISCONNECTED) { |
1344 | 6697 |
if (__isExternalAddress(aWindowId)) { |
6698 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6699 |
ENTER_XLIB(); |
1344 | 6700 |
result = XGrabKeyboard(myDpy, |
6701 |
_WindowVal(aWindowId), |
|
6702 |
True /* False */, |
|
6703 |
GrabModeAsync, |
|
6704 |
GrabModeAsync, |
|
6705 |
CurrentTime); |
|
1974 | 6706 |
LEAVE_XLIB(); |
1344 | 6707 |
END_INTERRUPTSBLOCKED |
6708 |
ok = 0; |
|
6709 |
switch(result) { |
|
6710 |
case AlreadyGrabbed: |
|
6711 |
if (@global(ErrorPrinting) == true) { |
|
6712 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
6713 |
} |
|
6714 |
break; |
|
6715 |
case GrabNotViewable: |
|
6716 |
if (@global(ErrorPrinting) == true) { |
|
6717 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
6718 |
} |
|
6719 |
break; |
|
6720 |
case GrabInvalidTime: |
|
6721 |
if (@global(ErrorPrinting) == true) { |
|
6722 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
6723 |
} |
|
6724 |
break; |
|
6725 |
case GrabFrozen: |
|
6726 |
if (@global(ErrorPrinting) == true) { |
|
6727 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
6728 |
} |
|
6729 |
break; |
|
6730 |
default: |
|
6731 |
ok = 1; |
|
6732 |
break; |
|
6733 |
} |
|
6734 |
if (! ok) { |
|
1974 | 6735 |
ENTER_XLIB(); |
1344 | 6736 |
XUngrabKeyboard(myDpy, CurrentTime); |
1974 | 6737 |
LEAVE_XLIB(); |
1344 | 6738 |
RETURN (false); |
6739 |
} |
|
6740 |
||
6741 |
RETURN ( true ); |
|
6742 |
} |
|
295 | 6743 |
} |
1183 | 6744 |
%}. |
295 | 6745 |
self primitiveFailed |
6746 |
! |
|
6747 |
||
1344 | 6748 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 6749 |
"grap the pointer - return true if ok" |
6750 |
||
6751 |
%{ /* NOCONTEXT */ |
|
6752 |
||
6753 |
int result, ok; |
|
6754 |
Window confineWin; |
|
6755 |
Cursor curs; |
|
6756 |
int pointer_mode, keyboard_mode; |
|
6757 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6758 |
if (ISCONNECTED) { |
1344 | 6759 |
if (__isExternalAddress(aWindowId)) { |
6760 |
if (__isExternalAddress(confineId)) |
|
6761 |
confineWin = _WindowVal(confineId); |
|
6762 |
else |
|
6763 |
confineWin = (Window) None; |
|
6764 |
||
6765 |
if (__isExternalAddress(aCursorId)) |
|
6766 |
curs = _CursorVal(aCursorId); |
|
6767 |
else |
|
6768 |
curs = (Cursor) None; |
|
6769 |
||
6770 |
if (pMode == @symbol(sync)) |
|
6771 |
pointer_mode = GrabModeSync; |
|
6772 |
else |
|
6773 |
pointer_mode = GrabModeAsync; |
|
6774 |
||
6775 |
if (kMode == @symbol(sync)) |
|
6776 |
keyboard_mode = GrabModeSync; |
|
6777 |
else |
|
6778 |
keyboard_mode = GrabModeAsync; |
|
6779 |
||
6780 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 6781 |
ENTER_XLIB(); |
1344 | 6782 |
result = XGrabPointer(myDpy, |
6783 |
_WindowVal(aWindowId), |
|
6784 |
False, |
|
6785 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
6786 |
pointer_mode, keyboard_mode, |
|
6787 |
confineWin, |
|
6788 |
curs, |
|
6789 |
CurrentTime); |
|
1974 | 6790 |
LEAVE_XLIB(); |
1344 | 6791 |
END_INTERRUPTSBLOCKED |
6792 |
||
6793 |
ok = 0; |
|
6794 |
switch (result) { |
|
6795 |
case AlreadyGrabbed: |
|
6796 |
if (@global(ErrorPrinting) == true) { |
|
6797 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
6798 |
} |
|
6799 |
break; |
|
6800 |
case GrabNotViewable: |
|
6801 |
if (@global(ErrorPrinting) == true) { |
|
6802 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
6803 |
} |
|
6804 |
break; |
|
6805 |
case GrabInvalidTime: |
|
6806 |
if (@global(ErrorPrinting) == true) { |
|
6807 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
6808 |
} |
|
6809 |
break; |
|
6810 |
case GrabFrozen: |
|
6811 |
if (@global(ErrorPrinting) == true) { |
|
6812 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
6813 |
} |
|
6814 |
break; |
|
6815 |
default: |
|
6816 |
ok = 1; |
|
6817 |
break; |
|
6818 |
} |
|
6819 |
||
6820 |
if (! ok) { |
|
1974 | 6821 |
ENTER_XLIB(); |
1344 | 6822 |
XUngrabPointer(myDpy, CurrentTime); |
1974 | 6823 |
LEAVE_XLIB(); |
1344 | 6824 |
RETURN (false); |
6825 |
} |
|
6826 |
RETURN ( true ); |
|
6827 |
} |
|
295 | 6828 |
} |
1183 | 6829 |
%}. |
295 | 6830 |
self primitiveFailed |
6831 |
! |
|
6832 |
||
1344 | 6833 |
ungrabKeyboard |
295 | 6834 |
"release the keyboard" |
6835 |
||
6836 |
%{ /* NOCONTEXT */ |
|
6837 |
||
6838 |
if (ISCONNECTED) { |
|
1344 | 6839 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 6840 |
ENTER_XLIB(); |
1344 | 6841 |
XUngrabKeyboard(myDpy, CurrentTime); |
6842 |
XSync(myDpy, 0); |
|
1974 | 6843 |
LEAVE_XLIB(); |
1344 | 6844 |
END_INTERRUPTSBLOCKED |
295 | 6845 |
} |
6846 |
%}. |
|
6847 |
activeKeyboardGrab := nil |
|
6848 |
! |
|
6849 |
||
1344 | 6850 |
ungrabPointer |
295 | 6851 |
"release the pointer" |
6852 |
||
6853 |
%{ /* NOCONTEXT */ |
|
6854 |
||
6855 |
if (ISCONNECTED) { |
|
1344 | 6856 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 6857 |
ENTER_XLIB(); |
1344 | 6858 |
XUngrabPointer(myDpy, CurrentTime); |
6859 |
XSync(myDpy, 0); |
|
1974 | 6860 |
LEAVE_XLIB(); |
1344 | 6861 |
END_INTERRUPTSBLOCKED |
295 | 6862 |
} |
6863 |
%}. |
|
6864 |
activePointerGrab := nil |
|
6865 |
! ! |
|
6866 |
||
6867 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
6868 |
||
1709
342fc0eb3517
pass drawableId to clip methods (req'd for Windows)
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
6869 |
noClipIn:aDrawableId gc:aGCId |
295 | 6870 |
"disable clipping rectangle" |
6871 |
||
6872 |
%{ /* NOCONTEXT */ |
|
6873 |
||
6874 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6875 |
GC gc; |
295 | 6876 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6877 |
if (ISCONNECTED) { |
1344 | 6878 |
if (__isExternalAddress(aGCId)) { |
6879 |
gc = _GCVal(aGCId); |
|
6880 |
gcv.clip_mask = None; |
|
1974 | 6881 |
ENTER_XLIB(); |
1344 | 6882 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
1974 | 6883 |
LEAVE_XLIB(); |
1344 | 6884 |
RETURN ( self ); |
6885 |
} |
|
295 | 6886 |
} |
6887 |
%}. |
|
6888 |
self primitiveFailed |
|
6889 |
! |
|
6890 |
||
1344 | 6891 |
setBackground:bgColorIndex in:aGCId |
295 | 6892 |
"set background color to be drawn with" |
6893 |
||
6894 |
%{ /* NOCONTEXT */ |
|
6895 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6896 |
if (ISCONNECTED) { |
1344 | 6897 |
if (__isExternalAddress(aGCId) |
6898 |
&& __isSmallInteger(bgColorIndex)) { |
|
1974 | 6899 |
ENTER_XLIB(); |
1344 | 6900 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
1974 | 6901 |
LEAVE_XLIB(); |
1344 | 6902 |
RETURN ( self ); |
6903 |
} |
|
295 | 6904 |
} |
6905 |
%}. |
|
6906 |
self primitiveFailed |
|
6907 |
! |
|
6908 |
||
1344 | 6909 |
setBitmapMask:aBitmapId in:aGCId |
295 | 6910 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
6911 |
||
6912 |
%{ /* NOCONTEXT */ |
|
6913 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6914 |
GC gc; |
295 | 6915 |
Pixmap bitmap; |
6916 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6917 |
if (ISCONNECTED) { |
1344 | 6918 |
Display *dpy = myDpy; |
6919 |
||
6920 |
if (__isExternalAddress(aGCId)) { |
|
6921 |
gc = _GCVal(aGCId); |
|
6922 |
if (__isExternalAddress(aBitmapId)) { |
|
6923 |
bitmap = _PixmapVal(aBitmapId); |
|
1974 | 6924 |
ENTER_XLIB(); |
1344 | 6925 |
XSetStipple(dpy, gc, bitmap); |
6926 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
1974 | 6927 |
LEAVE_XLIB(); |
1344 | 6928 |
RETURN ( self ); |
6929 |
} |
|
6930 |
if (aBitmapId == nil) { |
|
1974 | 6931 |
ENTER_XLIB(); |
1344 | 6932 |
XSetFillStyle(dpy, gc, FillSolid); |
1974 | 6933 |
LEAVE_XLIB(); |
1344 | 6934 |
RETURN ( self ); |
6935 |
} |
|
6936 |
} |
|
295 | 6937 |
} |
6938 |
%}. |
|
6939 |
self primitiveFailed |
|
6940 |
! |
|
6941 |
||
1681
069ede63fb19
pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents:
1627
diff
changeset
|
6942 |
setClipByChildren:aBool in:aDrawableId gc:aGCId |
295 | 6943 |
"enable/disable drawing into child views" |
6944 |
||
6945 |
%{ /* NOCONTEXT */ |
|
6946 |
||
6947 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6948 |
GC gc; |
295 | 6949 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6950 |
if (ISCONNECTED) { |
1694 | 6951 |
if (__isExternalAddress(aGCId)) { |
6952 |
gc = _GCVal(aGCId); |
|
6953 |
if (aBool == true) |
|
6954 |
gcv.subwindow_mode = ClipByChildren; |
|
6955 |
else |
|
6956 |
gcv.subwindow_mode = IncludeInferiors; |
|
6957 |
||
1974 | 6958 |
ENTER_XLIB(); |
1694 | 6959 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
1974 | 6960 |
LEAVE_XLIB(); |
1694 | 6961 |
RETURN ( self ); |
6962 |
} |
|
295 | 6963 |
} |
6964 |
%}. |
|
6965 |
self primitiveFailed |
|
6966 |
! |
|
6967 |
||
1709
342fc0eb3517
pass drawableId to clip methods (req'd for Windows)
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
6968 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:drawableId gc:aGCId |
295 | 6969 |
"clip to a rectangle" |
6970 |
||
6971 |
%{ /* NOCONTEXT */ |
|
6972 |
||
6973 |
XRectangle r; |
|
6974 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6975 |
if (ISCONNECTED) { |
1344 | 6976 |
if (__isExternalAddress(aGCId) |
6977 |
&& __bothSmallInteger(clipX, clipY) |
|
6978 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
6979 |
r.x = __intVal(clipX); |
|
6980 |
r.y = __intVal(clipY); |
|
6981 |
r.width = __intVal(clipWidth); |
|
6982 |
r.height = __intVal(clipHeight); |
|
1974 | 6983 |
ENTER_XLIB(); |
1344 | 6984 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
1974 | 6985 |
LEAVE_XLIB(); |
1344 | 6986 |
RETURN ( self ); |
6987 |
} |
|
295 | 6988 |
} |
6989 |
%}. |
|
6990 |
self primitiveFailed |
|
6991 |
! |
|
6992 |
||
1344 | 6993 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 6994 |
"set line attributes" |
6995 |
||
6996 |
%{ /* NOCONTEXT */ |
|
6997 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6998 |
if (ISCONNECTED) { |
1344 | 6999 |
if (__isExternalAddress(aGCId) |
7000 |
&& __isSmallInteger(offset) |
|
7001 |
&& __isByteArray(dashList)) { |
|
1974 | 7002 |
ENTER_XLIB(); |
1344 | 7003 |
XSetDashes(myDpy, _GCVal(aGCId), |
7004 |
__intVal(offset), |
|
7005 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
7006 |
__byteArraySize(dashList)); |
|
1974 | 7007 |
LEAVE_XLIB(); |
1344 | 7008 |
RETURN ( self ); |
7009 |
} |
|
788 | 7010 |
} |
7011 |
bad: ; |
|
7012 |
%}. |
|
7013 |
" |
|
7014 |
either aGCId is invalid, |
|
7015 |
and/or dashList is not a byteArray |
|
7016 |
and/or offset is not a smallInteger |
|
7017 |
" |
|
7018 |
self primitiveFailed |
|
7019 |
! |
|
7020 |
||
1344 | 7021 |
setFont:aFontId in:aGCId |
295 | 7022 |
"set font to be drawn in" |
7023 |
||
7024 |
%{ /* NOCONTEXT */ |
|
7025 |
||
7026 |
XFontStruct *f; |
|
7027 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7028 |
if (ISCONNECTED) { |
1344 | 7029 |
if (__isExternalAddress(aFontId) |
7030 |
&& __isExternalAddress(aGCId)) { |
|
7031 |
f = (XFontStruct *) _FontVal(aFontId); |
|
1974 | 7032 |
ENTER_XLIB(); |
1344 | 7033 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
1974 | 7034 |
LEAVE_XLIB(); |
1344 | 7035 |
RETURN ( self ); |
7036 |
} |
|
295 | 7037 |
} |
7038 |
%}. |
|
7039 |
" |
|
7040 |
aGCId and/or aFontId are invalid |
|
7041 |
" |
|
7042 |
self primitiveFailed |
|
7043 |
! |
|
7044 |
||
1344 | 7045 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 7046 |
"set foreground and background colors to be drawn with" |
7047 |
||
7048 |
%{ /* NOCONTEXT */ |
|
7049 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7050 |
GC gc; |
295 | 7051 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7052 |
if (ISCONNECTED) { |
1344 | 7053 |
Display *dpy = myDpy; |
7054 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
7055 |
&& __isExternalAddress(aGCId)) { |
|
7056 |
gc = _GCVal(aGCId); |
|
7057 |
||
1974 | 7058 |
ENTER_XLIB(); |
1344 | 7059 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
7060 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
1974 | 7061 |
LEAVE_XLIB(); |
1344 | 7062 |
RETURN ( self ); |
7063 |
} |
|
295 | 7064 |
} |
7065 |
%}. |
|
7066 |
self primitiveFailed |
|
7067 |
! |
|
7068 |
||
1344 | 7069 |
setForeground:fgColorIndex in:aGCId |
295 | 7070 |
"set foreground color to be drawn with" |
7071 |
||
7072 |
%{ /* NOCONTEXT */ |
|
7073 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7074 |
if (ISCONNECTED) { |
1344 | 7075 |
if (__isExternalAddress(aGCId) |
7076 |
&& __isSmallInteger(fgColorIndex)) { |
|
1974 | 7077 |
ENTER_XLIB(); |
1344 | 7078 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
1974 | 7079 |
LEAVE_XLIB(); |
1344 | 7080 |
RETURN ( self ); |
7081 |
} |
|
295 | 7082 |
} |
7083 |
%}. |
|
7084 |
self primitiveFailed |
|
7085 |
! |
|
7086 |
||
1344 | 7087 |
setFunction:aFunctionSymbol in:aGCId |
295 | 7088 |
"set alu function to be drawn with" |
7089 |
||
7090 |
%{ /* NOCONTEXT */ |
|
7091 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7092 |
GC gc; |
295 | 7093 |
int fun = -1; |
7094 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7095 |
if (ISCONNECTED) { |
1344 | 7096 |
if (__isExternalAddress(aGCId)) { |
7097 |
gc = _GCVal(aGCId); |
|
7098 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
7099 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
7100 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
7101 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
7102 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
7103 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
7104 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
7105 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
7106 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
7107 |
if (fun != -1) { |
|
1974 | 7108 |
ENTER_XLIB(); |
1344 | 7109 |
XSetFunction(myDpy, gc, fun); |
1974 | 7110 |
LEAVE_XLIB(); |
1344 | 7111 |
RETURN ( self ); |
7112 |
} |
|
7113 |
} |
|
295 | 7114 |
} |
7115 |
%}. |
|
7116 |
" |
|
7117 |
either aGCId is not an integer, or an invalid symbol |
|
7118 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
7119 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
7120 |
" |
|
7121 |
self primitiveFailed |
|
7122 |
! |
|
7123 |
||
1344 | 7124 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 7125 |
"set or clear the graphics exposures flag" |
7126 |
||
7127 |
%{ /* NOCONTEXT */ |
|
7128 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7129 |
if (ISCONNECTED) { |
1344 | 7130 |
if (__isExternalAddress(aGCId)) { |
1974 | 7131 |
ENTER_XLIB(); |
1344 | 7132 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
1974 | 7133 |
LEAVE_XLIB(); |
1344 | 7134 |
RETURN ( self ); |
7135 |
} |
|
295 | 7136 |
} |
7137 |
%} |
|
7138 |
. |
|
7139 |
self primitiveFailed |
|
7140 |
! |
|
7141 |
||
1344 | 7142 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
1455 | 7143 |
"set line attributes; |
7144 |
lineStyle must be one of #solid, #dashed or #doubleDashed; |
|
7145 |
capStyle one of: #notLast, #butt, #round or #projecting; |
|
7146 |
joinStyle one of: #miter, #bevel or #round." |
|
295 | 7147 |
|
7148 |
%{ /* NOCONTEXT */ |
|
7149 |
||
7150 |
int x_style, x_cap, x_join; |
|
7151 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7152 |
if (ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7153 |
if (__isExternalAddress(aGCId) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7154 |
&& __isSmallInteger(aNumber)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7155 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7156 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7157 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7158 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7159 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7160 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7161 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7162 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7163 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7164 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7165 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7166 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7167 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7168 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7169 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7170 |
|
1974 | 7171 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7172 |
XSetLineAttributes(myDpy, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7173 |
_GCVal(aGCId), __intVal(aNumber), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7174 |
x_style, x_cap, x_join); |
1974 | 7175 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7176 |
RETURN ( self ); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7177 |
} |
295 | 7178 |
} |
7179 |
bad: ; |
|
7180 |
%}. |
|
7181 |
" |
|
7182 |
either aGCId is invalid, |
|
1455 | 7183 |
and/or lineWidth is not a smallInteger, |
295 | 7184 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
7185 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
7186 |
and/or joinStyle is none of #miter, #bevel, #round |
|
7187 |
" |
|
7188 |
self primitiveFailed |
|
7189 |
! |
|
7190 |
||
1344 | 7191 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 7192 |
"set the mask origin" |
7193 |
||
7194 |
%{ /* NOCONTEXT */ |
|
7195 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7196 |
if (ISCONNECTED) { |
1344 | 7197 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
1974 | 7198 |
ENTER_XLIB(); |
1344 | 7199 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
1974 | 7200 |
LEAVE_XLIB(); |
1344 | 7201 |
RETURN ( self ); |
7202 |
} |
|
295 | 7203 |
} |
7204 |
%}. |
|
7205 |
self primitiveFailed |
|
7206 |
! |
|
7207 |
||
1344 | 7208 |
setPixmapMask:aPixmapId in:aGCId |
295 | 7209 |
"set or clear the drawing mask - a pixmap mask providing full color" |
7210 |
||
7211 |
%{ /* NOCONTEXT */ |
|
7212 |
||
7213 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7214 |
GC gc; |
295 | 7215 |
Pixmap pixmap; |
7216 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7217 |
if (ISCONNECTED) { |
1344 | 7218 |
if (__isExternalAddress(aGCId)) { |
7219 |
gc = _GCVal(aGCId); |
|
7220 |
if (__isExternalAddress(aPixmapId)) { |
|
7221 |
pixmap = _PixmapVal(aPixmapId); |
|
1974 | 7222 |
ENTER_XLIB(); |
1344 | 7223 |
XSetTile(dpy, gc, pixmap); |
7224 |
XSetFillStyle(dpy, gc, FillTiled); |
|
1974 | 7225 |
LEAVE_XLIB(); |
1344 | 7226 |
RETURN ( self ); |
7227 |
} |
|
7228 |
if (aPixmapId == nil) { |
|
1974 | 7229 |
ENTER_XLIB(); |
1344 | 7230 |
XSetFillStyle(dpy, gc, FillSolid); |
1974 | 7231 |
LEAVE_XLIB(); |
1344 | 7232 |
RETURN ( self ); |
7233 |
} |
|
7234 |
} |
|
295 | 7235 |
} |
7236 |
%}. |
|
7237 |
self primitiveFailed |
|
7238 |
! ! |
|
7239 |
||
7240 |
!XWorkstation methodsFor:'initialize / release'! |
|
7241 |
||
1344 | 7242 |
closeConnection |
295 | 7243 |
"close down the connection to the X-server" |
7244 |
||
7245 |
%{ /* NOCONTEXT */ |
|
7246 |
||
7247 |
if (ISCONNECTED) { |
|
1344 | 7248 |
Display *dpy = myDpy; |
7249 |
||
7250 |
BEGIN_INTERRUPTSBLOCKED |
|
7251 |
__INST(displayId) = nil; |
|
1974 | 7252 |
ENTER_XLIB(); |
1344 | 7253 |
XCloseDisplay(dpy); |
1974 | 7254 |
LEAVE_XLIB(); |
1344 | 7255 |
END_INTERRUPTSBLOCKED |
295 | 7256 |
} |
7257 |
%} |
|
7258 |
! |
|
7259 |
||
1344 | 7260 |
initializeDefaultValues |
295 | 7261 |
buttonTranslation := ButtonTranslation. |
7262 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
7263 |
||
7264 |
self initializeModifierMappings |
|
7265 |
! |
|
7266 |
||
1344 | 7267 |
initializeEventBuffer |
295 | 7268 |
|sz| |
7269 |
||
7270 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
7271 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 7272 |
%}. |
7273 |
eventBuffer isNil ifTrue:[ |
|
1344 | 7274 |
eventBuffer := ByteArray new:sz. |
295 | 7275 |
]. |
7276 |
! |
|
7277 |
||
1344 | 7278 |
initializeFor:aDisplayName |
295 | 7279 |
"initialize the receiver for a connection to an X-Server; |
7280 |
the argument, aDisplayName may be nil (for the default server from |
|
7281 |
DISPLAY-variable or command line argument) or the name of the server |
|
7282 |
as hostname:number" |
|
7283 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
7284 |
|dpyName index arguments| |
295 | 7285 |
|
7286 |
dpyName := aDisplayName. |
|
7287 |
dpyName isNil ifTrue:[ |
|
1344 | 7288 |
"look for a '-display xxx' argument" |
7289 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
7290 |
index := arguments indexOf:'-display'. |
|
7291 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
7292 |
dpyName := arguments at:index+1 |
|
7293 |
] |
|
7294 |
] |
|
295 | 7295 |
]. |
7296 |
%{ |
|
7297 |
int scr; |
|
7298 |
Display *dpy; |
|
7299 |
Visual *visual; |
|
7300 |
XVisualInfo viproto; |
|
7301 |
XVisualInfo *vip; /* retured info */ |
|
7302 |
int maxRGBDepth; |
|
7303 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
7304 |
int rgbVisualID; |
|
7305 |
int nvi, i; |
|
7306 |
char *type, *nm; |
|
7307 |
int dummy; |
|
7308 |
OBJ dpyID; |
|
7309 |
||
555 | 7310 |
if (__INST(displayId) != nil) { |
1344 | 7311 |
/* |
7312 |
* already connected - you bad guy try to |
|
7313 |
* trick me manually ? |
|
7314 |
*/ |
|
7315 |
RETURN ( self ); |
|
295 | 7316 |
} |
7317 |
||
7318 |
BEGIN_INTERRUPTSBLOCKED |
|
7319 |
||
7320 |
if (__isString(dpyName)) |
|
1831 | 7321 |
nm = (char *) __stringVal(dpyName); |
295 | 7322 |
else { |
1344 | 7323 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
7324 |
nm = NULL; |
|
295 | 7325 |
} |
7326 |
dpy = XOpenDisplay(nm); |
|
7327 |
||
7328 |
if (dpy) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7329 |
static int firstCall = 1; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7330 |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
7331 |
__INST(displayId) = dpyID = __MKEXTERNALADDRESS(dpy); __STORE(self, dpyID); |
295 | 7332 |
|
7333 |
#ifdef SUPERDEBUG |
|
1344 | 7334 |
XSynchronize(dpy, 1); |
295 | 7335 |
#endif |
7336 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7337 |
if (firstCall) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7338 |
firstCall = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7339 |
XSetErrorHandler(__XErrorHandler__); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7340 |
XSetIOErrorHandler(__XIOErrorHandler__); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7341 |
} |
295 | 7342 |
} |
7343 |
||
7344 |
END_INTERRUPTSBLOCKED |
|
7345 |
%}. |
|
7346 |
displayId isNil ifTrue:[ |
|
1344 | 7347 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
7348 |
^ nil |
|
295 | 7349 |
]. |
7350 |
||
7351 |
dispatching := false. |
|
7352 |
dispatchingExpose := false. |
|
7353 |
isSlow := false. |
|
7354 |
shiftDown := false. |
|
7355 |
ctrlDown := false. |
|
7356 |
metaDown := false. |
|
7357 |
altDown := false. |
|
7358 |
motionEventCompression := true. |
|
7359 |
buttonsPressed := 0. |
|
7360 |
displayName := dpyName. |
|
7361 |
||
7362 |
protocolsAtom := nil. |
|
7363 |
deleteWindowAtom := nil. |
|
7364 |
saveYourselfAtom := nil. |
|
7365 |
quitAppAtom := nil. |
|
7366 |
||
7367 |
self initializeScreenProperties. |
|
1366 | 7368 |
self initializeDeviceResourceTables. |
295 | 7369 |
|
7370 |
self initializeDefaultValues. |
|
7371 |
self initializeEventBuffer. |
|
7372 |
self initializeSpecialFlags. |
|
7373 |
self initializeKeyboardMap. |
|
7374 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7375 |
deviceErrorSignal := DeviceErrorSignal newSignalMayProceed:false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7376 |
deviceErrorSignal nameClass:self class message:#deviceErrorSignal. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7377 |
deviceIOErrorSignal := DeviceIOErrorSignal newSignalMayProceed:false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7378 |
deviceIOErrorSignal nameClass:self class message:#deviceIOErrorSignal. |
1974 | 7379 |
deviceIOTimeoutErrorSignal := deviceIOErrorSignal newSignalMayProceed:false. |
7380 |
deviceIOTimeoutErrorSignal nameClass:self class message:#deviceIOTimeoutErrorSignal. |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7381 |
|
295 | 7382 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7383 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayIOError. |
1974 | 7384 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayIOTimeoutError. |
295 | 7385 |
! |
7386 |
||
1344 | 7387 |
initializeModifierMappings |
295 | 7388 |
|map mod| |
7389 |
||
7390 |
"/ altModifiers := #(Alt_L Alt_R). |
|
7391 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
7392 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
7393 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
7394 |
||
7395 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
7396 |
altModifierMask := metaModifierMask := nil. |
|
7397 |
||
7398 |
map := self modifierMapping. |
|
342 | 7399 |
map isNil ifTrue:[ |
1344 | 7400 |
"/ |
7401 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
7402 |
"/ setup some reasonable default. If that is not sufficient, |
|
7403 |
"/ you have to change things from your display.rc file. |
|
7404 |
"/ |
|
7405 |
altModifierMask := self modifier1Mask. |
|
7406 |
metaModifierMask := self modifier2Mask. |
|
7407 |
||
7408 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
7409 |
ctrlModifiers := #(Control_L Control_R Control). |
|
7410 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
7411 |
altModifiers := #(Alt_R Alt). |
|
342 | 7412 |
] ifFalse:[ |
1344 | 7413 |
altModifierMask := 0. |
7414 |
metaModifierMask := 0. |
|
7415 |
||
7416 |
mod := map at:1. |
|
7417 |
mod notNil ifTrue:[ |
|
7418 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
7419 |
]. |
|
7420 |
mod := map at:3. |
|
7421 |
mod notNil ifTrue:[ |
|
7422 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
7423 |
]. |
|
7424 |
mod := map at:4. |
|
7425 |
mod notNil ifTrue:[ |
|
7426 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
7427 |
metaModifierMask := 1 bitShift:(4-1). |
|
7428 |
]. |
|
7429 |
mod := map at:5. |
|
7430 |
mod notNil ifTrue:[ |
|
7431 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
7432 |
altModifierMask := 1 bitShift:(5-1). |
|
7433 |
] |
|
295 | 7434 |
]. |
7435 |
||
7436 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
7437 |
! |
|
7438 |
||
1344 | 7439 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7440 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7441 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
7442 |
%{ |
295 | 7443 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7444 |
Display *dpy; |
295 | 7445 |
int scr; |
7446 |
Visual *visual; |
|
7447 |
XVisualInfo viproto; |
|
7448 |
XVisualInfo *vip; /* retured info */ |
|
7449 |
int maxRGBDepth; |
|
7450 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
7451 |
int rgbVisualID; |
|
7452 |
int nvi, i; |
|
7453 |
int shapeEventBase, shapeErrorBase; |
|
7454 |
int shmEventBase, shmErrorBase; |
|
7455 |
char *type, *nm; |
|
7456 |
int dummy; |
|
7457 |
int mask, shift, nBits; |
|
7458 |
||
7459 |
if (ISCONNECTED) { |
|
1344 | 7460 |
dpy = myDpy; |
7461 |
||
7462 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
7463 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
7464 |
||
7465 |
BEGIN_INTERRUPTSBLOCKED |
|
7466 |
||
7467 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
7468 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
7469 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
7470 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
7471 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
7472 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
7473 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
7474 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
7475 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 7476 |
|
7477 |
#ifdef SHAPE |
|
1344 | 7478 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
7479 |
__INST(hasShapeExtension) = true; |
|
7480 |
else |
|
295 | 7481 |
#endif |
1344 | 7482 |
__INST(hasShapeExtension) = false; |
295 | 7483 |
|
7484 |
#ifdef SHM |
|
1344 | 7485 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
7486 |
__INST(hasShmExtension) = true; |
|
7487 |
else |
|
295 | 7488 |
#endif |
1344 | 7489 |
__INST(hasShmExtension) = false; |
295 | 7490 |
|
7491 |
#ifdef DPS |
|
1344 | 7492 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
7493 |
__INST(hasDPSExtension) = true; |
|
7494 |
else |
|
295 | 7495 |
#endif |
1344 | 7496 |
__INST(hasDPSExtension) = false; |
295 | 7497 |
|
7498 |
#ifdef XVIDEO |
|
1344 | 7499 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
7500 |
__INST(hasXVideoExtension) = true; |
|
7501 |
else |
|
295 | 7502 |
#endif |
1344 | 7503 |
__INST(hasXVideoExtension) = false; |
295 | 7504 |
|
7505 |
#ifdef MBUF |
|
1344 | 7506 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
7507 |
__INST(hasMbufExtension) = true; |
|
7508 |
else |
|
295 | 7509 |
#endif |
1344 | 7510 |
__INST(hasMbufExtension) = false; |
295 | 7511 |
|
7512 |
#ifdef PEX5 |
|
1344 | 7513 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
7514 |
__INST(hasPEXExtension) = true; |
|
7515 |
else |
|
295 | 7516 |
#endif |
1344 | 7517 |
__INST(hasPEXExtension) = false; |
295 | 7518 |
|
7519 |
#ifdef XIE |
|
1344 | 7520 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
7521 |
__INST(hasImageExtension) = true; |
|
7522 |
else |
|
295 | 7523 |
#endif |
1344 | 7524 |
__INST(hasImageExtension) = false; |
295 | 7525 |
|
7526 |
#ifdef XI |
|
1344 | 7527 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
7528 |
__INST(hasInputExtension) = true; |
|
7529 |
else |
|
295 | 7530 |
#endif |
1344 | 7531 |
__INST(hasInputExtension) = false; |
7532 |
||
7533 |
/* |
|
7534 |
* look for RGB visual |
|
7535 |
*/ |
|
7536 |
nvi = 0; |
|
7537 |
viproto.screen = scr; |
|
7538 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
7539 |
maxRGBDepth = 0; |
|
7540 |
for (i = 0; i < nvi; i++) { |
|
7541 |
switch (vip[i].class) { |
|
7542 |
case TrueColor: |
|
7543 |
if (vip[i].depth > maxRGBDepth) { |
|
7544 |
maxRGBDepth = vip[i].depth; |
|
7545 |
rgbRedMask = vip[i].red_mask; |
|
7546 |
rgbGreenMask = vip[i].green_mask; |
|
7547 |
rgbBlueMask = vip[i].blue_mask; |
|
7548 |
rgbVisualID = vip[i].visualid; |
|
7549 |
} |
|
7550 |
break; |
|
7551 |
} |
|
7552 |
} |
|
7553 |
if (vip) XFree ((char *) vip); |
|
7554 |
||
7555 |
if (maxRGBDepth) { |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
7556 |
__INST(rgbVisual) = __MKEXTERNALADDRESS(rgbVisualID); __STORESELF(rgbVisual); |
1344 | 7557 |
} |
7558 |
||
7559 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
7560 |
__INST(monitorType) = @symbol(unknown); |
|
7561 |
__INST(hasColors) = true; |
|
7562 |
__INST(hasGreyscales) = true; |
|
7563 |
switch (visual->class) { |
|
7564 |
case StaticGray: |
|
7565 |
__INST(visualType) = @symbol(StaticGray); |
|
7566 |
__INST(hasColors) = false; |
|
7567 |
__INST(monitorType) = @symbol(monochrome); |
|
7568 |
break; |
|
7569 |
case GrayScale: |
|
7570 |
__INST(visualType) = @symbol(GrayScale); |
|
7571 |
__INST(hasColors) = false; |
|
7572 |
__INST(monitorType) = @symbol(monochrome); |
|
7573 |
break; |
|
7574 |
case StaticColor: |
|
7575 |
__INST(visualType) = @symbol(StaticColor); |
|
7576 |
break; |
|
7577 |
case PseudoColor: |
|
7578 |
__INST(visualType) = @symbol(PseudoColor); |
|
7579 |
break; |
|
7580 |
case TrueColor: |
|
7581 |
__INST(visualType) = @symbol(TrueColor); |
|
7582 |
break; |
|
7583 |
case DirectColor: |
|
7584 |
__INST(visualType) = @symbol(DirectColor); |
|
7585 |
break; |
|
7586 |
} |
|
7587 |
if (DisplayCells(dpy, scr) == 2) { |
|
7588 |
__INST(hasColors) = false; |
|
7589 |
__INST(hasGreyscales) = false; |
|
7590 |
__INST(monitorType) = @symbol(monochrome); |
|
7591 |
} |
|
7592 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
7593 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
7594 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
7595 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
7596 |
switch (visual->class) { |
|
7597 |
case TrueColor: |
|
7598 |
/* extract number of bits and shift counts */ |
|
7599 |
mask = visual->red_mask; |
|
7600 |
shift = 0; |
|
7601 |
while (mask && ((mask & 1) == 0)) { |
|
7602 |
mask >>= 1; |
|
7603 |
shift++; |
|
7604 |
} |
|
7605 |
__INST(redShift) = __MKSMALLINT(shift); |
|
7606 |
nBits = 0; |
|
7607 |
while (mask) { |
|
7608 |
mask >>= 1; |
|
7609 |
nBits++; |
|
7610 |
} |
|
7611 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
7612 |
||
7613 |
mask = visual->green_mask; |
|
7614 |
shift = 0; |
|
7615 |
while (mask && ((mask & 1) == 0)) { |
|
7616 |
mask >>= 1; |
|
7617 |
shift++; |
|
7618 |
} |
|
7619 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
7620 |
nBits = 0; |
|
7621 |
while (mask) { |
|
7622 |
mask >>= 1; |
|
7623 |
nBits++; |
|
7624 |
} |
|
7625 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
7626 |
||
7627 |
mask = visual->blue_mask; |
|
7628 |
shift = 0; |
|
7629 |
while (mask && ((mask & 1) == 0)) { |
|
7630 |
mask >>= 1; |
|
7631 |
shift++; |
|
7632 |
} |
|
7633 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
7634 |
nBits = 0; |
|
7635 |
while (mask) { |
|
7636 |
mask >>= 1; |
|
7637 |
nBits++; |
|
7638 |
} |
|
7639 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
7640 |
break; |
|
7641 |
} |
|
295 | 7642 |
|
7643 |
#ifndef XA_PRIMARY |
|
1344 | 7644 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 7645 |
#else |
1344 | 7646 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 7647 |
#endif |
7648 |
#ifndef XA_SECONDARY |
|
1344 | 7649 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 7650 |
#else |
1344 | 7651 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 7652 |
#endif |
7653 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 7654 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 7655 |
#else |
1344 | 7656 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 7657 |
#endif |
7658 |
#ifndef XA_STRING |
|
1344 | 7659 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 7660 |
#else |
1344 | 7661 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 7662 |
#endif |
7663 |
#ifndef XA_LENGTH |
|
1344 | 7664 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 7665 |
#else |
1344 | 7666 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 7667 |
#endif |
1533 | 7668 |
#ifndef WM_STATE |
7669 |
__INST(wmStateAtom) = __MKATOMOBJ( XInternAtom(dpy, "WM_STATE", True) ); |
|
7670 |
#else |
|
7671 |
__INST(wmStateAtom) = __MKATOMOBJ( WM_STATE ); |
|
7672 |
#endif |
|
295 | 7673 |
|
1344 | 7674 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7675 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7676 |
%}. |
295 | 7677 |
! |
7678 |
||
1344 | 7679 |
initializeSpecialFlags |
295 | 7680 |
"perform additional special server implementation flags" |
7681 |
||
7682 |
"/ |
|
7683 |
"/ assume we have it ... (should check) |
|
7684 |
"/ |
|
7685 |
hasSaveUnder := true. |
|
7686 |
ignoreBackingStore := false. |
|
7687 |
||
7688 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 7689 |
"/ |
7690 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
7691 |
"/ which does not correctly handle saveUnder |
|
7692 |
"/ |
|
7693 |
hasSaveUnder := false. |
|
295 | 7694 |
]. |
7695 |
! |
|
7696 |
||
1344 | 7697 |
reinitialize |
295 | 7698 |
virtualRootId := rootId := nil. |
7699 |
super reinitialize. |
|
7700 |
dispatchingExpose := nil |
|
7701 |
! ! |
|
7702 |
||
7703 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
7704 |
||
1344 | 7705 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7706 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7707 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7708 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7709 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7710 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7711 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7712 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7713 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7714 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7715 |
|
1344 | 7716 |
altModifierMask:aSmallInteger |
341 | 7717 |
"define which key takes the role of an alt-key. |
7718 |
By default, this is X's modifier1, which is the ALT key on |
|
7719 |
most keyboards. However, there may be exceptions to this, |
|
7720 |
and the setting can be changed with: |
|
1344 | 7721 |
Display altModifierMask:(Display modifier2Mask) |
341 | 7722 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
7723 |
" |
|
7724 |
||
7725 |
altModifierMask := aSmallInteger |
|
7726 |
! |
|
7727 |
||
1344 | 7728 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7729 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7730 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7731 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7732 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7733 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7734 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7735 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7736 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7737 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7738 |
|
1344 | 7739 |
metaModifierMask:aSmallInteger |
341 | 7740 |
"define which key takes the role of a meta key. |
7741 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
7742 |
most keyboards (if present at all). |
|
7743 |
However, there may be exceptions to this, and the setting can |
|
7744 |
be changed with: |
|
1344 | 7745 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 7746 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
7747 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
7748 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
7749 |
all the time. On those, you should disable the meta key by setting |
|
7750 |
the mask to 0. |
|
7751 |
" |
|
7752 |
||
7753 |
metaModifierMask := aSmallInteger |
|
7754 |
! |
|
7755 |
||
1344 | 7756 |
modifier1Mask |
341 | 7757 |
"return the Xlib mask bit for the 1st modifier key. |
7758 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7759 |
this could be used." |
|
7760 |
||
7761 |
%{ /* NOCONTEXT */ |
|
7762 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
7763 |
%} |
|
7764 |
! |
|
7765 |
||
1344 | 7766 |
modifier2Mask |
341 | 7767 |
"return the Xlib mask bit for the 2nd modifier key. |
7768 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7769 |
this could be used." |
|
7770 |
||
7771 |
%{ /* NOCONTEXT */ |
|
7772 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
7773 |
%} |
|
7774 |
! |
|
7775 |
||
1344 | 7776 |
modifierMapping |
341 | 7777 |
"Get the Modifier Mapping. |
7778 |
We return an array of arrays of keycodes" |
|
7779 |
||
7780 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
7781 |
||
7782 |
%{ |
|
7783 |
XModifierKeymap *modmap; |
|
7784 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
7785 |
||
7786 |
if (ISCONNECTED) { |
|
1344 | 7787 |
Display *dpy = myDpy; |
7788 |
||
7789 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
7790 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7791 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
7792 |
if (modifierKeyMap != nil) { |
|
7793 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7794 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
7795 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
7796 |
} |
|
7797 |
XFreeModifiermap(modmap); |
|
7798 |
} |
|
341 | 7799 |
} |
7800 |
%}. |
|
7801 |
||
7802 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
7803 |
||
7804 |
ret := Array new:8. |
|
7805 |
nextKey := 1. |
|
7806 |
1 to:8 do:[ :i | |
|
1344 | 7807 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
7808 |
|mod| |
|
7809 |
||
7810 |
mod := OrderedCollection new:maxKeyPerMod. |
|
7811 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
7812 |
key ~= 0 ifTrue:[ |
|
7813 |
mod add:key |
|
7814 |
]. |
|
7815 |
]. |
|
7816 |
ret at:i put:mod. |
|
7817 |
]. |
|
7818 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 7819 |
]. |
7820 |
||
7821 |
^ ret |
|
7822 |
||
7823 |
" |
|
1344 | 7824 |
Display modifierMapping |
341 | 7825 |
" |
7826 |
! |
|
7827 |
||
1344 | 7828 |
stringFromKeycode:code |
341 | 7829 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
7830 |
||
7831 |
|str| |
|
7832 |
||
7833 |
%{ |
|
7834 |
KeySym keysym; |
|
7835 |
char *keystring; |
|
7836 |
||
7837 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 7838 |
Display *dpy = myDpy; |
7839 |
||
7840 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
7841 |
(keystring = XKeysymToString(keysym)) != 0) |
|
7842 |
str = __MKSTRING(keystring); |
|
341 | 7843 |
} |
7844 |
%}. |
|
7845 |
^ str |
|
7846 |
||
7847 |
" |
|
1344 | 7848 |
Display stringFromKeycode:28 |
341 | 7849 |
" |
7850 |
! |
|
7851 |
||
1344 | 7852 |
translateKey:untranslatedKey |
295 | 7853 |
"Return the key translated via the translation table. |
7854 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
7855 |
which gets further processed in the superclasses translation method." |
|
7856 |
||
7857 |
|key| |
|
7858 |
||
7859 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 7860 |
key := RawKeysymTranslation at:key ifAbsent:key. |
7861 |
key := key asSymbol. |
|
295 | 7862 |
]. |
7863 |
^ super translateKey:key |
|
7864 |
! ! |
|
7865 |
||
7866 |
!XWorkstation methodsFor:'misc'! |
|
7867 |
||
1344 | 7868 |
beep |
295 | 7869 |
"output an audible beep or bell" |
7870 |
||
1906 | 7871 |
NoBeep ~~ true ifTrue:[ |
7872 |
self beep:50 |
|
7873 |
] |
|
295 | 7874 |
! |
7875 |
||
1344 | 7876 |
beep:volumeInPercent |
295 | 7877 |
"output an audible beep" |
7878 |
%{ |
|
7879 |
int volume; |
|
7880 |
||
7881 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 7882 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
7883 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
7884 |
if (volume < -100) volume = -100; |
|
7885 |
else if (volume > 100) volume = 100; |
|
7886 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 7887 |
ENTER_XLIB(); |
1344 | 7888 |
XBell(myDpy, volume); |
1974 | 7889 |
LEAVE_XLIB(); |
1344 | 7890 |
END_INTERRUPTSBLOCKED |
295 | 7891 |
} |
7892 |
%} |
|
7893 |
! |
|
7894 |
||
1344 | 7895 |
buffered |
295 | 7896 |
"buffer drawing - do not send it immediately to the display. |
374 | 7897 |
This is the default anyway. |
7898 |
See #unBuffered for additional info." |
|
295 | 7899 |
|
7900 |
%{ /* NOCONTEXT */ |
|
7901 |
||
7902 |
if (ISCONNECTED) { |
|
1344 | 7903 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 7904 |
ENTER_XLIB(); |
1344 | 7905 |
XSynchronize(myDpy, 0); |
1974 | 7906 |
LEAVE_XLIB(); |
1344 | 7907 |
END_INTERRUPTSBLOCKED |
295 | 7908 |
} |
7909 |
%} |
|
374 | 7910 |
" |
7911 |
Display buffered |
|
7912 |
" |
|
295 | 7913 |
! |
7914 |
||
1344 | 7915 |
flush |
295 | 7916 |
"send all buffered drawing to the display. |
7917 |
This may be required to make certain, that all previous operations |
|
7918 |
are really sent to the display before continuing. For example, |
|
7919 |
after a cursor-change with a followup long computation. |
|
374 | 7920 |
(otherwise, the cursor change request may still be in the output buffer) |
7921 |
See also #sync, which even waits until the request has been processed." |
|
295 | 7922 |
|
7923 |
%{ /* NOCONTEXT */ |
|
7924 |
||
7925 |
if (ISCONNECTED) { |
|
1344 | 7926 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 7927 |
ENTER_XLIB(); |
1344 | 7928 |
XFlush(myDpy); |
1974 | 7929 |
LEAVE_XLIB(); |
1344 | 7930 |
END_INTERRUPTSBLOCKED |
310 | 7931 |
} |
7932 |
%} |
|
7933 |
! |
|
7934 |
||
1344 | 7935 |
flushDpsContext:aDPSContext |
295 | 7936 |
|
7937 |
%{ /* NOCONTEXT */ |
|
7938 |
#ifdef DPS |
|
7939 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 7940 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 7941 |
ENTER_XLIB(); |
1344 | 7942 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
1974 | 7943 |
LEAVE_XLIB(); |
1344 | 7944 |
END_INTERRUPTSBLOCKED |
7945 |
RETURN ( self ); |
|
295 | 7946 |
} |
7947 |
#endif |
|
374 | 7948 |
%}. |
295 | 7949 |
self primitiveFailed |
7950 |
! |
|
7951 |
||
1344 | 7952 |
refreshKeyboardMapping:eB |
295 | 7953 |
%{ |
7954 |
XMappingEvent *ev; |
|
7955 |
||
7956 |
if (__isByteArray(eB)) { |
|
1344 | 7957 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1974 | 7958 |
ENTER_XLIB(); |
1344 | 7959 |
XRefreshKeyboardMapping(ev); |
1974 | 7960 |
LEAVE_XLIB(); |
295 | 7961 |
} |
7962 |
%} |
|
7963 |
! |
|
7964 |
||
1344 | 7965 |
setInputFocusTo:aWindowId |
295 | 7966 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
7967 |
self setInputFocusTo:aWindowId revertTo:#root |
|
7968 |
! |
|
7969 |
||
1344 | 7970 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 7971 |
"set the focus to the view as defined by aWindowId. |
7972 |
Passing nil set the focus to no window and lets the display discard all |
|
7973 |
input until a new focus is set. |
|
7974 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
7975 |
passing one of #parent, #root or nil specifies that the focus should be |
|
7976 |
given to the parent view, the root view or no view." |
|
7977 |
||
7978 |
%{ /* NOCONTEXT */ |
|
7979 |
int arg; |
|
7980 |
Window focusWindow; |
|
7981 |
||
7982 |
if (ISCONNECTED) { |
|
1344 | 7983 |
if (__isExternalAddress(aWindowId)) { |
7984 |
focusWindow = _WindowVal(aWindowId); |
|
7985 |
} else { |
|
7986 |
focusWindow = None; |
|
7987 |
} |
|
7988 |
if (revertSymbol == @symbol(parent)) |
|
7989 |
arg = RevertToParent; |
|
7990 |
else if (revertSymbol == @symbol(root)) |
|
7991 |
arg = RevertToPointerRoot; |
|
7992 |
else |
|
7993 |
arg = RevertToNone; |
|
7994 |
||
7995 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 7996 |
ENTER_XLIB(); |
1344 | 7997 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
1974 | 7998 |
LEAVE_XLIB(); |
1344 | 7999 |
END_INTERRUPTSBLOCKED |
8000 |
RETURN ( self ); |
|
295 | 8001 |
} |
8002 |
%}. |
|
8003 |
self primitiveFailed |
|
8004 |
! |
|
8005 |
||
1344 | 8006 |
sync |
341 | 8007 |
"send all buffered drawing to the display AND wait until the display |
8008 |
has finished drawing it. |
|
8009 |
This is almost never needed, except if you are about to read previously |
|
374 | 8010 |
drawn pixels back from the display screen, or you want to wait for a beep |
8011 |
to be finished. See also #flush." |
|
341 | 8012 |
|
8013 |
%{ /* NOCONTEXT */ |
|
8014 |
||
8015 |
if (ISCONNECTED) { |
|
1344 | 8016 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 8017 |
ENTER_XLIB(); |
1344 | 8018 |
XSync(myDpy, 0); |
1974 | 8019 |
LEAVE_XLIB(); |
1344 | 8020 |
END_INTERRUPTSBLOCKED |
341 | 8021 |
} |
8022 |
%} |
|
8023 |
! |
|
8024 |
||
1344 | 8025 |
unBuffered |
374 | 8026 |
"make all drawing be sent immediately to the display. |
8027 |
This makes all graphics synchronous and turns off any buffering |
|
8028 |
(i.e. each individual draw-request is sent immediately without |
|
8029 |
packing multiple requests into a larger message buffer). |
|
8030 |
Be prepared, that this slows down graphics considerably. |
|
8031 |
However, it allows display errors to be handled immediately and |
|
8032 |
may be useful if you get Xdisplay errors and want to find the request |
|
1813 | 8033 |
which was responsible for it. See also #buffered." |
295 | 8034 |
|
8035 |
%{ /* NOCONTEXT */ |
|
8036 |
||
8037 |
if (ISCONNECTED) { |
|
1344 | 8038 |
BEGIN_INTERRUPTSBLOCKED |
1974 | 8039 |
ENTER_XLIB(); |
1344 | 8040 |
XSynchronize(myDpy, 1); |
1974 | 8041 |
LEAVE_XLIB(); |
1344 | 8042 |
END_INTERRUPTSBLOCKED |
295 | 8043 |
} |
8044 |
%} |
|
1813 | 8045 |
" |
8046 |
Display unBuffered |
|
8047 |
" |
|
295 | 8048 |
! ! |
8049 |
||
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8050 |
!XWorkstation methodsFor:'pointer stuff'! |
295 | 8051 |
|
1344 | 8052 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8053 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8054 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8055 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8056 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8057 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8058 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8059 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8060 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8061 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8062 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8063 |
|
1344 | 8064 |
buttonStates |
295 | 8065 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8066 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8067 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8068 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 8069 |
|
8070 |
%{ /* NOCONTEXT*/ |
|
8071 |
Window w; |
|
555 | 8072 |
int screen = __intVal(__INST(screen)); |
295 | 8073 |
Window rootRet, childRet; |
8074 |
int rootX, rootY, winX, winY; |
|
8075 |
unsigned int mask; |
|
8076 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8077 |
if (ISCONNECTED) { |
1906 | 8078 |
Display *dpy = myDpy; |
8079 |
||
8080 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 8081 |
#ifdef VIRTUAL_ROOT |
1906 | 8082 |
w = getRootWindow(myDpy, screen); |
295 | 8083 |
#else |
1906 | 8084 |
w = RootWindow(dpy, screen); |
295 | 8085 |
#endif |
1906 | 8086 |
END_INTERRUPTSBLOCKED |
8087 |
if (w) { |
|
8088 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 8089 |
ENTER_XLIB(); |
1906 | 8090 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
8091 |
&rootX, &rootY, |
|
8092 |
&winX, &winY, |
|
8093 |
&mask); |
|
1974 | 8094 |
LEAVE_XLIB(); |
1906 | 8095 |
END_INTERRUPTSBLOCKED |
8096 |
RETURN (__MKSMALLINT(mask)); |
|
8097 |
} |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8098 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8099 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8100 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8101 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8102 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8103 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8104 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8105 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8106 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8107 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8108 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8109 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8110 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8111 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8112 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8113 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8114 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8115 |
" |
295 | 8116 |
! |
8117 |
||
1344 | 8118 |
leftButtonStateMask |
295 | 8119 |
"return an integer for masking out the left button from a |
8120 |
buttonStates value" |
|
8121 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8122 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8123 |
|
295 | 8124 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8125 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8126 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 8127 |
! |
8128 |
||
1344 | 8129 |
middleButtonStateMask |
295 | 8130 |
"return an integer for masking out the middle button from a |
8131 |
buttonStates value" |
|
8132 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8133 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8134 |
|
295 | 8135 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8136 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8137 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 8138 |
! |
8139 |
||
1344 | 8140 |
pointerPosition |
295 | 8141 |
"return the current pointer position in root-window coordinates" |
8142 |
||
8143 |
|xpos ypos| |
|
8144 |
||
8145 |
%{ |
|
8146 |
Window w; |
|
555 | 8147 |
int screen = __intVal(__INST(screen)); |
295 | 8148 |
Window rootRet, childRet; |
8149 |
int rootX, rootY, winX, winY; |
|
8150 |
unsigned int mask; |
|
8151 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8152 |
if (ISCONNECTED) { |
1344 | 8153 |
Display *dpy = myDpy; |
8154 |
||
8155 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 8156 |
#ifdef VIRTUAL_ROOT |
1344 | 8157 |
w = getRootWindow(myDpy, screen); |
295 | 8158 |
#else |
1344 | 8159 |
w = RootWindow(dpy, screen); |
295 | 8160 |
#endif |
1974 | 8161 |
ENTER_XLIB(); |
1344 | 8162 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
8163 |
&rootX, &rootY, |
|
8164 |
&winX, &winY, |
|
8165 |
&mask); |
|
1974 | 8166 |
LEAVE_XLIB(); |
1344 | 8167 |
xpos = __MKSMALLINT(rootX); |
8168 |
ypos = __MKSMALLINT(rootY); |
|
8169 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8170 |
} |
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8171 |
%}. |
295 | 8172 |
^ xpos @ ypos |
8173 |
! |
|
8174 |
||
1344 | 8175 |
rightButtonStateMask |
295 | 8176 |
"return an integer for masking out the right button from a |
8177 |
buttonStates value" |
|
8178 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8179 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8180 |
|
295 | 8181 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8182 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
8183 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 8184 |
! |
8185 |
||
1344 | 8186 |
rootPositionOfLastEvent |
295 | 8187 |
"return the position in root-window coordinates |
8188 |
of the last button, key or pointer event" |
|
8189 |
||
8190 |
^ eventRootX @ eventRootY |
|
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8191 |
! |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8192 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8193 |
setPointerPosition:newPosition in:aWindowId |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8194 |
"change the pointer position to a new position relative to the |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8195 |
given windows origin (which may be the rootWindow). |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8196 |
Be careful with this - its usually not very ergonimically |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8197 |
to change the mousePointer position. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8198 |
This interface is provided for special applications (presentation |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8199 |
playback) and should not be used in normal applications." |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8200 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8201 |
|xpos ypos| |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8202 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8203 |
xpos := newPosition x. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8204 |
ypos := newPosition y. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8205 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8206 |
%{ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8207 |
if (ISCONNECTED |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8208 |
&& __isExternalAddress(aWindowId) |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8209 |
&& __bothSmallInteger(xpos, ypos)) { |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8210 |
Display *dpy = myDpy; |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8211 |
Window w = _WindowVal(aWindowId); |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8212 |
|
1974 | 8213 |
ENTER_XLIB(); |
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8214 |
XWarpPointer(dpy, |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8215 |
None, /* src window */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8216 |
w, /* dst window */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8217 |
0, /* src_x */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8218 |
0, /* src_y */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8219 |
0, /* src_w */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8220 |
0, /* src_h */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8221 |
__intVal(xpos), /* dst_x */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8222 |
__intVal(ypos) /* dst_y */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8223 |
); |
1974 | 8224 |
LEAVE_XLIB(); |
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8225 |
} |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8226 |
%}. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8227 |
^ self |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8228 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8229 |
" |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8230 |
Display setPointerPosition:1000@1000 |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
8231 |
" |
295 | 8232 |
! ! |
8233 |
||
1556 | 8234 |
!XWorkstation methodsFor:'properties'! |
8235 |
||
8236 |
getObjectProperty:propertyID from:aWindowID |
|
8237 |
"get an object property from the server; return object or nil" |
|
8238 |
||
8239 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8240 |
type == stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8241 |
^ value |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8242 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8243 |
(value isMemberOf:ByteArray) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8244 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8245 |
] |
1556 | 8246 |
]. |
8247 |
^ nil |
|
8248 |
||
8249 |
"Modified: 6.4.1997 / 13:27:07 / cg" |
|
8250 |
! |
|
8251 |
||
8252 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
8253 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
8254 |
||
8255 |
|val typeID cls| |
|
8256 |
||
8257 |
cls := ByteArray. |
|
8258 |
%{ |
|
8259 |
Window window; |
|
8260 |
Atom property; |
|
8261 |
char *cp, *cp2; |
|
8262 |
Atom actual_type; |
|
8263 |
int actual_format,i; |
|
8264 |
unsigned long nitems, bytes_after, nread; |
|
8265 |
unsigned char *data; |
|
8266 |
int ok = 1; |
|
8267 |
# define PROP_SIZE 2048 |
|
8268 |
||
8269 |
if (ISCONNECTED) { |
|
8270 |
Display *dpy = myDpy; |
|
8271 |
||
8272 |
if (__isAtomID(propertyID)) { |
|
8273 |
property = _AtomVal(propertyID); |
|
8274 |
if (__isExternalAddress(aWindowID)) { |
|
8275 |
window = _WindowVal(aWindowID); |
|
8276 |
} else { |
|
8277 |
window = DefaultRootWindow(dpy); |
|
8278 |
} |
|
8279 |
||
8280 |
nread = 0; |
|
8281 |
cp = 0; |
|
8282 |
/* |
|
8283 |
fprintf(stderr, "getProperty: "); |
|
8284 |
*/ |
|
8285 |
do { |
|
8286 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
8287 |
AnyPropertyType,&actual_type,&actual_format, |
|
8288 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
8289 |
!= Success) { |
|
8290 |
ok = 0; |
|
8291 |
break; |
|
8292 |
} |
|
8293 |
typeID = __MKATOMOBJ(actual_type); |
|
8294 |
if (! cp) { |
|
8295 |
cp = cp2 = (char *)malloc(nitems+1); |
|
8296 |
} else { |
|
8297 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
8298 |
cp2 = cp + nread; |
|
8299 |
} |
|
8300 |
if (! cp) { |
|
8301 |
XFree(data); |
|
8302 |
goto fail; |
|
8303 |
} |
|
8304 |
||
8305 |
nread += nitems; |
|
8306 |
bcopy(data, cp2, nitems); |
|
8307 |
XFree(data); |
|
8308 |
/* |
|
8309 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
8310 |
*/ |
|
8311 |
} while (bytes_after > 0); |
|
8312 |
/* |
|
8313 |
fprintf(stderr, "\n"); |
|
8314 |
*/ |
|
8315 |
||
8316 |
if (ok) { |
|
8317 |
if (actual_type == XA_STRING) { |
|
8318 |
cp[nread] = '\0'; |
|
8319 |
val = __MKSTRING_L(cp, nread); |
|
8320 |
} else { |
|
8321 |
val = __new(nread + OHDR_SIZE); |
|
8322 |
val->o_class = cls; |
|
8323 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
8324 |
} |
|
8325 |
} |
|
8326 |
if (cp) |
|
8327 |
free(cp); |
|
8328 |
} |
|
8329 |
} |
|
8330 |
fail: ; |
|
8331 |
%}. |
|
8332 |
typeID isNil ifTrue:[ |
|
8333 |
^ false |
|
8334 |
]. |
|
8335 |
aTwoArgBlock value:typeID value:val. |
|
8336 |
^ true |
|
8337 |
! |
|
8338 |
||
8339 |
getTextProperty:propertyID from:aWindowID |
|
8340 |
"get a text property; return string or nil" |
|
8341 |
||
1798 | 8342 |
|stringClass| |
8343 |
||
1556 | 8344 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
1906 | 8345 |
type == stringAtom ifTrue:[ |
8346 |
clipBoardEncoding notNil ifTrue:[ |
|
8347 |
stringClass := (CharacterArray classForEncoding:clipBoardEncoding). |
|
8348 |
stringClass ~~ String ifTrue:[ |
|
8349 |
^ stringClass fromBytes:(value asByteArray) |
|
8350 |
]. |
|
8351 |
^ value decodeFrom:clipBoardEncoding |
|
8352 |
]. |
|
8353 |
^ value |
|
8354 |
] |
|
1556 | 8355 |
]. |
8356 |
^ nil |
|
1793 | 8357 |
|
1798 | 8358 |
"Modified: 30.6.1997 / 20:54:59 / cg" |
1556 | 8359 |
! |
8360 |
||
8361 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
8362 |
"set a size property" |
|
8363 |
||
8364 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8365 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8366 |
type:(self atomIDOfLENGTH) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8367 |
value:aNumber |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8368 |
for:aWindowID |
1556 | 8369 |
|
8370 |
"Modified: 6.4.1997 / 13:27:26 / cg" |
|
8371 |
! |
|
8372 |
||
8373 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
8374 |
"set a property to a smalltalk object in the XServer. |
|
8375 |
Can only be retrieved by another ST/X smalltalk" |
|
8376 |
||
8377 |
|s| |
|
8378 |
||
8379 |
(anObject isMemberOf:String) ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8380 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
1556 | 8381 |
]. |
8382 |
s := WriteStream on:(ByteArray new:200). |
|
8383 |
anObject storeBinaryOn:s. |
|
8384 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8385 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8386 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8387 |
value:(s contents) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8388 |
for:aWindowID |
1556 | 8389 |
|
8390 |
"Modified: 6.4.1997 / 13:27:57 / cg" |
|
8391 |
! |
|
8392 |
||
8393 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
8394 |
"set a property in the XServer" |
|
8395 |
||
8396 |
%{ /* UNLIMITEDSTACK */ |
|
8397 |
||
8398 |
Atom prop, type; |
|
8399 |
Window window; |
|
1888 | 8400 |
unsigned INT value; |
1556 | 8401 |
|
8402 |
if (__isAtomID(propertyID) |
|
8403 |
&& __isAtomID(typeID) |
|
8404 |
&& ISCONNECTED |
|
8405 |
&& (__isString(anObject) |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8406 |
|| __isSmallInteger(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8407 |
|| __isSymbol(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8408 |
|| __isByteArray(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8409 |
|| __isWords(anObject))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8410 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8411 |
Display *dpy = myDpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8412 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8413 |
prop = _AtomVal(propertyID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8414 |
type = _AtomVal(typeID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8415 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8416 |
if (__isExternalAddress(aWindowID)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8417 |
window = _WindowVal(aWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8418 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8419 |
window = DefaultRootWindow(dpy); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8420 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8421 |
if (__isSmallInteger(anObject)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8422 |
value = __intVal(anObject); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8423 |
XChangeProperty(dpy, window, prop, type, 32, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8424 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8425 |
(unsigned char *)(&value), sizeof(unsigned int)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8426 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8427 |
if (__isByteArray(anObject)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8428 |
XChangeProperty(dpy, window, prop, type, 8, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8429 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8430 |
__ByteArrayInstPtr(anObject)->ba_element, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8431 |
__byteArraySize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8432 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8433 |
/* string or symbol or wordArray-like (16bit-string) object */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8434 |
type = _AtomVal(typeID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8435 |
if (__isWords(__qClass(anObject))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8436 |
XChangeProperty(dpy, window, prop, type, 16, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8437 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8438 |
__stringVal(anObject), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8439 |
__wordArraySize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8440 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8441 |
XChangeProperty(dpy, window, prop, type, 8, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8442 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8443 |
__stringVal(anObject), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8444 |
__stringSize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8445 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8446 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8447 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8448 |
RETURN (true); |
1556 | 8449 |
} |
8450 |
%}. |
|
8451 |
^ false |
|
8452 |
! |
|
8453 |
||
8454 |
setTextProperty:propertyID value:aString for:aWindowID |
|
8455 |
"set a property to a stringValue in the XServer" |
|
8456 |
||
8457 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8458 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8459 |
type:(self atomIDOfSTRING) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8460 |
value:aString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8461 |
for:aWindowID |
1556 | 8462 |
|
8463 |
"Modified: 6.4.1997 / 13:26:32 / cg" |
|
8464 |
! ! |
|
8465 |
||
295 | 8466 |
!XWorkstation methodsFor:'resources'! |
8467 |
||
1344 | 8468 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8469 |
"return an Atoms ID; dont create if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8470 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8471 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8472 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8473 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8474 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8475 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8476 |
Display atomIDOf:'FULL_NAME' |
1535 | 8477 |
Display atomIDOf:'DndProtocol' |
8478 |
Display atomIDOf:'DndSelection' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8479 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8480 |
|
1535 | 8481 |
"Modified: 4.4.1997 / 13:38:48 / cg" |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8482 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8483 |
|
1344 | 8484 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8485 |
"return an Atoms ID; if create is true, create it if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8486 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8487 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8488 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8489 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8490 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8491 |
if (ISCONNECTED) { |
1344 | 8492 |
if (__isString(aStringOrSymbol) |
8493 |
|| __isSymbol(aStringOrSymbol)) { |
|
1831 | 8494 |
prop = XInternAtom(myDpy, __stringVal(aStringOrSymbol), |
1344 | 8495 |
(create == true) ? False : True); |
8496 |
if (prop == None) { |
|
8497 |
RETURN (nil); |
|
8498 |
} |
|
8499 |
RETURN ( __MKATOMOBJ(prop) ); |
|
8500 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8501 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8502 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8503 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8504 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8505 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8506 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8507 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8508 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8509 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8510 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8511 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8512 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8513 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8514 |
|
1344 | 8515 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8516 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8517 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8518 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8519 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8520 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8521 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8522 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8523 |
|
1344 | 8524 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8525 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8526 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8527 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8528 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8529 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8530 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8531 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8532 |
|
1344 | 8533 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8534 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8535 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8536 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8537 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8538 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8539 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8540 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8541 |
|
1344 | 8542 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8543 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8544 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8545 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8546 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8547 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8548 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8549 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8550 |
|
1344 | 8551 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8552 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8553 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8554 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8555 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8556 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8557 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8558 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8559 |
|
1344 | 8560 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8561 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8562 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8563 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8564 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8565 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8566 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8567 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8568 |
if (ISCONNECTED) { |
1344 | 8569 |
if (__isAtomID(anAtomID)) { |
8570 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
8571 |
if (name == 0) { |
|
8572 |
RETURN (nil); |
|
8573 |
} |
|
8574 |
str = __MKSTRING(name); |
|
8575 |
XFree(name); |
|
8576 |
RETURN ( str ); |
|
8577 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8578 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8579 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8580 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8581 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8582 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8583 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8584 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8585 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8586 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8587 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8588 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8589 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8590 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8591 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8592 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8593 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8594 |
|
1344 | 8595 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8596 |
"access the displays resource database for a default value |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8597 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8598 |
This is highly X specific and currently not used. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8599 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8600 |
Notice: |
1344 | 8601 |
we do not plan to use X's resources for ST/X's defaults, |
8602 |
styles or resources. This would make porting of applications |
|
8603 |
to different platforms much more difficult (Windows has no resource |
|
8604 |
database). If you stay within ST/X's resource files, these can be |
|
8605 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8606 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8607 |
This method is provided for special applications which want to access |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8608 |
existing X resources and are not planned to be ever ported to other |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8609 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8610 |
|
295 | 8611 |
%{ |
8612 |
char *rslt; |
|
8613 |
||
8614 |
if ((__isString(name) || __isSymbol(name)) |
|
8615 |
&& (__isString(cls) || __isSymbol(cls)) |
|
8616 |
&& ISCONNECTED) { |
|
1344 | 8617 |
BEGIN_INTERRUPTSBLOCKED |
1831 | 8618 |
rslt = XGetDefault(myDpy, (char *) __stringVal(cls), |
8619 |
(char *) __stringVal(name)); |
|
1344 | 8620 |
END_INTERRUPTSBLOCKED |
8621 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8622 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8623 |
%}. |
295 | 8624 |
self primitiveFailed. |
8625 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8626 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8627 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 8628 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8629 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8630 |
|
1344 | 8631 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8632 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8633 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 8634 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8635 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8636 |
|
1344 | 8637 |
Display getResource:'beNiceToColormap' class:'any' |
8638 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8639 |
" |
295 | 8640 |
! ! |
8641 |
||
8642 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
8643 |
||
1462
f8b2909deb3c
renamed getBitsFrom to getBitsFromId
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
8644 |
getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 8645 |
"get bits from a drawable into the imageBits. The storage for the bits |
8646 |
must be big enough for the data to fit. If ok, returns an array with some |
|
8647 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
8648 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
8649 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
8650 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8651 |
|rawInfo info| |
295 | 8652 |
|
8653 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 8654 |
self primitiveFailed. |
8655 |
^ nil |
|
295 | 8656 |
]. |
8657 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8658 |
rawInfo := Array new:8. |
1344 | 8659 |
"1 -> bit order" |
8660 |
"2 -> depth" |
|
8661 |
"3 -> bytes_per_line" |
|
8662 |
"4 -> byte_order" |
|
8663 |
"5 -> format" |
|
8664 |
"6 -> bitmap_unit" |
|
8665 |
"7 -> bitmap_pad" |
|
8666 |
"8 -> bits_per_pixel" |
|
295 | 8667 |
|
8668 |
"/ had to extract the getPixel call into a separate method, to specify |
|
8669 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
8670 |
"/ of temporary stack space |
|
8671 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8672 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 8673 |
info := IdentityDictionary new. |
8674 |
info at:#bitOrder put:(rawInfo at:1). |
|
8675 |
info at:#depth put:(rawInfo at:2). |
|
8676 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
8677 |
info at:#byteOrder put:(rawInfo at:4). |
|
8678 |
info at:#format put:(rawInfo at:5). |
|
8679 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
8680 |
info at:#bitmapPad put:(rawInfo at:7). |
|
8681 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
8682 |
^ info |
|
295 | 8683 |
]. |
8684 |
" |
|
8685 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
8686 |
or is too small to hold the bits |
|
8687 |
" |
|
8688 |
^ self primitiveFailed |
|
8689 |
! |
|
8690 |
||
1344 | 8691 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
8692 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left. |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
8693 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 8694 |
|
8695 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
8696 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8697 |
Window win; |
295 | 8698 |
XImage *img; |
8699 |
int ret; |
|
8700 |
int xpos, ypos; |
|
8701 |
||
1209 | 8702 |
if (ISCONNECTED |
8703 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 8704 |
win = _WindowVal(aDrawableId); |
8705 |
xpos = __intVal(x); |
|
8706 |
ypos = __intVal(y); |
|
8707 |
if ((xpos < 0) || (ypos < 0)) { |
|
8708 |
RETURN ( __MKSMALLINT(0) ); |
|
8709 |
} |
|
1974 | 8710 |
ENTER_XLIB(); |
1344 | 8711 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
1974 | 8712 |
LEAVE_XLIB(); |
1344 | 8713 |
if (img != 0) { |
8714 |
ret = XGetPixel(img, 0, 0); |
|
8715 |
XDestroyImage(img); |
|
8716 |
RETURN ( __MKSMALLINT(ret) ); |
|
8717 |
} |
|
295 | 8718 |
} |
8719 |
%}. |
|
8720 |
^ nil |
|
8721 |
! |
|
8722 |
||
1344 | 8723 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 8724 |
"since XGetImage may allocate huge amount of stack space |
8725 |
(some implementations use alloca), this must run with unlimited stack." |
|
8726 |
||
8727 |
%{ /* UNLIMITEDSTACK */ |
|
8728 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8729 |
Window win; |
295 | 8730 |
XImage *image = (XImage *)0; |
8731 |
int pad, bytes_per_line, numBytes; |
|
8732 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8733 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8734 |
&& __isExternalAddress(aDrawableId) |
295 | 8735 |
&& __bothSmallInteger(srcx, srcy) |
8736 |
&& __bothSmallInteger(w, h) |
|
8737 |
&& __isArray(info) |
|
8738 |
&& __isByteArray(imageBits)) { |
|
1344 | 8739 |
Display *dpy = myDpy; |
8740 |
||
8741 |
win = _WindowVal(aDrawableId); |
|
1974 | 8742 |
ENTER_XLIB(); |
1344 | 8743 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
8744 |
__intVal(w), __intVal(h), |
|
8745 |
(unsigned)AllPlanes, ZPixmap); |
|
1974 | 8746 |
LEAVE_XLIB(); |
1344 | 8747 |
|
8748 |
if (! image) { |
|
8749 |
RETURN ( false ); |
|
8750 |
} |
|
8751 |
||
8752 |
pad = image->bitmap_pad; |
|
295 | 8753 |
#ifdef SUPERDEBUG |
1344 | 8754 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 8755 |
#endif |
1344 | 8756 |
switch (image->depth) { |
8757 |
case 1: |
|
8758 |
case 2: |
|
8759 |
case 4: |
|
8760 |
case 8: |
|
8761 |
case 16: |
|
8762 |
case 24: |
|
8763 |
case 32: |
|
8764 |
numBytes = image->bytes_per_line * image->height; |
|
8765 |
break; |
|
1728 | 8766 |
|
1344 | 8767 |
default: |
8768 |
/* unsupported depth ? */ |
|
8769 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
8770 |
numBytes = image->bytes_per_line * image->height; |
|
8771 |
break; |
|
8772 |
} |
|
295 | 8773 |
|
8774 |
#ifdef SUPERDEBUG |
|
1344 | 8775 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 8776 |
#endif |
8777 |
||
1344 | 8778 |
if (numBytes > __byteArraySize(imageBits)) { |
8779 |
/* imageBits too small */ |
|
1728 | 8780 |
fprintf(stderr, "Workstation [warning]: byteArray too small in primGetBits\n"); |
8781 |
fprintf(stderr, " bytes need:%d given:%d\n", numBytes, __byteArraySize(imageBits)); |
|
8782 |
fprintf(stderr, " pad:%d depth:%d imgBytesPerLine:%d\n", |
|
8783 |
image->bitmap_pad, image->depth, image->bytes_per_line); |
|
1344 | 8784 |
goto fail; |
8785 |
} |
|
8786 |
if (image->bitmap_bit_order == MSBFirst) |
|
8787 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
8788 |
else |
|
8789 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
8790 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
8791 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
8792 |
if (image->byte_order == MSBFirst) |
|
8793 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
8794 |
else |
|
8795 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
8796 |
if (image->format == XYBitmap) |
|
8797 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
8798 |
else if (image->format == XYPixmap) |
|
8799 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
8800 |
else if (image->format == ZPixmap) |
|
8801 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
8802 |
|
1344 | 8803 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
8804 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
8805 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
8806 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
8807 |
XDestroyImage(image); |
|
8808 |
RETURN ( true ); |
|
295 | 8809 |
} |
8810 |
fail: |
|
8811 |
if (image) { |
|
1344 | 8812 |
XDestroyImage(image); |
295 | 8813 |
} |
8814 |
%}. |
|
8815 |
^ false |
|
8816 |
! ! |
|
8817 |
||
8818 |
!XWorkstation methodsFor:'selections'! |
|
8819 |
||
1344 | 8820 |
getSelectionFor:drawableId |
295 | 8821 |
"get the object selection - either immediate, or asynchronous. |
8822 |
Returns nil, if async request is on its way" |
|
8823 |
||
8824 |
|selProp sel| |
|
8825 |
||
8826 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8827 |
"no primary selection - use cut buffer" |
8828 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
8829 |
^ sel |
|
295 | 8830 |
]. |
8831 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
8832 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
8833 |
^ nil |
|
8834 |
! |
|
8835 |
||
1344 | 8836 |
getSelectionOwnerOf:selectionAtomID |
295 | 8837 |
"get the owner of a selection" |
8838 |
||
8839 |
%{ /* NOCONTEXT */ |
|
8840 |
Atom selection; |
|
8841 |
Window window; |
|
8842 |
||
8843 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 8844 |
Display *dpy = myDpy; |
8845 |
||
8846 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
1913
cd9259612040
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
8847 |
RETURN ((window == None) ? nil : __MKEXTERNALADDRESS(window)); |
295 | 8848 |
} |
8849 |
%}. |
|
8850 |
self primitiveFailed. |
|
8851 |
^ nil |
|
8852 |
! |
|
8853 |
||
1344 | 8854 |
getTextSelectionFor:drawableId |
295 | 8855 |
"get the text selection - either immediate, or asynchronous. |
8856 |
Returns nil, if async request is on its way" |
|
8857 |
||
8858 |
|selProp sel| |
|
8859 |
||
8860 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8861 |
"no primary selection - use cut buffer" |
8862 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
8863 |
^ sel |
|
295 | 8864 |
]. |
8865 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
8866 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
8867 |
^ nil |
|
8868 |
! |
|
8869 |
||
1344 | 8870 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 8871 |
"ask the server to send us the selection - the view with ID aWindowID |
8872 |
will later receive a SelectionNotify event for it." |
|
8873 |
||
8874 |
^ self requestSelection:selectionID |
|
1344 | 8875 |
property:propertyID |
8876 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
8877 |
for:aWindowId |
|
8878 |
! |
|
8879 |
||
8880 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 8881 |
"ask the server to send us the selection - the view with id aWindowID |
8882 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
8883 |
with the selections value)." |
|
8884 |
||
8885 |
%{ /* NOCONTEXT */ |
|
8886 |
Atom sel_prop; |
|
8887 |
char *cp; |
|
8888 |
||
8889 |
if (__isExternalAddress(aWindowId) |
|
8890 |
&& ISCONNECTED |
|
8891 |
&& __isSmallInteger(typeID) |
|
8892 |
&& __isAtomID(selectionID)) { |
|
1344 | 8893 |
Display *dpy = myDpy; |
8894 |
||
8895 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
8896 |
/* |
|
8897 |
* no owner of primary selection |
|
8898 |
*/ |
|
8899 |
RETURN (false); |
|
8900 |
} |
|
8901 |
/* |
|
8902 |
* PRIMARY selection |
|
8903 |
*/ |
|
8904 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
8905 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
8906 |
RETURN (true); |
|
295 | 8907 |
} |
8908 |
%}. |
|
8909 |
self primitiveFailed. |
|
8910 |
^ false |
|
8911 |
||
8912 |
" |
|
8913 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 8914 |
property:(Display atomIDOf:'VT_SELECTION') |
8915 |
for:0 |
|
295 | 8916 |
" |
8917 |
! |
|
8918 |
||
1344 | 8919 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 8920 |
"ask the server to send us the selection - the view with ID aWindowID |
8921 |
will later receive a SelectionNotify event for it." |
|
8922 |
||
8923 |
^ self requestSelection:selectionID |
|
1344 | 8924 |
property:propertyID |
8925 |
type:stringAtom |
|
8926 |
for:aWindowId |
|
8927 |
! |
|
8928 |
||
8929 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8930 |
"send aString back from a SelectionRequest" |
8931 |
||
8932 |
self |
|
1344 | 8933 |
sendSelection:something |
8934 |
selection:primaryAtom |
|
8935 |
property:propertyID |
|
8936 |
target:targetID |
|
8937 |
from:windowID |
|
8938 |
to:requestorID |
|
8939 |
! |
|
8940 |
||
8941 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8942 |
"send aString back from a SelectionRequest" |
8943 |
||
8944 |
self |
|
1344 | 8945 |
setProperty:propertyID |
8946 |
type:targetID |
|
8947 |
value:something |
|
8948 |
for:requestorID. |
|
295 | 8949 |
self |
1344 | 8950 |
sendSelectionNotifySelection:selectionID |
8951 |
property:propertyID |
|
8952 |
target:targetID |
|
8953 |
from:requestorID |
|
8954 |
to:requestorID. |
|
8955 |
! |
|
8956 |
||
8957 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8958 |
"send a selectionNotify back from a SelectionRequest" |
8959 |
||
8960 |
%{ /* NOCONTEXT */ |
|
8961 |
||
8962 |
if (__isAtomID(propertyID) |
|
8963 |
&& __isExternalAddress(requestorID) |
|
8964 |
&& ISCONNECTED |
|
8965 |
&& __isAtomID(targetID) |
|
8966 |
&& __isAtomID(selectionID)) { |
|
1916 | 8967 |
Display *dpy = myDpy; |
8968 |
XEvent ev; |
|
8969 |
Window requestor = _WindowVal(requestorID); |
|
8970 |
Atom property = _AtomVal(propertyID); |
|
8971 |
Atom target = _AtomVal(targetID); |
|
8972 |
Atom selection = _AtomVal(selectionID); |
|
8973 |
Status result; |
|
8974 |
||
8975 |
ev.xselection.type = SelectionNotify; |
|
8976 |
ev.xselection.display = dpy; |
|
8977 |
ev.xselection.selection = selection; |
|
8978 |
ev.xselection.target = target; |
|
8979 |
if (__isExternalAddress(windowID)) |
|
8980 |
ev.xselection.requestor = _WindowVal(windowID); |
|
8981 |
else |
|
8982 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
8983 |
ev.xselection.time = CurrentTime; |
|
8984 |
if (property == None) |
|
8985 |
ev.xselection.property = target; |
|
8986 |
else |
|
8987 |
ev.xselection.property = property; |
|
8988 |
||
8989 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
8990 |
ev.xselection.selection, |
|
8991 |
ev.xselection.property, |
|
8992 |
ev.xselection.target, |
|
8993 |
ev.xselection.requestor, |
|
8994 |
requestor)); |
|
8995 |
||
1974 | 8996 |
ENTER_XLIB(); |
1916 | 8997 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
1974 | 8998 |
LEAVE_XLIB(); |
8999 |
||
1916 | 9000 |
if ((result == BadValue) || (result == BadWindow)) { |
9001 |
DPRINTF(("bad status\n")); |
|
9002 |
RETURN (false); |
|
9003 |
} |
|
1974 | 9004 |
ENTER_XLIB(); |
1916 | 9005 |
XFlush(dpy); |
1974 | 9006 |
LEAVE_XLIB(); |
1916 | 9007 |
RETURN (true) |
382 | 9008 |
} |
9009 |
%}. |
|
9010 |
self primitiveFailed. |
|
9011 |
^ false |
|
295 | 9012 |
! |
9013 |
||
1344 | 9014 |
setSelection:anObject owner:aWindowId |
295 | 9015 |
"set the object selection, and make aWindowId be the owner. |
9016 |
This can be used by other Smalltalk(X) applications only." |
|
9017 |
||
9018 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 9019 |
^ false |
295 | 9020 |
]. |
9021 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
9022 |
^ true |
|
9023 |
! |
|
9024 |
||
1344 | 9025 |
setSelectionOwner:aWindowId of:selectionID |
295 | 9026 |
"set the owner of a selection; return false if failed" |
9027 |
||
9028 |
%{ /* NOCONTEXT */ |
|
9029 |
Window win; |
|
9030 |
||
9031 |
if (__isExternalAddress(aWindowId) |
|
9032 |
&& __isAtomID(selectionID) |
|
9033 |
&& ISCONNECTED) { |
|
1344 | 9034 |
Display *dpy = myDpy; |
9035 |
||
9036 |
win = _WindowVal(aWindowId); |
|
9037 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
9038 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
9039 |
RETURN (false); |
|
9040 |
} |
|
9041 |
RETURN (true); |
|
295 | 9042 |
} |
9043 |
%} |
|
9044 |
. |
|
9045 |
self primitiveFailed. |
|
9046 |
^ nil |
|
9047 |
! |
|
9048 |
||
1344 | 9049 |
setTextSelection:aString owner:aWindowId |
295 | 9050 |
"set the text selection, and make aWindowId be the owner. |
9051 |
This can be used by any other X application." |
|
9052 |
||
9053 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 9054 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 9055 |
]. |
9056 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9057 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9058 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 9059 |
! ! |
9060 |
||
9061 |
!XWorkstation methodsFor:'window stuff'! |
|
9062 |
||
1344 | 9063 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 9064 |
"clear a rectangular area to viewbackground" |
9065 |
||
9066 |
%{ /* NOCONTEXT */ |
|
9067 |
||
9068 |
int w, h; |
|
9069 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9070 |
if (ISCONNECTED) { |
1344 | 9071 |
if (__isExternalAddress(aWindowId) |
9072 |
&& __bothSmallInteger(x, y) |
|
9073 |
&& __bothSmallInteger(width, height)) { |
|
9074 |
w = __intVal(width); |
|
9075 |
h = __intVal(height); |
|
9076 |
/* |
|
9077 |
* need this check here: some servers simply dump core with bad args |
|
9078 |
*/ |
|
9079 |
if ((w >= 0) && (h >= 0)) { |
|
1974 | 9080 |
ENTER_XLIB(); |
1344 | 9081 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
1974 | 9082 |
LEAVE_XLIB(); |
1344 | 9083 |
} |
9084 |
RETURN ( self ); |
|
9085 |
} |
|
295 | 9086 |
} |
9087 |
%} |
|
9088 |
. |
|
9089 |
self primitiveFailed |
|
9090 |
! |
|
9091 |
||
1344 | 9092 |
clearWindow:aWindowId |
295 | 9093 |
"clear a window to viewbackground" |
9094 |
||
9095 |
%{ /* NOCONTEXT */ |
|
9096 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9097 |
if (ISCONNECTED) { |
1344 | 9098 |
if (__isExternalAddress(aWindowId)) { |
1974 | 9099 |
ENTER_XLIB(); |
1344 | 9100 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
1974 | 9101 |
LEAVE_XLIB(); |
1344 | 9102 |
RETURN ( self ); |
9103 |
} |
|
295 | 9104 |
} |
9105 |
%} |
|
9106 |
. |
|
9107 |
self primitiveFailed |
|
9108 |
! |
|
9109 |
||
1344 | 9110 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 9111 |
"configure stacking operation of aWindowId w.r.t siblingId" |
9112 |
||
9113 |
%{ /* NOCONTEXT */ |
|
9114 |
||
9115 |
XWindowChanges chg; |
|
9116 |
int mask = CWSibling | CWStackMode; |
|
9117 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9118 |
if (ISCONNECTED) { |
1344 | 9119 |
if (__isExternalAddress(aWindowId) |
9120 |
&& __isExternalAddress(siblingId)) { |
|
9121 |
if (modeSymbol == @symbol(above)) { |
|
9122 |
chg.stack_mode = Above; |
|
9123 |
} else if (modeSymbol == @symbol(below)) { |
|
9124 |
chg.stack_mode = Below; |
|
9125 |
} else if (modeSymbol == @symbol(topIf)) { |
|
9126 |
chg.stack_mode = TopIf; |
|
9127 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
9128 |
chg.stack_mode = BottomIf; |
|
9129 |
} else if (modeSymbol == @symbol(opposite)) { |
|
9130 |
chg.stack_mode = Opposite; |
|
9131 |
} else { |
|
9132 |
mask = CWSibling; |
|
9133 |
} |
|
9134 |
||
9135 |
chg.sibling = _WindowVal(siblingId); |
|
1974 | 9136 |
ENTER_XLIB(); |
1344 | 9137 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
9138 |
mask, &chg); |
|
1974 | 9139 |
LEAVE_XLIB(); |
1344 | 9140 |
RETURN ( self ); |
9141 |
} |
|
295 | 9142 |
} |
9143 |
bad: ; |
|
9144 |
%} |
|
9145 |
. |
|
9146 |
self primitiveFailed |
|
9147 |
! |
|
9148 |
||
1344 | 9149 |
lowerWindow:aWindowId |
295 | 9150 |
"bring a window to back" |
9151 |
||
9152 |
%{ /* NOCONTEXT */ |
|
9153 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9154 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9155 |
&& __isExternalAddress(aWindowId)) { |
1974 | 9156 |
ENTER_XLIB(); |
1344 | 9157 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
1974 | 9158 |
LEAVE_XLIB(); |
1344 | 9159 |
RETURN ( self ); |
295 | 9160 |
} |
9161 |
%} |
|
9162 |
. |
|
9163 |
self primitiveFailed |
|
9164 |
! |
|
9165 |
||
1344 | 9166 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 9167 |
"make a window visible - either as icon or as a real view - needed for restart" |
9168 |
||
9169 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
9170 |
||
9171 |
aBoolean ifTrue:[ |
|
1344 | 9172 |
wicon := aView icon. |
9173 |
wicon notNil ifTrue:[ |
|
9174 |
wiconId := wicon id |
|
9175 |
]. |
|
9176 |
wiconView := aView iconView. |
|
9177 |
wiconView notNil ifTrue:[ |
|
9178 |
wiconViewId := wiconView id |
|
9179 |
]. |
|
9180 |
wlabel := aView label. |
|
295 | 9181 |
]. |
9182 |
%{ |
|
9183 |
||
9184 |
XWMHints wmhints; |
|
9185 |
XSizeHints szhints; |
|
9186 |
Window win; |
|
9187 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9188 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9189 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9190 |
Display *dpy = myDpy; |
9191 |
||
9192 |
win = _WindowVal(aWindowId); |
|
9193 |
||
9194 |
szhints.flags = 0; |
|
9195 |
if (__bothSmallInteger(xPos, yPos)) { |
|
9196 |
szhints.x = __intVal(xPos); |
|
9197 |
szhints.y = __intVal(yPos); |
|
9198 |
szhints.flags |= USPosition; |
|
9199 |
} |
|
9200 |
if (__bothSmallInteger(w, h)) { |
|
9201 |
szhints.width = __intVal(w); |
|
9202 |
szhints.height = __intVal(h); |
|
9203 |
szhints.flags |= USSize; |
|
9204 |
} |
|
9205 |
||
9206 |
if (aBoolean == true) { |
|
9207 |
char *windowName; |
|
9208 |
Pixmap iconBitmap = (Pixmap)0; |
|
9209 |
Window iconWindow; |
|
9210 |
||
9211 |
if (__isExternalAddress(wiconId)) |
|
9212 |
iconBitmap = _PixmapVal(wiconId); |
|
9213 |
else |
|
9214 |
iconBitmap = (Pixmap)0; |
|
9215 |
||
9216 |
if (__isExternalAddress(wiconViewId)) |
|
9217 |
iconWindow = _WindowVal(wiconViewId); |
|
9218 |
else |
|
9219 |
iconWindow = (Window)0; |
|
9220 |
||
9221 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1831 | 9222 |
windowName = (char *) __stringVal(wlabel); |
1344 | 9223 |
else |
9224 |
windowName = ""; |
|
9225 |
||
9226 |
if (iconBitmap || windowName) { |
|
1974 | 9227 |
ENTER_XLIB(); |
1344 | 9228 |
XSetStandardProperties(dpy, win, |
9229 |
windowName, windowName, |
|
9230 |
iconBitmap, |
|
9231 |
0, 0, &szhints); |
|
1974 | 9232 |
LEAVE_XLIB(); |
1344 | 9233 |
} |
9234 |
||
9235 |
wmhints.flags = 0; |
|
9236 |
if (iconBitmap) { |
|
9237 |
wmhints.flags |= IconPixmapHint; |
|
9238 |
wmhints.icon_pixmap = iconBitmap; |
|
9239 |
} |
|
9240 |
if (iconWindow) { |
|
9241 |
wmhints.flags |= IconWindowHint; |
|
9242 |
wmhints.icon_window = iconWindow; |
|
9243 |
} |
|
9244 |
||
9245 |
wmhints.initial_state = IconicState; |
|
9246 |
wmhints.flags |= StateHint; |
|
1974 | 9247 |
ENTER_XLIB(); |
1344 | 9248 |
XSetWMHints(dpy, win, &wmhints); |
1974 | 9249 |
LEAVE_XLIB(); |
1344 | 9250 |
} |
9251 |
||
9252 |
if (szhints.flags) { |
|
1974 | 9253 |
ENTER_XLIB(); |
1344 | 9254 |
XSetNormalHints(dpy, win, &szhints); |
1974 | 9255 |
LEAVE_XLIB(); |
9256 |
} |
|
9257 |
||
9258 |
ENTER_XLIB(); |
|
1344 | 9259 |
XMapWindow(dpy, win); |
1974 | 9260 |
LEAVE_XLIB(); |
1344 | 9261 |
RETURN ( self ); |
295 | 9262 |
} |
9263 |
%} |
|
9264 |
. |
|
9265 |
self primitiveFailed |
|
9266 |
! |
|
9267 |
||
1344 | 9268 |
mapWindow:aWindowId |
295 | 9269 |
"make a window visible" |
9270 |
||
9271 |
%{ /* NOCONTEXT */ |
|
9272 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9273 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9274 |
&& __isExternalAddress(aWindowId)) { |
1974 | 9275 |
ENTER_XLIB(); |
1344 | 9276 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
1974 | 9277 |
LEAVE_XLIB(); |
1344 | 9278 |
RETURN ( self ); |
295 | 9279 |
} |
9280 |
%} |
|
9281 |
. |
|
9282 |
self primitiveFailed |
|
9283 |
! |
|
9284 |
||
1344 | 9285 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 9286 |
"move and resize a window" |
9287 |
||
9288 |
%{ /* NOCONTEXT */ |
|
9289 |
||
9290 |
int newWidth, newHeight; |
|
9291 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9292 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9293 |
&& __isExternalAddress(aWindowId) |
295 | 9294 |
&& __bothSmallInteger(w, h) |
9295 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 9296 |
newWidth = __intVal(w); |
9297 |
newHeight = __intVal(h); |
|
9298 |
if (newWidth < 1) newWidth = 1; |
|
9299 |
if (newHeight < 1) newHeight = 1; |
|
1974 | 9300 |
ENTER_XLIB(); |
1344 | 9301 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
9302 |
__intVal(x), __intVal(y), |
|
9303 |
newWidth, newHeight); |
|
1974 | 9304 |
LEAVE_XLIB(); |
1344 | 9305 |
RETURN ( self ); |
295 | 9306 |
} |
9307 |
%} |
|
9308 |
. |
|
9309 |
self primitiveFailed |
|
9310 |
! |
|
9311 |
||
1344 | 9312 |
moveWindow:aWindowId x:x y:y |
295 | 9313 |
"move a window" |
9314 |
||
9315 |
%{ /* NOCONTEXT */ |
|
9316 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9317 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9318 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1974 | 9319 |
ENTER_XLIB(); |
1344 | 9320 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
1974 | 9321 |
LEAVE_XLIB(); |
1344 | 9322 |
RETURN ( self ); |
295 | 9323 |
} |
9324 |
%} |
|
9325 |
. |
|
9326 |
self primitiveFailed |
|
9327 |
! |
|
9328 |
||
1344 | 9329 |
raiseWindow:aWindowId |
295 | 9330 |
"bring a window to front" |
9331 |
||
9332 |
%{ /* NOCONTEXT */ |
|
9333 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9334 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9335 |
&& __isExternalAddress(aWindowId)) { |
1974 | 9336 |
ENTER_XLIB(); |
1344 | 9337 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
1974 | 9338 |
LEAVE_XLIB(); |
1344 | 9339 |
RETURN ( self ); |
295 | 9340 |
} |
9341 |
%} |
|
9342 |
. |
|
9343 |
self primitiveFailed |
|
9344 |
! |
|
9345 |
||
1344 | 9346 |
resizeWindow:aWindowId width:w height:h |
295 | 9347 |
"resize a window" |
9348 |
||
9349 |
%{ /* NOCONTEXT */ |
|
9350 |
||
9351 |
int newWidth, newHeight; |
|
9352 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9353 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9354 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 9355 |
newWidth = __intVal(w); |
9356 |
newHeight = __intVal(h); |
|
9357 |
if (newWidth < 1) newWidth = 1; |
|
9358 |
if (newHeight < 1) newHeight = 1; |
|
1974 | 9359 |
ENTER_XLIB(); |
1344 | 9360 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
1974 | 9361 |
LEAVE_XLIB(); |
1344 | 9362 |
RETURN ( self ); |
295 | 9363 |
} |
9364 |
%} |
|
9365 |
. |
|
9366 |
self primitiveFailed |
|
9367 |
! |
|
9368 |
||
1344 | 9369 |
setBackingStore:how in:aWindowId |
295 | 9370 |
"turn on/off backing-store for a window" |
9371 |
||
9372 |
%{ /* NOCONTEXT */ |
|
9373 |
||
9374 |
XSetWindowAttributes wa; |
|
9375 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9376 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9377 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9378 |
if (__INST(ignoreBackingStore) != true) { |
9379 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
9380 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
9381 |
else if (how == true) wa.backing_store = Always; |
|
9382 |
else wa.backing_store = 0; |
|
9383 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 9384 |
ENTER_XLIB(); |
1344 | 9385 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
1974 | 9386 |
LEAVE_XLIB(); |
1344 | 9387 |
END_INTERRUPTSBLOCKED |
9388 |
} |
|
9389 |
RETURN ( self ); |
|
295 | 9390 |
} |
9391 |
%}. |
|
9392 |
self primitiveFailed |
|
9393 |
! |
|
9394 |
||
1344 | 9395 |
setBitGravity:how in:aWindowId |
295 | 9396 |
"set bit gravity for a window" |
9397 |
||
9398 |
%{ /* NOCONTEXT */ |
|
9399 |
||
9400 |
XSetWindowAttributes wa; |
|
9401 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9402 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9403 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9404 |
if (how == @symbol(NorthWest)) { |
9405 |
wa.bit_gravity = NorthWestGravity; |
|
9406 |
} else if (how == @symbol(NorthEast)) { |
|
9407 |
wa.bit_gravity = NorthEastGravity; |
|
9408 |
} else if (how == @symbol(SouthWest)) { |
|
9409 |
wa.bit_gravity = SouthWestGravity; |
|
9410 |
} else if (how == @symbol(SouthEast)) { |
|
9411 |
wa.bit_gravity = SouthEastGravity; |
|
9412 |
} else if (how == @symbol(Center)) { |
|
9413 |
wa.bit_gravity = CenterGravity; |
|
9414 |
} else if (how == @symbol(North)) { |
|
9415 |
wa.bit_gravity = NorthGravity; |
|
9416 |
} else if (how == @symbol(South)) { |
|
9417 |
wa.bit_gravity = SouthGravity; |
|
9418 |
} else if (how == @symbol(West)) { |
|
9419 |
wa.bit_gravity = WestGravity; |
|
9420 |
} else if (how == @symbol(East)) { |
|
9421 |
wa.bit_gravity = EastGravity; |
|
9422 |
} else { |
|
9423 |
wa.bit_gravity = NorthWestGravity; |
|
9424 |
} |
|
9425 |
||
9426 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 9427 |
ENTER_XLIB(); |
1344 | 9428 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
1974 | 9429 |
LEAVE_XLIB(); |
1344 | 9430 |
END_INTERRUPTSBLOCKED |
9431 |
RETURN ( self ); |
|
295 | 9432 |
} |
9433 |
%}. |
|
9434 |
self primitiveFailed |
|
9435 |
! |
|
9436 |
||
1344 | 9437 |
setCursor:aCursorId in:aWindowId |
295 | 9438 |
"define a windows cursor" |
9439 |
||
9440 |
%{ /* NOCONTEXT */ |
|
9441 |
||
9442 |
Display *dpy = myDpy; |
|
9443 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9444 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9445 |
&& __isExternalAddress(aWindowId) |
295 | 9446 |
&& __isExternalAddress(aCursorId)) { |
1974 | 9447 |
ENTER_XLIB(); |
1344 | 9448 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
1974 | 9449 |
LEAVE_XLIB(); |
1344 | 9450 |
RETURN ( self ); |
295 | 9451 |
} |
9452 |
%}. |
|
9453 |
self primitiveFailed |
|
9454 |
! |
|
9455 |
||
1344 | 9456 |
setIconName:aString in:aWindowId |
295 | 9457 |
"define a windows iconname" |
9458 |
||
9459 |
%{ /* NOCONTEXT */ |
|
9460 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9461 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9462 |
&& __isExternalAddress(aWindowId) |
295 | 9463 |
&& (__isString(aString) || __isSymbol(aString))) { |
1974 | 9464 |
ENTER_XLIB(); |
1831 | 9465 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString)); |
1974 | 9466 |
LEAVE_XLIB(); |
1344 | 9467 |
RETURN ( self ); |
295 | 9468 |
} |
9469 |
%}. |
|
9470 |
self primitiveFailed |
|
9471 |
! |
|
9472 |
||
1344 | 9473 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 9474 |
"turn on/off save-under for a window" |
9475 |
||
9476 |
%{ /* NOCONTEXT */ |
|
9477 |
||
9478 |
XSetWindowAttributes wa; |
|
9479 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9480 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9481 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9482 |
if (__INST(hasSaveUnder) == true) { |
9483 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
1974 | 9484 |
ENTER_XLIB(); |
1344 | 9485 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
1974 | 9486 |
LEAVE_XLIB(); |
1344 | 9487 |
} |
9488 |
RETURN ( self ); |
|
295 | 9489 |
} |
9490 |
%}. |
|
9491 |
self primitiveFailed |
|
9492 |
! |
|
9493 |
||
1344 | 9494 |
setTransient:aWindowId for:aMainWindowId |
295 | 9495 |
"set aWindowId to be a transient of aMainWindow" |
9496 |
||
9497 |
%{ /* NOCONTEXT */ |
|
9498 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9499 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9500 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9501 |
Window w; |
9502 |
||
9503 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
9504 |
w = (Window) 0; |
|
9505 |
} else { |
|
9506 |
if (__isExternalAddress(aMainWindowId)) { |
|
9507 |
w = _WindowVal(aMainWindowId); |
|
9508 |
} else { |
|
9509 |
goto getOutOfHere; |
|
9510 |
} |
|
9511 |
} |
|
1974 | 9512 |
ENTER_XLIB(); |
1344 | 9513 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
1974 | 9514 |
LEAVE_XLIB(); |
1344 | 9515 |
RETURN ( self ); |
295 | 9516 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
9517 |
getOutOfHere: ; |
295 | 9518 |
%}. |
9519 |
self primitiveFailed |
|
9520 |
! |
|
9521 |
||
1344 | 9522 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 9523 |
"set the windows background color. This is the color with which |
9524 |
the view is filled whenever exposed. Do not confuse this with |
|
9525 |
the background drawing color, which is used with opaque drawing." |
|
9526 |
||
9527 |
%{ /* NOCONTEXT */ |
|
9528 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9529 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9530 |
&& __isExternalAddress(aWindowId) |
295 | 9531 |
&& __isSmallInteger(aColorIndex)) { |
1974 | 9532 |
ENTER_XLIB(); |
1344 | 9533 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
1974 | 9534 |
LEAVE_XLIB(); |
1344 | 9535 |
RETURN ( self ); |
295 | 9536 |
} |
9537 |
%}. |
|
9538 |
self primitiveFailed |
|
9539 |
! |
|
9540 |
||
1344 | 9541 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 9542 |
"set the windows background pattern to be a form. |
9543 |
This is the pattern with which the view is filled whenever exposed. |
|
9544 |
Do not confuse this with the background drawing color, which is used |
|
9545 |
with opaque drawing." |
|
9546 |
||
9547 |
%{ /* NOCONTEXT */ |
|
9548 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9549 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9550 |
&& __isExternalAddress(aWindowId) |
295 | 9551 |
&& __isExternalAddress(aPixmapId)) { |
1974 | 9552 |
ENTER_XLIB(); |
1344 | 9553 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
1974 | 9554 |
LEAVE_XLIB(); |
1344 | 9555 |
RETURN ( self ); |
295 | 9556 |
} |
9557 |
%}. |
|
9558 |
self primitiveFailed |
|
9559 |
! |
|
9560 |
||
1344 | 9561 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 9562 |
"set the windows border color" |
9563 |
||
9564 |
%{ /* NOCONTEXT */ |
|
9565 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9566 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9567 |
&& __isExternalAddress(aWindowId) |
295 | 9568 |
&& __isSmallInteger(aColorIndex)) { |
1974 | 9569 |
ENTER_XLIB(); |
1344 | 9570 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
1974 | 9571 |
LEAVE_XLIB(); |
1344 | 9572 |
RETURN ( self ); |
295 | 9573 |
} |
9574 |
%}. |
|
9575 |
self primitiveFailed |
|
9576 |
! |
|
9577 |
||
1344 | 9578 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 9579 |
"set the windows border pattern" |
9580 |
||
9581 |
%{ /* NOCONTEXT */ |
|
9582 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9583 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9584 |
&& __isExternalAddress(aWindowId) |
295 | 9585 |
&& __isExternalAddress(aPixmapId)) { |
1974 | 9586 |
ENTER_XLIB(); |
1344 | 9587 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
1974 | 9588 |
LEAVE_XLIB(); |
1344 | 9589 |
RETURN ( self ); |
295 | 9590 |
} |
9591 |
%} |
|
9592 |
. |
|
9593 |
self primitiveFailed |
|
9594 |
! |
|
9595 |
||
1344 | 9596 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 9597 |
"set the windows border shape" |
9598 |
||
9599 |
hasShapeExtension ifFalse:[^ self]. |
|
9600 |
||
9601 |
%{ /* NOCONTEXT */ |
|
9602 |
||
9603 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9604 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9605 |
&& __isExternalAddress(aWindowId) |
295 | 9606 |
&& __isExternalAddress(aPixmapId)) { |
1974 | 9607 |
ENTER_XLIB(); |
1344 | 9608 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
9609 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
1974 | 9610 |
LEAVE_XLIB(); |
1344 | 9611 |
RETURN ( self ); |
295 | 9612 |
} |
9613 |
#endif |
|
9614 |
%}. |
|
9615 |
self primitiveFailed |
|
9616 |
! |
|
9617 |
||
1344 | 9618 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 9619 |
"set the windows border width" |
9620 |
||
9621 |
%{ /* NOCONTEXT */ |
|
9622 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9623 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9624 |
&& __isExternalAddress(aWindowId) |
295 | 9625 |
&& __isSmallInteger(aNumber)) { |
1974 | 9626 |
ENTER_XLIB(); |
1344 | 9627 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
1974 | 9628 |
LEAVE_XLIB(); |
1344 | 9629 |
RETURN ( self ); |
295 | 9630 |
} |
9631 |
%}. |
|
9632 |
self primitiveFailed |
|
9633 |
! |
|
9634 |
||
1344 | 9635 |
setWindowClass:wClass name:wName in:aWindowId |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9636 |
"define class and name of a window. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9637 |
This may be used by the window manager to |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9638 |
select client specific resources." |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9639 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9640 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9641 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9642 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9643 |
XClassHint classhint; |
9644 |
||
9645 |
classhint.res_class = classhint.res_name = 0; |
|
9646 |
||
9647 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
1831 | 9648 |
classhint.res_class = (char *) __stringVal(wClass); |
1344 | 9649 |
} else if (wClass != nil) |
9650 |
goto error; |
|
9651 |
||
9652 |
if (__isString(wName) || __isSymbol(wName)) { |
|
1831 | 9653 |
classhint.res_name = (char *) __stringVal(wName); |
1344 | 9654 |
} else if (wName != nil) |
9655 |
goto error; |
|
9656 |
||
1974 | 9657 |
ENTER_XLIB(); |
1344 | 9658 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
1974 | 9659 |
LEAVE_XLIB(); |
1344 | 9660 |
RETURN ( self ); |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9661 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9662 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9663 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9664 |
self primitiveFailed |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9665 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9666 |
|
1344 | 9667 |
setWindowGravity:how in:aWindowId |
295 | 9668 |
"set window gravity for a window" |
9669 |
||
9670 |
%{ /* NOCONTEXT */ |
|
9671 |
||
9672 |
XSetWindowAttributes wa; |
|
9673 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9674 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9675 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9676 |
if (how == @symbol(NorthWest)) { |
9677 |
wa.win_gravity = NorthWestGravity; |
|
9678 |
} else if (how == @symbol(NorthEast)) { |
|
9679 |
wa.win_gravity = NorthEastGravity; |
|
9680 |
} else if (how == @symbol(SouthWest)) { |
|
9681 |
wa.win_gravity = SouthWestGravity; |
|
9682 |
} else if (how == @symbol(SouthEast)) { |
|
9683 |
wa.win_gravity = SouthEastGravity; |
|
9684 |
} else if (how == @symbol(Center)) { |
|
9685 |
wa.win_gravity = CenterGravity; |
|
9686 |
} else if (how == @symbol(North)) { |
|
9687 |
wa.win_gravity = NorthGravity; |
|
9688 |
} else if (how == @symbol(South)) { |
|
9689 |
wa.win_gravity = SouthGravity; |
|
9690 |
} else if (how == @symbol(West)) { |
|
9691 |
wa.win_gravity = WestGravity; |
|
9692 |
} else if (how == @symbol(East)) { |
|
9693 |
wa.win_gravity = EastGravity; |
|
9694 |
} else { |
|
9695 |
wa.win_gravity = NorthWestGravity; |
|
9696 |
} |
|
9697 |
||
9698 |
BEGIN_INTERRUPTSBLOCKED |
|
1974 | 9699 |
ENTER_XLIB(); |
1344 | 9700 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
1974 | 9701 |
LEAVE_XLIB(); |
1344 | 9702 |
END_INTERRUPTSBLOCKED |
9703 |
RETURN ( self ); |
|
295 | 9704 |
} |
9705 |
%}. |
|
9706 |
self primitiveFailed |
|
9707 |
! |
|
9708 |
||
1344 | 9709 |
setWindowIcon:aForm in:aWindowId |
295 | 9710 |
"define a bitmap to be used as icon" |
9711 |
||
9712 |
|iconId| |
|
9713 |
||
9714 |
aForm notNil ifTrue:[ |
|
1344 | 9715 |
iconId := aForm id |
295 | 9716 |
]. |
9717 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9718 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9719 |
&& __isExternalAddress(iconId) |
295 | 9720 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9721 |
XWMHints hints; |
9722 |
||
9723 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
9724 |
hints.flags = IconPixmapHint; |
|
1974 | 9725 |
ENTER_XLIB(); |
1344 | 9726 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
1974 | 9727 |
LEAVE_XLIB(); |
1344 | 9728 |
RETURN ( self ); |
295 | 9729 |
} |
9730 |
%}. |
|
9731 |
self primitiveFailed |
|
9732 |
! |
|
9733 |
||
1376 | 9734 |
setWindowIcon:aForm mask:aMaskForm in:aWindowId |
1535 | 9735 |
"define a windows icon and (optional) iconMask." |
9736 |
||
9737 |
|iconId maskId| |
|
9738 |
||
9739 |
aForm notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9740 |
iconId := aForm id |
1535 | 9741 |
]. |
9742 |
aMaskForm notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9743 |
maskId := aMaskForm id. |
1535 | 9744 |
]. |
9745 |
%{ |
|
9746 |
if (ISCONNECTED |
|
9747 |
&& __isExternalAddress(iconId) |
|
9748 |
&& __isExternalAddress(aWindowId)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9749 |
XWMHints hints; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9750 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9751 |
hints.icon_pixmap = _PixmapVal(iconId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9752 |
hints.flags = IconPixmapHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9753 |
if ((maskId != nil) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9754 |
&& __isExternalAddress(maskId)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9755 |
hints.icon_mask = _PixmapVal(maskId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9756 |
hints.flags |= IconMaskHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9757 |
} |
1974 | 9758 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9759 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
1974 | 9760 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9761 |
RETURN ( self ); |
1535 | 9762 |
} |
9763 |
%}. |
|
9764 |
self primitiveFailed |
|
9765 |
||
1376 | 9766 |
! |
9767 |
||
1344 | 9768 |
setWindowIconWindow:aView in:aWindowId |
295 | 9769 |
"define a window to be used as icon" |
9770 |
||
9771 |
|iconWindowId| |
|
9772 |
||
9773 |
aView notNil ifTrue:[ |
|
1344 | 9774 |
iconWindowId := aView id |
295 | 9775 |
]. |
9776 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9777 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9778 |
&& __isExternalAddress(iconWindowId) |
295 | 9779 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9780 |
XWMHints wmhints; |
9781 |
||
9782 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
9783 |
wmhints.flags = IconWindowHint; |
|
1974 | 9784 |
ENTER_XLIB(); |
1344 | 9785 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
1974 | 9786 |
LEAVE_XLIB(); |
1344 | 9787 |
RETURN ( self ); |
295 | 9788 |
} |
9789 |
%}. |
|
9790 |
self primitiveFailed |
|
9791 |
! |
|
9792 |
||
1344 | 9793 |
setWindowName:aString in:aWindowId |
295 | 9794 |
"define a windows name" |
9795 |
||
9796 |
%{ /* NOCONTEXT */ |
|
9797 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9798 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9799 |
&& __isExternalAddress(aWindowId) |
295 | 9800 |
&& (__isString(aString) || __isSymbol(aString))) { |
1974 | 9801 |
ENTER_XLIB(); |
1831 | 9802 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString)); |
1974 | 9803 |
LEAVE_XLIB(); |
1344 | 9804 |
RETURN ( self ); |
295 | 9805 |
} |
9806 |
%}. |
|
9807 |
self primitiveFailed |
|
9808 |
! |
|
9809 |
||
1344 | 9810 |
setWindowShape:aPixmapId in:aWindowId |
295 | 9811 |
"set the windows shape" |
9812 |
||
9813 |
hasShapeExtension ifFalse:[^ self]. |
|
9814 |
||
9815 |
%{ /* NOCONTEXT */ |
|
9816 |
||
9817 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9818 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9819 |
&& __isExternalAddress(aWindowId) |
295 | 9820 |
&& __isExternalAddress(aPixmapId)) { |
1974 | 9821 |
ENTER_XLIB(); |
1344 | 9822 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
9823 |
0, 0, |
|
9824 |
_PixmapVal(aPixmapId), ShapeSet); |
|
1974 | 9825 |
LEAVE_XLIB(); |
1344 | 9826 |
RETURN ( self ); |
295 | 9827 |
} |
9828 |
#endif |
|
9829 |
%}. |
|
9830 |
self primitiveFailed |
|
9831 |
! |
|
9832 |
||
1344 | 9833 |
unmapWindow:aWindowId |
295 | 9834 |
"make a window invisible" |
9835 |
||
9836 |
%{ /* NOCONTEXT */ |
|
9837 |
||
1214 | 9838 |
if (!ISCONNECTED) { |
1344 | 9839 |
RETURN ( self ); |
1214 | 9840 |
} |
9841 |
||
9842 |
if (__isExternalAddress(aWindowId)) { |
|
1974 | 9843 |
ENTER_XLIB(); |
1344 | 9844 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
1974 | 9845 |
LEAVE_XLIB(); |
1344 | 9846 |
RETURN ( self ); |
9847 |
} |
|
9848 |
%}. |
|
295 | 9849 |
self primitiveFailed |
1535 | 9850 |
! |
9851 |
||
9852 |
windowIsIconified:aWindowId |
|
9853 |
"return true, if some window is iconified. |
|
9854 |
The passed windowID may be an alien windows id." |
|
9855 |
||
9856 |
%{ /* NOCONTEXT */ |
|
9857 |
||
9858 |
if (ISCONNECTED |
|
9859 |
&& __isExternalAddress(aWindowId)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9860 |
Atom JunkAtom; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9861 |
int JunkInt; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9862 |
unsigned long WinState,JunkLong; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9863 |
unsigned char *Property; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9864 |
Atom WM_STATE_Atom; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9865 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9866 |
if (__INST(wmStateAtom) != nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9867 |
WM_STATE_Atom = _AtomVal(__INST(wmStateAtom)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9868 |
|
1974 | 9869 |
ENTER_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9870 |
XGetWindowProperty(myDpy, _WindowVal(aWindowId), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9871 |
WM_STATE_Atom, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9872 |
0L, 2L, False, AnyPropertyType, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9873 |
&JunkAtom,&JunkInt,&WinState,&JunkLong, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9874 |
&Property); |
1974 | 9875 |
LEAVE_XLIB(); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9876 |
WinState=(unsigned long)(*((long*)Property)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9877 |
if (WinState==3) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9878 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9879 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9880 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9881 |
RETURN (false); |
1535 | 9882 |
} |
9883 |
%}. |
|
9884 |
self primitiveFailed |
|
9885 |
||
9886 |
||
9887 |
||
295 | 9888 |
! ! |
9889 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9890 |
!XWorkstation class methodsFor:'documentation'! |
295 | 9891 |
|
9892 |
version |
|
1990 | 9893 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.272 1998-01-19 19:13:02 cg Exp $' |
295 | 9894 |
! ! |
9895 |
XWorkstation initialize! |