author | Claus Gittinger <cg@exept.de> |
Mon, 21 Jul 1997 11:30:29 +0200 | |
changeset 1813 | 2622c38573df |
parent 1798 | fcbbdcbd5870 |
child 1831 | 8a03aa87a0ee |
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 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
22 |
multiClickTime deviceErrorSignal deviceIOErrorSignal' |
1344 | 23 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
24 |
poolDictionaries:'' |
|
25 |
category:'Interface-Graphics' |
|
295 | 26 |
! |
0 | 27 |
|
78 | 28 |
!XWorkstation primitiveDefinitions! |
0 | 29 |
%{ |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
30 |
|
1062 | 31 |
#ifdef LINUX |
32 |
# define SHM |
|
33 |
#endif |
|
34 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
35 |
#define COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
36 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
37 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
38 |
static int __cnt_color = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
39 |
static int __cnt_bitmap = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
40 |
static int __cnt_view = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
41 |
static int __cnt_gc = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
42 |
static int __cnt_cursor = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
43 |
static int __cnt_font = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
44 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
45 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
46 |
|
46 | 47 |
/* |
48 |
* x does a typedef Time - I need Object Time ... |
|
49 |
*/ |
|
0 | 50 |
#define Time XTime |
51 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
52 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
53 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
54 |
* 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
|
55 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
56 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
57 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
58 |
|
37 | 59 |
#ifdef memset |
60 |
# undef memset |
|
61 |
#endif |
|
62 |
||
0 | 63 |
#include <stdio.h> |
64 |
#include <X11/Xlib.h> |
|
65 |
#include <X11/Xutil.h> |
|
66 |
#include <X11/Xatom.h> |
|
67 |
||
150 | 68 |
#define XK_MISCELLANY |
69 |
#include <X11/keysymdef.h> |
|
70 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
71 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
72 |
|
90 | 73 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
74 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
75 |
* 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
|
76 |
* 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
|
77 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
78 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
79 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
80 |
/* |
0 | 81 |
* shape support works; enabled by -DSHAPE in makefile |
82 |
* see RoundClock and RoundGlobe examples |
|
83 |
*/ |
|
84 |
#ifdef SHAPE |
|
85 |
# include <X11/extensions/shape.h> |
|
86 |
#endif |
|
87 |
||
88 |
/* |
|
150 | 89 |
* shared memory extension access is currently not supported |
0 | 90 |
* (only query is implemented) |
91 |
*/ |
|
92 |
#ifdef SHM |
|
93 |
# include <X11/extensions/XShm.h> |
|
94 |
#endif |
|
95 |
||
96 |
/* |
|
150 | 97 |
* multiBuffer extension access is currently not supported |
98 |
* (only query is implemented) |
|
99 |
*/ |
|
100 |
#ifdef MBUF |
|
101 |
# include <X11/extensions/multibuf.h> |
|
102 |
#endif |
|
103 |
||
104 |
/* |
|
105 |
* XVideo extension access is currently not supported |
|
106 |
* (only query is implemented) |
|
107 |
*/ |
|
108 |
#ifdef XVIDEO |
|
109 |
# include <X11/extensions/Xv.h> |
|
110 |
#endif |
|
111 |
||
112 |
/* |
|
186 | 113 |
* PEX extension - if available |
114 |
*/ |
|
115 |
#ifdef PEX5 |
|
116 |
# include <PEX5/PEX.h> |
|
117 |
#endif |
|
118 |
||
119 |
/* |
|
120 |
* XImage extension - if available |
|
121 |
*/ |
|
122 |
#ifdef XIE |
|
123 |
# include <X11/extensions/XIE.h> |
|
124 |
#endif |
|
125 |
||
126 |
/* |
|
90 | 127 |
* when I have more time to check it out, I will support display-PS |
0 | 128 |
*/ |
129 |
#ifdef DPS |
|
130 |
# ifdef sgi |
|
131 |
# include <X11/extensions/XDPS.h> |
|
132 |
# include <X11/extensions/XDPSlib.h> |
|
133 |
# include <X11/extensions/dpsXclient.h> |
|
134 |
# else |
|
135 |
# include <DPS/XDPS.h> |
|
136 |
# include <DPS/XDPSlib.h> |
|
137 |
# include <DPS/dpsXclient.h> |
|
138 |
# endif |
|
139 |
#endif |
|
140 |
||
90 | 141 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
142 |
/* |
|
143 |
* accessing private data in Display ... sorry |
|
144 |
*/ |
|
145 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
146 |
#else |
|
147 |
# define DISPLAYACCESS(d) d |
|
148 |
#endif |
|
149 |
||
78 | 150 |
/* |
151 |
* some defines - tired of typing ... |
|
152 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
153 |
#define _DisplayVal(o) (Display *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
154 |
#define _WindowVal(o) (Window)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
155 |
#define _PixmapVal(o) (Pixmap)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
156 |
#define _GCVal(o) (GC)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
157 |
#define _CursorVal(o) (Cursor)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
158 |
#define _FontVal(o) (XFontStruct *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
159 |
#define _DPSContextVal(o) (DPSContext)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
160 |
|
211 | 161 |
#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
|
162 |
#define _AtomVal(o) __intVal(o) |
211 | 163 |
#define __isAtomID(o) __isSmallInteger(o) |
164 |
||
555 | 165 |
#define myDpy _DisplayVal(__INST(displayId)) |
166 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 167 |
|
168 |
#ifndef THISCONTEXT_IN_REGISTER |
|
1098 | 169 |
|
78 | 170 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
171 |
# define END_INTERRUPTSBLOCKED /* */ |
|
1098 | 172 |
|
78 | 173 |
#else |
1098 | 174 |
|
78 | 175 |
# define BEGIN_INTERRUPTSBLOCKED \ |
176 |
{ \ |
|
1344 | 177 |
int needUnblock = 0; \ |
178 |
\ |
|
179 |
__BEGIN_PROTECT_REGISTERS__ \ |
|
180 |
if (!__interruptsBlocked) { \ |
|
181 |
__BLOCKINTERRUPTS(); \ |
|
182 |
needUnblock = 1; \ |
|
183 |
} |
|
78 | 184 |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
185 |
# define END_INTERRUPTSBLOCKED_NOW \ |
1344 | 186 |
__END_PROTECT_REGISTERS__ \ |
187 |
if (needUnblock) { \ |
|
188 |
__UNBLOCKINTERRUPTS(); \ |
|
189 |
} \ |
|
78 | 190 |
} |
191 |
||
1103
8378530a4e8d
XShmQueryExtension -> XQueryExtension
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
192 |
# define END_INTERRUPTSBLOCKED \ |
1344 | 193 |
__END_PROTECT_REGISTERS__ |
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
194 |
|
78 | 195 |
#endif |
196 |
%} |
|
197 |
! ! |
|
198 |
||
199 |
!XWorkstation primitiveVariables! |
|
200 |
%{ |
|
0 | 201 |
/* |
146 | 202 |
* remembered info from private error handler |
0 | 203 |
*/ |
2 | 204 |
static char lastErrorMsg[80] = ""; |
205 |
static unsigned lastRequestCode = 0; |
|
206 |
static unsigned lastMinorCode = 0; |
|
207 |
static unsigned lastResource = 0; |
|
129 | 208 |
|
209 |
static int __debug__ = 0; |
|
210 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 211 |
%} |
212 |
! ! |
|
213 |
||
214 |
!XWorkstation primitiveFunctions! |
|
215 |
%{ |
|
1062 | 216 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
217 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
218 |
* 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
|
219 |
* to include that stuff. Should be #ifdef'd ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
220 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
221 |
#ifndef ELF |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
222 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
223 |
# ifdef __GNUC__ |
1081 | 224 |
VOLATILE |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
225 |
# endif |
1081 | 226 |
static |
1062 | 227 |
dummyToForceLoading() { |
1344 | 228 |
XCreateSimpleWindow(0, 0, 0, 0, 0, 0, 0, 0, 0); |
229 |
XCloseDisplay(0); |
|
230 |
XCreateImage(0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0); |
|
231 |
XSetWindowColormap(0, 0, 0); |
|
232 |
XQueryColors(0,0,0,0); |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
233 |
# ifdef SHM |
1344 | 234 |
XShmAttach(0, 0); |
235 |
XShmCreateImage(0, 0, 0, 0, 0, 0, 0 ,0); |
|
236 |
XShmDetach(0, 0); |
|
237 |
XShmPutImage(0, 0, 0, 0 , 0,0,0,0,0,0,0); |
|
238 |
shmctl(0,0,0); |
|
239 |
fgetc(0); |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
240 |
# endif |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
241 |
} |
1062 | 242 |
#endif |
243 |
||
18 | 244 |
/* |
144 | 245 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
246 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 247 |
* the implementation below is somewhat wrong: it will |
78 | 248 |
* report all errors for Display, even though there could be |
162 | 249 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
250 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 251 |
*/ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
252 |
|
12 | 253 |
__XErrorHandler__(dpy, event) |
0 | 254 |
Display *dpy; |
255 |
XErrorEvent *event; |
|
256 |
{ |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
257 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 79); |
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
258 |
lastErrorMsg[79] = '\0'; |
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
259 |
|
0 | 260 |
if (lastErrorMsg[0] == '\0') { |
1344 | 261 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 262 |
} |
2 | 263 |
lastRequestCode = event->request_code; |
264 |
lastMinorCode = event->minor_code; |
|
265 |
lastResource = event->resourceid; |
|
911 | 266 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
1344 | 267 |
/* |
268 |
* this is a BadWindow error for X_DestroyWindow. |
|
269 |
* ignore it here, since it results from the GC freeing windows |
|
270 |
* in non bottom-up window order. |
|
271 |
*/ |
|
272 |
return 0; |
|
911 | 273 |
} |
2 | 274 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
275 |
if (@global(ErrorPrinting) == true) { |
1753 | 276 |
fprintf(stderr, "XWorkstation [error]: x-error caught maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
1344 | 277 |
event->request_code, event->request_code, |
278 |
event->minor_code, event->minor_code, event->resourceid); |
|
279 |
fprintf(stderr, "XWorkstation [error]: x-error message is [%d] '%s'\n", event->error_code, lastErrorMsg); |
|
218
10072d9beba5
can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
280 |
} |
43 | 281 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
282 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 283 |
return 0; |
284 |
} |
|
285 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
286 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
287 |
* much like the above, but for IO Errors; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
288 |
* In single display apps, handling those here does not |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
289 |
* really make sense (except, for a controlled cleanup). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
290 |
* However, in multiDisplay apps, a single broken |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
291 |
* connection should not affect the other users. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
292 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
293 |
__XIOErrorHandler__(dpy) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
294 |
Display *dpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
295 |
{ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
296 |
if (@global(ErrorPrinting) == true) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
297 |
fprintf(stderr, "XWorkstation [error]: I/O error\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
298 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
299 |
__immediateErrorInterruptWithIDAndParameter__(@symbol(DisplayIOError), __MKOBJ(dpy)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
300 |
__internalError("unhandled display I/O error"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
301 |
__terminateProcess(0); /* soft terminate */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
302 |
__terminateProcess(1); /* hard terminate */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
303 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
304 |
|
90 | 305 |
#ifdef VIRTUAL_ROOT |
0 | 306 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
307 |
* added since RootWindow-macro is not sufficient |
18 | 308 |
* when virtual root-windows are involved (i.e. tvtwm) |
309 |
*/ |
|
310 |
static Window |
|
311 |
getRootWindow(dpy, screen) |
|
312 |
Display *dpy; |
|
313 |
{ |
|
314 |
Window root; |
|
315 |
Atom vRootAtom = None; |
|
316 |
int i; |
|
317 |
Window rootReturn, parentReturn; |
|
1050
b2c03e24d56c
another memoryLeak, due to an ommited XFree
Claus Gittinger <cg@exept.de>
parents:
1049
diff
changeset
|
318 |
Window* children = (Window *)0; |
18 | 319 |
unsigned int numChildren; |
320 |
||
321 |
root = RootWindow(dpy, screen); |
|
322 |
/* |
|
323 |
* on IRIS, this creates a badwindow error - why ? |
|
324 |
* children contains a funny window (000034) |
|
325 |
*/ |
|
90 | 326 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 327 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
1344 | 328 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
329 |
if (vRootAtom != None) { |
|
330 |
for (i=0; i < numChildren; i++) { |
|
331 |
Atom actual_type; |
|
332 |
int actual_format; |
|
333 |
unsigned long nitems, bytesafter; |
|
334 |
Window* newRoot = (Window*) 0; |
|
335 |
||
336 |
if (children[i]) { |
|
337 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
338 |
0L, 1L, False, XA_WINDOW, |
|
339 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
340 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
341 |
root = *newRoot; |
|
342 |
XFree(newRoot); /* XXX */ |
|
343 |
break; |
|
344 |
} |
|
345 |
} |
|
346 |
} |
|
347 |
} |
|
348 |
if (children) XFree( children ); |
|
18 | 349 |
} |
90 | 350 |
# endif |
18 | 351 |
return root; |
352 |
} |
|
90 | 353 |
#endif |
0 | 354 |
%} |
78 | 355 |
! ! |
0 | 356 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
357 |
!XWorkstation class methodsFor:'documentation'! |
295 | 358 |
|
359 |
copyright |
|
360 |
" |
|
361 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1344 | 362 |
All Rights Reserved |
295 | 363 |
|
364 |
This software is furnished under a license and may be used |
|
365 |
only in accordance with the terms of that license and with the |
|
366 |
inclusion of the above copyright notice. This software may not |
|
367 |
be provided or otherwise made available to, or used by, any |
|
368 |
other person. No title to or ownership of the software is |
|
369 |
hereby transferred. |
|
370 |
" |
|
371 |
! |
|
372 |
||
373 |
documentation |
|
374 |
" |
|
375 |
this class provides the interface to X11. It redefines all required methods |
|
376 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
377 |
limited to one display - in theory, you can create Views on many displays |
|
378 |
simultanously. However, the default setup is for one display only. |
|
379 |
To support multiple displays, you will have to start another event dispatcher |
|
380 |
process for the other display(s) and create the other views with a slightly |
|
381 |
different protocol. However, 'normal' applications do not have to care for |
|
382 |
all of this ... |
|
383 |
||
384 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 385 |
|
386 |
[author:] |
|
1344 | 387 |
Claus Gittinger |
295 | 388 |
" |
389 |
! ! |
|
390 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
391 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
392 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
393 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
394 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
395 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
396 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
397 |
|
386 | 398 |
RawKeysymTranslation isNil ifTrue:[ |
1344 | 399 |
"/ the following table maps X-keyevents to ST/X |
400 |
"/ device independed events. |
|
401 |
"/ It is NOT meant as a keyboardMap replacement. |
|
402 |
||
403 |
RawKeysymTranslation := d := Dictionary new. |
|
404 |
d at:'Delete_line' put:#DeleteLine. |
|
405 |
d at:'Delete_word' put:#DeleteWord. |
|
406 |
d at:'Down' put:#CursorDown. |
|
407 |
d at:'Up' put:#CursorUp. |
|
408 |
d at:'Left' put:#CursorLeft. |
|
409 |
d at:'Right' put:#CursorRight. |
|
386 | 410 |
] |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
411 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
412 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
413 |
!XWorkstation class methodsFor:'error handling'! |
2 | 414 |
|
129 | 415 |
debug:aBoolean |
416 |
%{ /* NOCONTEXT */ |
|
417 |
||
418 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
419 |
%} |
|
420 |
! |
|
421 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
422 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
423 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
424 |
#ifdef COUNT_RESOURCES |
1404 | 425 |
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
|
426 |
__cnt_color, __cnt_bitmap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
427 |
__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
|
428 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
429 |
%} |
1404 | 430 |
|
431 |
" |
|
432 |
XWorkstation debugResources |
|
433 |
" |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
434 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
435 |
|
78 | 436 |
errorStringOfLastError |
437 |
%{ |
|
1065
fdc5b9059d82
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
438 |
RETURN ( __MKSTRING(lastErrorMsg) ); |
78 | 439 |
%} |
440 |
! |
|
441 |
||
135 | 442 |
lastErrorString |
2 | 443 |
"return the last X-error string - |
444 |
when buffering is on, this may be |
|
445 |
an error for a long-ago operation" |
|
78 | 446 |
|
447 |
|string requestCode s match line| |
|
448 |
||
449 |
string := self errorStringOfLastError. |
|
450 |
requestCode := self requestCodeOfLastError. |
|
451 |
" |
|
452 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
453 |
and append the name of the corresponding X-request |
|
454 |
" |
|
455 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
456 |
s notNil ifTrue:[ |
|
1344 | 457 |
match := 'XRequest.' , requestCode printString. |
458 |
line := s peekForLineStartingWith:match. |
|
459 |
line notNil ifTrue:[ |
|
460 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
461 |
]. |
|
462 |
s close. |
|
78 | 463 |
]. |
464 |
^ string |
|
295 | 465 |
! |
466 |
||
467 |
minorCodeOfLastError |
|
468 |
%{ /* NOCONTEXT */ |
|
469 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
470 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 471 |
%} |
472 |
! |
|
473 |
||
474 |
requestCodeOfLastError |
|
152 | 475 |
%{ /* NOCONTEXT */ |
476 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
477 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 478 |
%} |
135 | 479 |
! |
480 |
||
295 | 481 |
resourceIdOfLastError |
0 | 482 |
%{ /* NOCONTEXT */ |
295 | 483 |
|
484 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 485 |
%} |
486 |
! ! |
|
487 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
488 |
!XWorkstation class methodsFor:'queries'! |
104 | 489 |
|
490 |
platformName |
|
133 | 491 |
"ST-80 compatibility. |
492 |
Return a string describing the display systems platform." |
|
493 |
||
715 | 494 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
495 |
||
496 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 497 |
! ! |
498 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
499 |
!XWorkstation methodsFor:'Signal constants'! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
500 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
501 |
deviceErrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
502 |
"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
|
503 |
X-Error occurs." |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
504 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
505 |
^ deviceErrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
506 |
! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
507 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
508 |
deviceIOrrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
509 |
"return the per-device signal, which is raised when a fatal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
510 |
IO error (i.e. broken connection) occurs." |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
511 |
|
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
512 |
^ deviceIOErrorSignal |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
513 |
! ! |
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
514 |
|
0 | 515 |
!XWorkstation methodsFor:'accessing & queries'! |
516 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
517 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
518 |
"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
|
519 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
520 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
521 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
522 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
523 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
524 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
525 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
526 |
|
295 | 527 |
blackpixel |
528 |
"return the colornumber of black" |
|
529 |
||
530 |
^ blackpixel |
|
531 |
! |
|
532 |
||
533 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
534 |
"return the state-mask for button1 in motion events' state-field. |
295 | 535 |
For backward compatibility." |
536 |
||
537 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
538 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 539 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
540 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
541 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
542 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
543 |
" |
295 | 544 |
! |
545 |
||
546 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
547 |
"return the state-mask for button2 in motion events' state-field |
295 | 548 |
For backward compatibility." |
549 |
||
550 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
551 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 552 |
%} |
553 |
! |
|
554 |
||
555 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
556 |
"return the state-mask for button3 in motion events' state-field |
295 | 557 |
For backward compatibility." |
558 |
||
559 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
560 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 561 |
%} |
562 |
! |
|
563 |
||
564 |
buttonMotionMask:aButton |
|
565 |
"return the state-mask for button1 in motion events state-field. |
|
566 |
This is the devices mask." |
|
567 |
||
568 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
569 |
if (aButton == __MKSMALLINT(1)) { |
1344 | 570 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
571 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
572 |
if (aButton == __MKSMALLINT(2)) { |
1344 | 573 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
574 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
575 |
if (aButton == __MKSMALLINT(3)) { |
1344 | 576 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 577 |
} |
578 |
%}. |
|
579 |
^ nil |
|
580 |
! |
|
581 |
||
382 | 582 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
583 |
"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
|
584 |
|
382 | 585 |
%{ /* NOCONTEXT */ |
586 |
RETURN (__MKSMALLINT(ControlMask)); |
|
587 |
%} |
|
588 |
! |
|
589 |
||
295 | 590 |
defaultEventMask |
591 |
"return a mask to enable some events by default." |
|
592 |
||
593 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
594 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
1344 | 595 |
KeyPressMask | KeyReleaseMask | |
596 |
EnterWindowMask | LeaveWindowMask | |
|
597 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
295 | 598 |
%} |
599 |
! |
|
600 |
||
0 | 601 |
displayFileDescriptor |
602 |
"return the displays fileNumber - for select" |
|
603 |
||
604 |
%{ /* NOCONTEXT */ |
|
605 |
||
150 | 606 |
if (ISCONNECTED) { |
1344 | 607 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 608 |
} |
609 |
RETURN (nil); |
|
0 | 610 |
%} |
611 |
! |
|
612 |
||
133 | 613 |
displayName |
614 |
"return the X-connections display name. |
|
615 |
This is (currently) nil for the default display, |
|
616 |
something like foo:0 for any other remote display. |
|
617 |
Future versions may return non-nil strings for the default display as well." |
|
618 |
||
619 |
^ displayName |
|
620 |
! |
|
621 |
||
341 | 622 |
protocolVersion |
623 |
"return the X-servers protocol version - should normally not be of |
|
624 |
any interest" |
|
625 |
||
626 |
%{ /* NOCONTEXT */ |
|
627 |
if (ISCONNECTED) { |
|
1344 | 628 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
341 | 629 |
} |
630 |
RETURN (nil); |
|
631 |
%} |
|
632 |
||
633 |
" |
|
634 |
Display protocolVersion |
|
635 |
" |
|
636 |
! |
|
637 |
||
638 |
serverVendor |
|
639 |
"return the X-server vendor string - this should normally not be of |
|
640 |
any interest, but can be for special cases |
|
641 |
(to avoid bugs in certain implementations)" |
|
642 |
%{ |
|
643 |
if (ISCONNECTED) { |
|
1344 | 644 |
RETURN ( __MKSTRING(XServerVendor(myDpy)) ); |
341 | 645 |
} |
646 |
RETURN (nil); |
|
647 |
%} |
|
648 |
||
649 |
" |
|
650 |
Display serverVendor |
|
651 |
" |
|
652 |
! |
|
653 |
||
382 | 654 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
655 |
"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
|
656 |
|
382 | 657 |
%{ /* NOCONTEXT */ |
658 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
659 |
%} |
|
660 |
! |
|
661 |
||
341 | 662 |
translatePoint:aPoint from:windowId1 to:windowId2 |
663 |
"given a point in window1, return the coordinate in window2. |
|
664 |
This expects a device coordinate (relative to the first views origin) |
|
665 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
666 |
- use to xlate points from a window to rootwindow" |
|
667 |
||
668 |
|x1 y1 x2 y2| |
|
669 |
||
670 |
x1 := x2 := aPoint x truncated. |
|
671 |
y1 := y2 := aPoint y truncated. |
|
672 |
%{ |
|
673 |
int xpos, ypos; |
|
674 |
Window w1, w2, child_return; |
|
555 | 675 |
int screen = __intVal(__INST(screen)); |
1209 | 676 |
|
677 |
if (ISCONNECTED |
|
678 |
&& __isExternalAddress(windowId1) |
|
341 | 679 |
&& __isExternalAddress(windowId2) |
680 |
&& __bothSmallInteger(x1, y1)) { |
|
1344 | 681 |
Display *dpy = myDpy; |
682 |
||
683 |
w1 = _WindowVal(windowId1); |
|
684 |
w2 = _WindowVal(windowId2); |
|
341 | 685 |
#ifdef VIRTUAL_ROOT |
1344 | 686 |
if ((w1 == RootWindow(dpy, screen)) |
687 |
|| (w2 == RootWindow(dpy, screen))) { |
|
688 |
if (w1 == RootWindow(dpy, screen)) { |
|
689 |
w1 = getRootWindow(dpy, screen); |
|
690 |
} |
|
691 |
if (w2 == RootWindow(dpy, screen)) { |
|
692 |
w2 = getRootWindow(dpy, screen); |
|
693 |
} |
|
694 |
} |
|
341 | 695 |
#endif |
1344 | 696 |
BEGIN_INTERRUPTSBLOCKED |
697 |
XTranslateCoordinates(dpy, w1, w2, |
|
698 |
__intVal(x1), __intVal(y1), |
|
699 |
&xpos, &ypos, &child_return); |
|
700 |
END_INTERRUPTSBLOCKED |
|
701 |
x2 = __MKSMALLINT(xpos); |
|
702 |
y2 = __MKSMALLINT(ypos); |
|
341 | 703 |
} |
704 |
%}. |
|
705 |
||
706 |
^ (x2 @ y2) |
|
707 |
! |
|
708 |
||
709 |
vendorRelease |
|
710 |
"return the X-servers vendor release - should normally not be of |
|
711 |
any interest, but can be for special cases. |
|
712 |
(to avoid bugs in certain implementations)" |
|
713 |
||
714 |
%{ /* NOCONTEXT */ |
|
715 |
if (ISCONNECTED) { |
|
1344 | 716 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
341 | 717 |
} |
718 |
RETURN (nil); |
|
719 |
%} |
|
720 |
||
721 |
" |
|
722 |
Display vendorRelease |
|
723 |
" |
|
724 |
! |
|
725 |
||
726 |
viewIdFromPoint:aPoint in:windowId |
|
727 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
728 |
hit by this coordinate. Return nil if no view was hit. |
|
729 |
The returned id may be the id of a non ST view. |
|
730 |
- used to find the window to drop objects after a cross-view drag." |
|
731 |
||
732 |
%{ /* NOCONTEXT */ |
|
733 |
||
555 | 734 |
int screen = __intVal(__INST(screen)); |
341 | 735 |
OBJ xp, yp; |
736 |
int xpos, ypos; |
|
737 |
Window child_return; |
|
738 |
||
1209 | 739 |
if (ISCONNECTED |
740 |
&& __isExternalAddress(windowId) |
|
341 | 741 |
&& __isPoint(aPoint)) { |
1344 | 742 |
Display *dpy = myDpy; |
743 |
||
744 |
xp = _point_X(aPoint); |
|
745 |
yp = _point_Y(aPoint); |
|
746 |
if (__bothSmallInteger(xp, yp)) { |
|
747 |
BEGIN_INTERRUPTSBLOCKED |
|
748 |
XTranslateCoordinates(dpy, |
|
749 |
RootWindow(dpy, screen), |
|
750 |
_WindowVal(windowId), |
|
751 |
__intVal(xp), __intVal(yp), |
|
752 |
&xpos, &ypos, &child_return); |
|
753 |
END_INTERRUPTSBLOCKED |
|
754 |
if (child_return) { |
|
755 |
RETURN ( __MKOBJ(child_return) ); |
|
756 |
} |
|
757 |
RETURN ( nil ); |
|
758 |
} |
|
341 | 759 |
} |
760 |
%}. |
|
761 |
windowId notNil ifTrue:[ |
|
1344 | 762 |
aPoint isPoint ifTrue:[ |
763 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
764 |
] |
|
341 | 765 |
]. |
766 |
||
767 |
^ nil |
|
768 |
! |
|
769 |
||
770 |
virtualExtent |
|
771 |
"return the virtual extent of the display (in pixels). |
|
772 |
On most systems, this is the same as the physical width; |
|
773 |
except, if a window manager with a virtual desktop like olvwm |
|
774 |
(simulating a bigger screen) is running." |
|
775 |
||
776 |
%{ |
|
1209 | 777 |
if (ISCONNECTED |
778 |
&& (__INST(rootId) != __INST(virtualRootId)) |
|
555 | 779 |
&& __isExternalAddress(__INST(virtualRootId))) { |
1344 | 780 |
Window vRootWin; |
781 |
Window root; |
|
782 |
int x, y; |
|
783 |
unsigned int width, height; |
|
784 |
unsigned int dummy; |
|
785 |
||
786 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
|
787 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
788 |
&dummy, &dummy)) { |
|
789 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
790 |
} |
|
341 | 791 |
} |
792 |
%}. |
|
793 |
^ width @ height |
|
794 |
! |
|
795 |
||
796 |
whitepixel |
|
797 |
"return the colornumber of white" |
|
798 |
||
799 |
^ whitepixel |
|
800 |
! ! |
|
801 |
||
802 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
803 |
||
0 | 804 |
hasDPS |
186 | 805 |
"return true, if this workstation supports display postscript. |
806 |
Both the server must support it, and the feature must have been |
|
807 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 808 |
|
809 |
^ hasDPSExtension |
|
186 | 810 |
|
811 |
" |
|
812 |
Display hasDPS |
|
813 |
" |
|
814 |
! |
|
815 |
||
150 | 816 |
hasExtension:extensionString |
817 |
"query for an X extension. The argument, extensionString |
|
818 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 819 |
Return true, if that extension is available in the server. |
820 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 821 |
|
822 |
%{ |
|
823 |
int dummy; |
|
824 |
||
825 |
if (__isString(extensionString) && ISCONNECTED) { |
|
1344 | 826 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
827 |
RETURN ( true ); |
|
828 |
} |
|
150 | 829 |
} |
830 |
%}. |
|
831 |
^ false |
|
186 | 832 |
|
833 |
" |
|
834 |
Display hasExtension:'XVideo' |
|
835 |
Display hasExtension:'Input' |
|
836 |
Display hasExtension:'GLX' |
|
837 |
Display hasExtension:'X3D-PEX' |
|
838 |
Display hasExtension:'XInputExtension' |
|
839 |
Display hasExtension:'SHAPE' |
|
840 |
Display hasExtension:'MIT-SHM' |
|
841 |
Display hasExtension:'SGIFullScreenStereo' |
|
842 |
" |
|
150 | 843 |
! |
844 |
||
295 | 845 |
hasImageExtension |
846 |
"return true, if this workstation supports the X image extension. |
|
847 |
Both the server must support it, and the feature must have been |
|
848 |
enabled in the smalltalk system, for true to be returned." |
|
849 |
||
850 |
^ hasImageExtension |
|
851 |
||
852 |
" |
|
853 |
Display hasImageExtension |
|
854 |
" |
|
855 |
! |
|
856 |
||
857 |
hasInputExtension |
|
858 |
"return true, if this workstation supports the X input extension. |
|
859 |
Both the server must support it, and the feature must have been |
|
860 |
enabled in the smalltalk system, for true to be returned." |
|
861 |
||
862 |
^ hasInputExtension |
|
863 |
||
864 |
" |
|
865 |
Display hasInputExtension |
|
866 |
" |
|
867 |
! |
|
868 |
||
869 |
hasMultibuffer |
|
870 |
"return true, if this workstation supports the multibuffer extension. |
|
871 |
Both the server must support it, and the feature must have been |
|
872 |
enabled in the smalltalk system, for true to be returned." |
|
873 |
||
874 |
^ hasMbufExtension |
|
875 |
||
876 |
" |
|
877 |
Display hasMultibuffer |
|
878 |
" |
|
879 |
! |
|
880 |
||
881 |
hasPEX |
|
882 |
"return true, if this workstation supports PEX 3D graphics. |
|
883 |
Both the server must support it, and the feature must have been |
|
884 |
enabled in the smalltalk system, for true to be returned." |
|
885 |
||
886 |
^ hasPEXExtension |
|
887 |
||
888 |
" |
|
889 |
Display hasPEX |
|
890 |
" |
|
891 |
! |
|
892 |
||
893 |
hasShape |
|
894 |
"return true, if this workstation supports non-rectangular windows. |
|
895 |
Both the server must support it, and the feature must have been |
|
896 |
enabled in the smalltalk system, for true to be returned." |
|
897 |
||
898 |
^ hasShapeExtension |
|
899 |
||
900 |
" |
|
901 |
Display hasShape |
|
902 |
" |
|
903 |
! |
|
904 |
||
905 |
hasShm |
|
906 |
"return true, if this workstation supports the shared pixmap extension. |
|
907 |
Both the server must support it, and the feature must have been |
|
908 |
enabled in the smalltalk system, for true to be returned." |
|
909 |
||
910 |
^ hasShmExtension |
|
911 |
||
912 |
" |
|
913 |
Display hasShm |
|
914 |
" |
|
915 |
! |
|
916 |
||
917 |
hasXVideo |
|
918 |
"return true, if this workstation supports the XVideo extension. |
|
919 |
Both the server must support it, and the feature must have been |
|
920 |
enabled in the smalltalk system, for true to be returned." |
|
921 |
||
922 |
^ hasXVideoExtension |
|
923 |
||
924 |
" |
|
925 |
Display hasXVideo |
|
926 |
" |
|
927 |
! |
|
928 |
||
929 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
930 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 931 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 932 |
|
933 |
|xIconSizes count ret| |
|
934 |
||
935 |
%{ |
|
555 | 936 |
int screen = __intVal(__INST(screen)); |
295 | 937 |
XIconSize *sizeList; |
938 |
int cnt; |
|
939 |
||
940 |
if (ISCONNECTED) { |
|
1344 | 941 |
Display *dpy = myDpy; |
942 |
||
943 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
|
944 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
945 |
count = __MKSMALLINT(cnt); |
|
946 |
} |
|
295 | 947 |
} |
948 |
%}. |
|
949 |
xIconSizes isNil ifTrue:[^ nil]. |
|
950 |
||
951 |
ret := OrderedCollection new:count. |
|
952 |
1 to:count do:[ :i | |
|
1344 | 953 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 954 |
|
955 |
%{ |
|
1344 | 956 |
XIconSize *slp; |
957 |
||
958 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
959 |
minWidth = __MKSMALLINT(slp->min_width); |
|
960 |
minHeight = __MKSMALLINT(slp->min_height); |
|
961 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
962 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
963 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
964 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 965 |
%}. |
1344 | 966 |
d := IdentityDictionary new. |
967 |
d at:#minWidth put:minWidth. |
|
968 |
d at:#maxWidth put:maxWidth. |
|
969 |
d at:#widthStep put:widthStep. |
|
970 |
d at:#minHeight put:minHeight. |
|
971 |
d at:#maxHeight put:maxHeight. |
|
972 |
d at:#heightStep put:heightStep. |
|
973 |
||
974 |
ret add:d |
|
295 | 975 |
]. |
976 |
||
977 |
xIconSizes free. |
|
978 |
^ ret |
|
979 |
||
980 |
" |
|
819 | 981 |
Display iconSizes |
295 | 982 |
" |
983 |
! |
|
984 |
||
341 | 985 |
ignoreBackingStore:aBoolean |
986 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
987 |
no backing store used - this can be used on servers where backing store is |
|
988 |
very slow or is broken (can be put into display-rc-file)" |
|
989 |
||
990 |
ignoreBackingStore := aBoolean |
|
295 | 991 |
! |
992 |
||
823 | 993 |
preferredIconSize |
994 |
"return the displays preferred size for icons. |
|
995 |
Redefined to return a special value on SGI servers." |
|
996 |
||
997 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
1344 | 998 |
^ 86@68 |
823 | 999 |
]. |
1000 |
^ super preferredIconSize |
|
1001 |
||
1002 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
1003 |
! |
|
1004 |
||
1025 | 1005 |
scrollsAsynchronous |
1008
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1006 |
"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
|
1007 |
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
|
1008 |
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
|
1009 |
|
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1010 |
^ true |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1011 |
! |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
1012 |
|
43 | 1013 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1014 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1015 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1016 |
depth, bitsPerPixel and padding values." |
43 | 1017 |
|
150 | 1018 |
|nFormats "{ Class: SmallInteger }" |
1019 |
formatArray| |
|
43 | 1020 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1021 |
Display *dpy; |
150 | 1022 |
|
1023 |
if (! ISCONNECTED) { |
|
1344 | 1024 |
RETURN (nil); |
150 | 1025 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1026 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1027 |
dpy = myDpy; |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1028 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 1029 |
%}. |
1030 |
formatArray := Array new:nFormats. |
|
150 | 1031 |
1 to:nFormats do:[:index | |
1344 | 1032 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
1033 |
||
1034 |
i := index. |
|
43 | 1035 |
%{ |
1344 | 1036 |
ScreenFormat *format; |
1037 |
Display *dpy = myDpy; |
|
1038 |
||
1039 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
|
1040 |
format += (__intVal(i)-1); |
|
1041 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
|
1042 |
depthInfo = __MKSMALLINT(format->depth); |
|
1043 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
|
43 | 1044 |
%}. |
1344 | 1045 |
info := IdentityDictionary new. |
1046 |
info at:#depth put:depthInfo. |
|
1047 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
|
1048 |
info at:#padding put:paddingInfo. |
|
1049 |
formatArray at:index put:info. |
|
43 | 1050 |
]. |
1051 |
^ formatArray |
|
1052 |
||
1053 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1054 |
Display supportedImageFormats |
43 | 1055 |
" |
1056 |
! |
|
1057 |
||
823 | 1058 |
supportsIconViews |
1059 |
"return true, if this device supports views as icons. |
|
1060 |
Only Xservers (currently) support this." |
|
1061 |
||
1062 |
^ true |
|
1063 |
||
1064 |
" |
|
1065 |
Display supportsIconViews |
|
1066 |
" |
|
1067 |
||
1068 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1069 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1070 |
! |
|
1071 |
||
81 | 1072 |
supportsViewGravity |
1073 |
"return true, if this device supports gravity attributes. |
|
82 | 1074 |
We do not depend on it being implemented, but some resizing operations |
81 | 1075 |
are faster, it is is." |
1076 |
||
1077 |
^ true |
|
0 | 1078 |
! ! |
1079 |
||
1080 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1081 |
||
295 | 1082 |
createBitmapFromArray:anArray width:w height:h |
1083 |
|bitmapId| |
|
1084 |
||
1085 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1086 |
bitmapId isNil ifTrue:[ |
|
1344 | 1087 |
self primitiveFailed |
295 | 1088 |
]. |
1089 |
^ bitmapId |
|
1090 |
! |
|
1091 |
||
1092 |
createBitmapFromFile:aString for:aForm |
|
1093 |
|id w h| |
|
1094 |
||
1095 |
%{ |
|
555 | 1096 |
int screen = __intVal(__INST(screen)); |
295 | 1097 |
Pixmap newBitmap; |
1098 |
char *filename; |
|
1099 |
unsigned b_width, b_height; |
|
1100 |
int b_x_hot, b_y_hot; |
|
1101 |
int status; |
|
1102 |
||
1103 |
if (ISCONNECTED) { |
|
1344 | 1104 |
Display *dpy = myDpy; |
1105 |
||
1106 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1107 |
filename = (char *)_stringVal(aString); |
|
1108 |
||
1109 |
BEGIN_INTERRUPTSBLOCKED |
|
1110 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1111 |
filename, &b_width, &b_height, &newBitmap, |
|
1112 |
&b_x_hot, &b_y_hot); |
|
1113 |
END_INTERRUPTSBLOCKED |
|
1114 |
||
1115 |
if ((status == BitmapSuccess) && newBitmap) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1116 |
#ifdef COUNT_RESOURCES |
1344 | 1117 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1118 |
#endif |
1344 | 1119 |
w = __MKSMALLINT(b_width); |
1120 |
h = __MKSMALLINT(b_height); |
|
1121 |
id = __MKOBJ(newBitmap); |
|
1122 |
} |
|
1123 |
} |
|
295 | 1124 |
} |
1125 |
%}. |
|
1126 |
id notNil ifTrue:[ |
|
1344 | 1127 |
aForm setWidth:w height:h |
295 | 1128 |
]. |
1129 |
^ id |
|
1130 |
! |
|
1131 |
||
1132 |
createBitmapWidth:w height:h |
|
1133 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1134 |
(i.e. random). Return a bitmap id or nil" |
|
1135 |
||
1136 |
%{ /* NOCONTEXT */ |
|
1137 |
||
555 | 1138 |
int screen = __intVal(__INST(screen)); |
295 | 1139 |
Pixmap newBitmap; |
1140 |
||
1141 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1344 | 1142 |
Display *dpy = myDpy; |
1143 |
||
1144 |
BEGIN_INTERRUPTSBLOCKED |
|
1145 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1146 |
__intVal(w), __intVal(h), 1); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1147 |
#ifdef COUNT_RESOURCES |
1344 | 1148 |
if (newBitmap) |
1149 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1150 |
#endif |
1344 | 1151 |
END_INTERRUPTSBLOCKED |
1152 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
295 | 1153 |
} |
1154 |
%} |
|
1155 |
. |
|
1156 |
self primitiveFailed. |
|
1157 |
^ nil |
|
1158 |
! |
|
1159 |
||
0 | 1160 |
createPixmapWidth:w height:h depth:d |
1161 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1162 |
(i.e. random). Return a bitmap id or nil" |
|
1163 |
||
1164 |
%{ /* NOCONTEXT */ |
|
1165 |
||
555 | 1166 |
int screen = __intVal(__INST(screen)); |
0 | 1167 |
Pixmap newBitmap; |
1168 |
||
150 | 1169 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
1344 | 1170 |
Display *dpy = myDpy; |
1171 |
||
1172 |
BEGIN_INTERRUPTSBLOCKED |
|
1173 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1174 |
__intVal(w), __intVal(h), __intVal(d)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1175 |
#ifdef COUNT_RESOURCES |
1344 | 1176 |
if (newBitmap) |
1177 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1178 |
#endif |
1344 | 1179 |
END_INTERRUPTSBLOCKED |
1180 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1181 |
} |
1424 | 1182 |
%}. |
43 | 1183 |
self primitiveFailed. |
1184 |
^ nil |
|
0 | 1185 |
! |
1186 |
||
1468
9832c4017a70
added type argument to createWindowFor - prepare for native window support (windows)
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1187 |
createWindowFor:aView type:typeSymbol |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1188 |
origin:origin |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1189 |
extent:extent |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1190 |
minExtent:minExt |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1191 |
maxExtent:maxExt |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1192 |
borderWidth:bWidth |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1193 |
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
|
1194 |
style:wStyle |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1195 |
inputOnly:winputOnly |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1196 |
label:wlabel |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1197 |
cursor:wcursor |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1198 |
icon:wicon iconMask:wiconMask |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1199 |
iconView:wiconView |
46 | 1200 |
|
1201 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1424 | 1202 |
bColorId wsuperViewId wcursorId wiconId wiconMaskId windowId |
46 | 1203 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
150 | 1204 |
vBgForm deepForm preferredVisual preferredDepth| |
1205 |
||
1206 |
displayId isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1207 |
self primitiveFailed. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1208 |
^ nil |
150 | 1209 |
]. |
0 | 1210 |
|
46 | 1211 |
origin notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1212 |
xpos := origin x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1213 |
ypos := origin y. |
46 | 1214 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1215 |
xpos := ypos := 0. |
0 | 1216 |
]. |
46 | 1217 |
extent notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1218 |
wwidth := extent x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1219 |
wheight := extent y. |
46 | 1220 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1221 |
wwidth := wheight := 100. |
46 | 1222 |
]. |
1223 |
minExt notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1224 |
minWidth := minExt x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1225 |
minHeight := minExt y |
0 | 1226 |
]. |
46 | 1227 |
maxExt notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1228 |
maxWidth := maxExt x. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1229 |
maxHeight := maxExt y |
46 | 1230 |
]. |
1231 |
||
0 | 1232 |
wsuperView notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1233 |
wsuperViewId := wsuperView id |
0 | 1234 |
]. |
1235 |
wcursor isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1236 |
'XWorkstation [info]: cursor nil - defaulted' infoPrintCR |
0 | 1237 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1238 |
wcursorId := wcursor id |
0 | 1239 |
]. |
1240 |
||
1241 |
wicon notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1242 |
wiconId := wicon id. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1243 |
wiconMask notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1244 |
wiconMaskId := wiconMask id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1245 |
] |
0 | 1246 |
]. |
1247 |
wiconView notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1248 |
wiconViewId := wiconView id |
0 | 1249 |
]. |
1250 |
weventMask := aView eventMask. |
|
1251 |
||
150 | 1252 |
preferredVisual := aView preferredVisual. |
1253 |
preferredDepth := aView preferredDepth. |
|
23 | 1254 |
|
72 | 1255 |
%{ /* STACK:16000 */ |
0 | 1256 |
Display *dpy = myDpy; |
555 | 1257 |
int screen = __intVal(__INST(screen)); |
0 | 1258 |
Visual visual; |
1259 |
XGCValues xgcv; |
|
1260 |
XSetWindowAttributes xswa; |
|
1261 |
XSizeHints sizehints; |
|
1262 |
XWMHints wmhints; |
|
46 | 1263 |
int bw, bd, bg; |
0 | 1264 |
Window newWindow, parentWindow; |
1265 |
char *windowName; |
|
1266 |
XFontStruct *f; |
|
1537 | 1267 |
Pixmap backPixmap = (Pixmap)0, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1268 |
iconBitmap = (Pixmap)0, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1269 |
iconMask = (Pixmap)0; |
0 | 1270 |
int flags = 0, depth, ioClass; |
1271 |
Window iconWindow; |
|
1272 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1273 |
Atom WmQuitAppAtom; |
|
1274 |
Atom atoms[3]; |
|
1275 |
int atomCount = 0, isTopWindow = 0; |
|
1276 |
||
1277 |
sizehints.flags = 0; |
|
1278 |
sizehints.width = 100; |
|
1279 |
sizehints.height = 100; |
|
1280 |
sizehints.x = 0; |
|
1281 |
sizehints.y = 0; |
|
1282 |
||
97 | 1283 |
if (__bothSmallInteger(wwidth, wheight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1284 |
sizehints.flags |= PSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1285 |
sizehints.width = __intVal(wwidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1286 |
sizehints.height = __intVal(wheight); |
0 | 1287 |
} |
97 | 1288 |
if (__bothSmallInteger(xpos, ypos)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1289 |
sizehints.flags |= PPosition; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1290 |
sizehints.x = __intVal(xpos); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1291 |
sizehints.y = __intVal(ypos); |
0 | 1292 |
} |
97 | 1293 |
if (__bothSmallInteger(minWidth, minHeight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1294 |
sizehints.flags |= PMinSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1295 |
sizehints.min_width = __intVal(minWidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1296 |
sizehints.min_height = __intVal(minHeight); |
0 | 1297 |
} |
97 | 1298 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1299 |
sizehints.flags |= PMaxSize; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1300 |
sizehints.max_width = __intVal(maxWidth); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1301 |
sizehints.max_height = __intVal(maxHeight); |
0 | 1302 |
} |
1303 |
||
37 | 1304 |
bg = WhitePixel(dpy, screen); |
0 | 1305 |
|
97 | 1306 |
if (__isSmallInteger(bWidth)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1307 |
bw = __intVal(bWidth); |
46 | 1308 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1309 |
bw = 0; |
0 | 1310 |
} |
1311 |
||
72 | 1312 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1313 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1314 |
if (__isExternalAddress(wsuperViewId)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1315 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1316 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1317 |
parentWindow = RootWindow(dpy, screen); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1318 |
isTopWindow = 1; |
0 | 1319 |
} |
1320 |
||
1695
46d9101e4bee
replaced isPopUp flag in #createWindow by a more general #style symbol argument
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
1321 |
if (wStyle == @symbol(popUp)) |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1322 |
xswa.override_redirect = 1; |
0 | 1323 |
else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1324 |
xswa.override_redirect = 0; |
0 | 1325 |
|
1326 |
if (winputOnly == true) |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1327 |
ioClass = InputOnly; |
0 | 1328 |
else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1329 |
ioClass = InputOutput; |
0 | 1330 |
|
97 | 1331 |
if (__isSmallInteger(weventMask)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1332 |
xswa.event_mask = __intVal(weventMask); |
0 | 1333 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1334 |
xswa.event_mask = 0; |
0 | 1335 |
} |
1336 |
||
1337 |
if (ioClass == InputOnly) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1338 |
bw = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1339 |
depth = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1340 |
flags |= CWEventMask; |
0 | 1341 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1342 |
depth = DefaultDepth(dpy,screen); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1343 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1344 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1345 |
if (backPixmap != (Pixmap)0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1346 |
xswa.background_pixmap = backPixmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1347 |
flags |= CWBackPixmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1348 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1349 |
xswa.background_pixel = bg; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1350 |
flags |= CWBackPixel; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1351 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1352 |
xswa.border_pixel = bd; |
0 | 1353 |
} |
23 | 1354 |
|
0 | 1355 |
visual.visualid = CopyFromParent; |
150 | 1356 |
if (__isSmallInteger(preferredDepth)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1357 |
depth = __intVal(preferredDepth); |
23 | 1358 |
} |
54 | 1359 |
|
1360 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1361 |
if (preferredVisual != nil) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1362 |
XVisualInfo vi; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1363 |
int cls; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1364 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1365 |
if (preferredVisual == @symbol(StaticGray)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1366 |
cls = StaticGray; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1367 |
else if (preferredVisual == @symbol(GrayScale)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1368 |
cls = GrayScale; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1369 |
else if (preferredVisual == @symbol(StaticColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1370 |
cls = StaticColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1371 |
else if (preferredVisual == @symbol(PseudoColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1372 |
cls = PseudoColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1373 |
else if (preferredVisual == @symbol(TrueColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1374 |
cls = TrueColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1375 |
else if (preferredVisual == @symbol(DirectColor)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1376 |
cls = DirectColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1377 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1378 |
cls = PseudoColor; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1379 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1380 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1381 |
visual.visualid = vi.visualid; |
163 | 1382 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1383 |
printf("visualId=%x\n", vi.visualid); |
163 | 1384 |
*/ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1385 |
} |
23 | 1386 |
} |
0 | 1387 |
|
1388 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1389 |
sizehints.x, sizehints.y, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1390 |
sizehints.width, sizehints.height, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1391 |
bw, depth, ioClass, &visual, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1392 |
flags, &xswa); |
54 | 1393 |
END_INTERRUPTSBLOCKED |
0 | 1394 |
|
1395 |
if (! newWindow) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1396 |
RETURN ( nil ); |
0 | 1397 |
} |
1398 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1399 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1400 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1401 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1402 |
|
54 | 1403 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1404 |
/* |
1405 |
* define its cursor |
|
1406 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1407 |
if (__isExternalAddress(wcursorId)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1408 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1409 |
} |
1410 |
||
1411 |
/* |
|
1412 |
* define its icon and name |
|
1413 |
* (only makes sense for topWindows) |
|
1414 |
*/ |
|
1415 |
if (isTopWindow) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1416 |
if (__isExternalAddress(wiconId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1417 |
iconBitmap = _PixmapVal(wiconId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1418 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1419 |
iconBitmap = (Pixmap)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1420 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1421 |
if (__isExternalAddress(wiconMaskId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1422 |
iconMask = _PixmapVal(wiconMaskId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1423 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1424 |
iconMask = (Pixmap)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1425 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1426 |
if (__isExternalAddress(wiconViewId)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1427 |
iconWindow = _WindowVal(wiconViewId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1428 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1429 |
iconWindow = (Window)0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1430 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1431 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1432 |
windowName = (char *)_stringVal(wlabel); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1433 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1434 |
windowName = ""; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1435 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1436 |
if (iconBitmap || windowName) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1437 |
XSetStandardProperties(dpy, newWindow, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1438 |
windowName, windowName, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1439 |
iconBitmap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1440 |
0, 0, &sizehints); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1441 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1442 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1443 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1444 |
wmhints.flags = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1445 |
if (iconBitmap) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1446 |
wmhints.flags |= IconPixmapHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1447 |
wmhints.icon_pixmap = iconBitmap; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1448 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1449 |
if (iconMask) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1450 |
wmhints.flags |= IconMaskHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1451 |
wmhints.icon_mask = iconMask; |
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 (iconWindow) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1454 |
wmhints.flags |= IconWindowHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1455 |
wmhints.icon_window = iconWindow; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1456 |
} |
0 | 1457 |
/* |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1458 |
wmhints.flags |= InputHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1459 |
wmhints.input = True; |
0 | 1460 |
*/ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1461 |
XSetWMHints(dpy, newWindow, &wmhints); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1462 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1463 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1464 |
* 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
|
1465 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1466 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1467 |
* get atoms first (if not already known) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1468 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1469 |
if (__INST(protocolsAtom) == nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1470 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1471 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1472 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1473 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1474 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1475 |
#endif |
1476 |
#ifdef USE_QUIT_APP_ATOM |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1477 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1478 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1479 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1480 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1481 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1482 |
} else { |
0 | 1483 |
#ifdef USE_QUIT_APP_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1484 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1485 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1486 |
WmQuitAppAtom = 0; |
0 | 1487 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1488 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1489 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
0 | 1490 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1491 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1492 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1493 |
WmSaveYourselfAtom = 0; |
0 | 1494 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1495 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1496 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1497 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
0 | 1498 |
#ifdef USE_SAVEYOURSELF_ATOM |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1499 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1500 |
#endif |
1501 |
#ifdef USE_QUIT_APP_ATOM |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1502 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1503 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1504 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1505 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
0 | 1506 |
} |
1507 |
||
54 | 1508 |
END_INTERRUPTSBLOCKED |
1509 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1510 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1511 |
%}. |
0 | 1512 |
self addKnownView:aView withId:windowId. |
1513 |
^ windowId |
|
1514 |
! |
|
1515 |
||
1516 |
destroyGC:aGCId |
|
1517 |
||
1518 |
%{ /* NOCONTEXT */ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1519 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1520 |
if (! ISCONNECTED) { |
1344 | 1521 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1522 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1523 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1524 |
if (__isExternalAddress(aGCId)) { |
1344 | 1525 |
GC gc = _GCVal(aGCId); |
1526 |
||
1527 |
if (gc) { |
|
1528 |
BEGIN_INTERRUPTSBLOCKED |
|
1529 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1530 |
#ifdef COUNT_RESOURCES |
1344 | 1531 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1532 |
#endif |
1344 | 1533 |
END_INTERRUPTSBLOCKED |
1534 |
} |
|
1535 |
RETURN ( self ); |
|
0 | 1536 |
} |
118 | 1537 |
%}. |
0 | 1538 |
self primitiveFailed |
1539 |
! |
|
1540 |
||
295 | 1541 |
destroyPixmap:aDrawableId |
0 | 1542 |
|
1543 |
%{ /* NOCONTEXT */ |
|
1544 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1545 |
if (! ISCONNECTED) { |
1344 | 1546 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1547 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1548 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1549 |
if (__isExternalAddress(aDrawableId)) { |
1344 | 1550 |
Pixmap pix = _PixmapVal(aDrawableId); |
1551 |
||
1552 |
if (pix) { |
|
1553 |
BEGIN_INTERRUPTSBLOCKED |
|
1554 |
XFreePixmap(myDpy, pix); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1555 |
#ifdef COUNT_RESOURCES |
1344 | 1556 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1557 |
#endif |
1344 | 1558 |
END_INTERRUPTSBLOCKED |
1559 |
} |
|
1560 |
RETURN ( self ); |
|
0 | 1561 |
} |
118 | 1562 |
%}. |
295 | 1563 |
self primitiveFailed |
1564 |
! |
|
1565 |
||
1566 |
destroyView:aView withId:aWindowId |
|
1567 |
%{ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1568 |
if (! ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1569 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1570 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1571 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1572 |
if (__isExternalAddress(aWindowId)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1573 |
Window win = _WindowVal(aWindowId); |
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 |
if (win) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1576 |
BEGIN_INTERRUPTSBLOCKED |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1577 |
XDestroyWindow(myDpy, win); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1578 |
#ifdef COUNT_RESOURCES |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1579 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1580 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1581 |
END_INTERRUPTSBLOCKED |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
1582 |
} |
295 | 1583 |
} |
1584 |
%}. |
|
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1585 |
self removeKnownView:aView withId:aWindowId |
0 | 1586 |
! |
1587 |
||
1588 |
dpsContextFor:aDrawableId and:aGCId |
|
1589 |
||
1590 |
%{ /* NOCONTEXT */ |
|
1591 |
#ifdef XXDPS |
|
555 | 1592 |
int screen = __intVal(__INST(screen)); |
0 | 1593 |
DPSContext dps; |
1594 |
int height; |
|
1595 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1596 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1597 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1598 |
&& ISCONNECTED) { |
1344 | 1599 |
BEGIN_INTERRUPTSBLOCKED |
1600 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1601 |
_GCVal(aGCId), |
|
1602 |
0, height, 0, colormap, NULL, 0, |
|
1603 |
XDPSDefaultTextBackstop, |
|
1604 |
XDPSDefaultErrorProc, |
|
1605 |
NULL); |
|
1606 |
END_INTERRUPTSBLOCKED |
|
1607 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
|
0 | 1608 |
} |
1609 |
#endif |
|
1610 |
%} |
|
1611 |
. |
|
43 | 1612 |
self primitiveFailed. |
1613 |
^ nil |
|
295 | 1614 |
! |
1615 |
||
1616 |
gcFor:aDrawableId |
|
132 | 1617 |
|
1618 |
%{ /* NOCONTEXT */ |
|
555 | 1619 |
int screen = __intVal(__INST(screen)); |
295 | 1620 |
GC gc; |
1621 |
||
1622 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1344 | 1623 |
BEGIN_INTERRUPTSBLOCKED |
1624 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1625 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1626 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1627 |
#ifdef COUNT_RESOURCES |
1344 | 1628 |
if (gc) |
1629 |
__cnt_gc++; |
|
1089 | 1630 |
#endif |
1631 |
||
1344 | 1632 |
END_INTERRUPTSBLOCKED |
1633 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1634 |
} |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1635 |
%}. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1636 |
self primitiveFailed. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1637 |
^ nil |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1638 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1639 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1640 |
gcForBitmap:aDrawableId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1641 |
"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
|
1642 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1643 |
%{ /* NOCONTEXT */ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1644 |
int screen = __intVal(__INST(screen)); |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1645 |
GC gc; |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1646 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1647 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
1344 | 1648 |
BEGIN_INTERRUPTSBLOCKED |
1649 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1650 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1651 |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1652 |
#ifdef COUNT_RESOURCES |
1344 | 1653 |
if (gc) |
1654 |
__cnt_gc++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1655 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1656 |
|
1344 | 1657 |
END_INTERRUPTSBLOCKED |
1658 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1659 |
} |
1660 |
%}. |
|
1661 |
self primitiveFailed. |
|
1662 |
^ nil |
|
295 | 1663 |
! |
1664 |
||
1665 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1666 |
|
1667 |
%{ /* UNLIMITEDSTACK */ |
|
1668 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1669 |
Display *dpy; |
555 | 1670 |
int screen = __intVal(__INST(screen)); |
295 | 1671 |
Pixmap newBitmap; |
1672 |
unsigned int b_width, b_height; |
|
1673 |
REGISTER unsigned char *cp; |
|
1674 |
REGISTER unsigned char *pBits; |
|
1675 |
unsigned char *b_bits, *allocatedBits; |
|
1676 |
int index, row; |
|
1677 |
REGISTER int col; |
|
1678 |
unsigned bits; |
|
1679 |
static char reverseBitTable[256]; |
|
1680 |
static firstCall = 1; |
|
1681 |
int nBytes; |
|
1682 |
unsigned char fastBits[10000]; |
|
1683 |
OBJ num, *op; |
|
1684 |
int bytesPerRow; |
|
1685 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1686 |
if (! ISCONNECTED) { |
1344 | 1687 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1688 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1689 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1690 |
dpy = myDpy; |
295 | 1691 |
if (firstCall) { |
1344 | 1692 |
for (index=0; index < 256; index++) { |
1693 |
reverseBitTable[index] = 0; |
|
1694 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1695 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1696 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1697 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1698 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1699 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1700 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1701 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1702 |
} |
|
1703 |
firstCall = 0; |
|
295 | 1704 |
} |
1705 |
||
1706 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1344 | 1707 |
newBitmap = (Pixmap)0; |
1708 |
b_width = __intVal(w); |
|
1709 |
b_height = __intVal(h); |
|
1710 |
bytesPerRow = (b_width + 7) / 8; |
|
1711 |
nBytes = b_height * bytesPerRow; |
|
1712 |
if (nBytes < sizeof(fastBits)) { |
|
1713 |
cp = b_bits = fastBits; |
|
1714 |
allocatedBits = 0; |
|
1715 |
} else { |
|
1716 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1717 |
if (! cp) goto fail; |
|
1718 |
} |
|
1719 |
||
1720 |
if (__qClass(anArray) == @global(Array)) { |
|
1721 |
index = 1; |
|
1722 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1723 |
for (row = b_height; row; row--) { |
|
1724 |
for (col = bytesPerRow; col; col--) { |
|
1725 |
num = *op++; |
|
1726 |
if (! __isSmallInteger(num)) goto fail; |
|
1727 |
bits = __intVal(num); |
|
1728 |
*cp++ = reverseBitTable[bits]; |
|
1729 |
} |
|
1730 |
} |
|
1731 |
} else { |
|
1732 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1733 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1734 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1735 |
*cp++ = reverseBitTable[*pBits++]; |
|
1736 |
} |
|
1737 |
} else { |
|
1738 |
goto fail; |
|
1739 |
} |
|
1740 |
} |
|
1741 |
||
1742 |
BEGIN_INTERRUPTSBLOCKED |
|
1743 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1744 |
(char *)b_bits, |
|
1745 |
b_width, b_height); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1746 |
#ifdef COUNT_RESOURCES |
1344 | 1747 |
if (newBitmap) |
1748 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1749 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1750 |
|
1344 | 1751 |
END_INTERRUPTSBLOCKED |
295 | 1752 |
fail: ; |
1344 | 1753 |
if (allocatedBits) |
1754 |
free(allocatedBits); |
|
1755 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1756 |
} |
1757 |
%} |
|
295 | 1758 |
! |
1759 |
||
1760 |
realRootWindowFor:aView |
|
1761 |
"the name of this method is historic; |
|
1762 |
- it will vanish" |
|
1763 |
||
1764 |
|id| |
|
1765 |
||
1766 |
id := self realRootWindowId. |
|
1767 |
self addKnownView:aView withId:id. |
|
1768 |
^ id |
|
1769 |
! |
|
1770 |
||
1771 |
realRootWindowId |
|
1772 |
"return the id of the real root window. |
|
1773 |
This may not be the window you see as background, |
|
1774 |
since some window managers install a virtual root window on top |
|
1775 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1776 |
care of any virtual root." |
|
0 | 1777 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
1778 |
%{ |
555 | 1779 |
int screen = __intVal(__INST(screen)); |
295 | 1780 |
Window root; |
1781 |
OBJ id; |
|
1782 |
||
555 | 1783 |
if (__INST(rootId) != nil) { |
1344 | 1784 |
RETURN (__INST(rootId)); |
295 | 1785 |
} |
0 | 1786 |
|
150 | 1787 |
if (ISCONNECTED) { |
1344 | 1788 |
root = RootWindow(myDpy, screen); |
1789 |
if (! root) { |
|
1790 |
id = nil; |
|
1791 |
} else { |
|
1792 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
|
1793 |
} |
|
1794 |
RETURN (id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1795 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1796 |
%}. |
295 | 1797 |
self primitiveFailed |
1798 |
! |
|
1799 |
||
1800 |
rootWindowFor:aView |
|
1801 |
|id| |
|
1802 |
||
1803 |
id := self rootWindowId. |
|
1804 |
self addKnownView:aView withId:id. |
|
0 | 1805 |
^ id |
1806 |
! |
|
1807 |
||
295 | 1808 |
rootWindowId |
1809 |
"return the id of the root window. |
|
1810 |
This is the window you see as background, |
|
1811 |
however, it may or may not be the real physical root window, |
|
1812 |
since some window managers install a virtual root window on top |
|
1813 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1814 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
1815 |
%{ |
555 | 1816 |
int screen = __intVal(__INST(screen)); |
295 | 1817 |
Window rootWin, vRootWin; |
1818 |
OBJ id; |
|
1819 |
||
555 | 1820 |
if (__INST(virtualRootId) != nil) { |
1344 | 1821 |
RETURN (__INST(virtualRootId)); |
295 | 1822 |
} |
0 | 1823 |
|
169 | 1824 |
if (ISCONNECTED) { |
1344 | 1825 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
295 | 1826 |
#ifndef IRIS |
1344 | 1827 |
BEGIN_INTERRUPTSBLOCKED |
1828 |
/* |
|
1829 |
* on IRIS, this creates a badwindow error - why ? |
|
1830 |
* children contains a funny window (000034) |
|
1831 |
*/ |
|
1832 |
||
1833 |
/* |
|
1834 |
* care for virtual root windows (tvtwm & friends) |
|
1835 |
*/ |
|
1836 |
{ |
|
1837 |
Atom vRootAtom = None; |
|
1838 |
int i; |
|
1839 |
Window rootReturn, parentReturn; |
|
1840 |
Window* children = (Window *)0; |
|
1841 |
unsigned int numChildren; |
|
1842 |
||
1843 |
if (XQueryTree(myDpy, rootWin, |
|
1844 |
&rootReturn, &parentReturn, |
|
1845 |
&children, &numChildren)) { |
|
1846 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1847 |
if (vRootAtom != None) { |
|
1848 |
for (i=0; i < numChildren; i++) { |
|
1849 |
Atom actual_type; |
|
1850 |
int actual_format; |
|
1851 |
unsigned long nitems, bytesafter; |
|
1852 |
Window* newRoot = (Window*) 0; |
|
1853 |
||
1854 |
if (children[i]) { |
|
1855 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1856 |
0L, 1L, False, XA_WINDOW, |
|
1857 |
&actual_type, &actual_format, |
|
1858 |
&nitems, &bytesafter, |
|
1859 |
(unsigned char**) &newRoot |
|
1860 |
) == Success && newRoot) { |
|
1861 |
vRootWin = *newRoot; |
|
1862 |
XFree(newRoot); /* XXX */ |
|
1863 |
break; |
|
1864 |
} |
|
1865 |
} |
|
1866 |
} |
|
1867 |
} |
|
1868 |
if (children) XFree( children ); |
|
1869 |
} |
|
1870 |
} |
|
1871 |
END_INTERRUPTSBLOCKED |
|
295 | 1872 |
#endif |
1873 |
} |
|
1874 |
||
1875 |
/* cannot happen */ |
|
1876 |
if (! vRootWin) { |
|
1344 | 1877 |
vRootWin = rootWin; |
1878 |
if (! rootWin) { |
|
1879 |
RETURN ( nil ); |
|
1880 |
} |
|
295 | 1881 |
} |
555 | 1882 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1883 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1884 |
RETURN ( id ); |
63 | 1885 |
%} |
0 | 1886 |
! ! |
1887 |
||
1888 |
!XWorkstation methodsFor:'color stuff'! |
|
1889 |
||
295 | 1890 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1891 |
"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
|
1892 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1893 |
|
1894 |
%{ /* NOCONTEXT */ |
|
1895 |
||
555 | 1896 |
int screen = __intVal(__INST(screen)); |
295 | 1897 |
XColor color; |
1898 |
unsigned long dummy; |
|
1899 |
Status ok; |
|
1900 |
||
1209 | 1901 |
if (ISCONNECTED) { |
1344 | 1902 |
Display *dpy = myDpy; |
1903 |
||
1904 |
BEGIN_INTERRUPTSBLOCKED |
|
1905 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1906 |
&dummy, 0, &color.pixel, 1); |
|
1907 |
END_INTERRUPTSBLOCKED |
|
1908 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1909 |
#ifdef COUNT_RESOURCES |
1344 | 1910 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1911 |
#endif |
1344 | 1912 |
RETURN ( __MKSMALLINT(color.pixel) ); |
1913 |
} |
|
0 | 1914 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1915 |
%}. |
43 | 1916 |
^ nil |
0 | 1917 |
! |
1918 |
||
1919 |
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
|
1920 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1921 |
Dont use this method, colornames are mostly X specific" |
1922 |
||
1923 |
%{ /* NOCONTEXT */ |
|
1924 |
||
1925 |
char *colorname; |
|
1926 |
XColor scolor, ecolor; |
|
555 | 1927 |
int screen = __intVal(__INST(screen)); |
850 | 1928 |
int id; |
54 | 1929 |
Status ok; |
0 | 1930 |
|
150 | 1931 |
if (ISCONNECTED) { |
1344 | 1932 |
Display *dpy = myDpy; |
1933 |
||
1934 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1935 |
colorname = (char *)_stringVal(aString); |
|
1936 |
||
1937 |
BEGIN_INTERRUPTSBLOCKED |
|
1938 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1939 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1940 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1941 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1942 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1943 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1944 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1945 |
RETURN ( __MKSMALLINT(id) ); |
|
1946 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1947 |
#endif |
1344 | 1948 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1949 |
} |
|
1950 |
END_INTERRUPTSBLOCKED |
|
1951 |
if (! ok) { |
|
1952 |
RETURN ( nil ); |
|
1953 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1954 |
#ifdef COUNT_RESOURCES |
1344 | 1955 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1956 |
#endif |
1344 | 1957 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1958 |
} |
|
0 | 1959 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1960 |
%}. |
43 | 1961 |
self primitiveFailed. |
1962 |
^ nil |
|
0 | 1963 |
! |
1964 |
||
295 | 1965 |
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
|
1966 |
"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
|
1967 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1968 |
|
1969 |
|r g b| |
|
1970 |
||
1971 |
r := self percentToXColorValue:redVal. |
|
1972 |
g := self percentToXColorValue:greenVal. |
|
1973 |
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
|
1974 |
^ 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
|
1975 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1976 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1977 |
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
|
1978 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1979 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1980 |
Display *dpy; |
295 | 1981 |
XColor ecolor; |
555 | 1982 |
int screen = __intVal(__INST(screen)); |
295 | 1983 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1984 |
int id; |
295 | 1985 |
|
1986 |
if (__bothSmallInteger(r, g) |
|
1987 |
&& __isSmallInteger(b) |
|
1988 |
&& ISCONNECTED) { |
|
1344 | 1989 |
ecolor.red = __intVal(r); |
1990 |
ecolor.green= __intVal(g); |
|
1991 |
ecolor.blue = __intVal(b); |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1992 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1993 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1994 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1995 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1996 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1997 |
RETURN ( __MKSMALLINT(id) ); |
|
1998 |
} |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1999 |
#endif |
1344 | 2000 |
dpy = myDpy; |
2001 |
BEGIN_INTERRUPTSBLOCKED |
|
2002 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
2003 |
END_INTERRUPTSBLOCKED |
|
2004 |
if (! ok) { |
|
2005 |
RETURN ( nil ); |
|
2006 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2007 |
#ifdef COUNT_RESOURCES |
1344 | 2008 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2009 |
#endif |
1344 | 2010 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 2011 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2012 |
%}. |
295 | 2013 |
self primitiveFailed. |
2014 |
^ nil |
|
2015 |
! |
|
2016 |
||
2017 |
freeColor:colorIndex |
|
2018 |
"free a display color when its no longer needed" |
|
0 | 2019 |
|
2020 |
%{ /* NOCONTEXT */ |
|
2021 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
2022 |
Display *dpy; |
295 | 2023 |
unsigned long color; |
555 | 2024 |
int screen = __intVal(__INST(screen)); |
295 | 2025 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2026 |
#ifdef QUICK_TRUE_COLORS |
555 | 2027 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1344 | 2028 |
/* no need to do anything on TrueColor displays ... */ |
2029 |
RETURN (self); |
|
295 | 2030 |
} |
2031 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2032 |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2033 |
if (! ISCONNECTED) { |
1344 | 2034 |
RETURN (self); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2035 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2036 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2037 |
if (__isSmallInteger(colorIndex)) { |
1344 | 2038 |
dpy = myDpy; |
2039 |
color = (long) __intVal(colorIndex); |
|
2040 |
BEGIN_INTERRUPTSBLOCKED |
|
2041 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2042 |
#ifdef COUNT_RESOURCES |
1344 | 2043 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2044 |
#endif |
1344 | 2045 |
END_INTERRUPTSBLOCKED |
2046 |
RETURN ( self ); |
|
0 | 2047 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2048 |
%}. |
295 | 2049 |
self primitiveFailed |
2050 |
! |
|
2051 |
||
2052 |
getRGBFrom:index into:aBlock |
|
2053 |
"get rgb components (0..100) of color in map at:index, |
|
2054 |
and evaluate the 3-arg block, aBlock with them" |
|
2055 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2056 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2057 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2058 |
self getScaledRGBFrom:index into:[:r :g :b | |
1344 | 2059 |
val := aBlock |
2060 |
value:(r * 100.0 / 16rFFFF) |
|
2061 |
value:(g * 100.0 / 16rFFFF) |
|
2062 |
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
|
2063 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2064 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2065 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2066 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2067 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2068 |
"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
|
2069 |
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
|
2070 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2071 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2072 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2073 |
r isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2074 |
^ nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2075 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2076 |
val := aBlock |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2077 |
value:(r * 100.0 / 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2078 |
value:(g * 100.0 / 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2079 |
value:(b * 100.0 / 16rFFFF) |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2080 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2081 |
^ val |
1056 | 2082 |
|
1430 | 2083 |
"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
|
2084 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2085 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2086 |
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
|
2087 |
"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
|
2088 |
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
|
2089 |
|
295 | 2090 |
|r g b| |
2091 |
%{ |
|
555 | 2092 |
int screen = __intVal(__INST(screen)); |
295 | 2093 |
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
|
2094 |
int sr, sg, sb; |
295 | 2095 |
int bits, scale, shift; |
2096 |
||
1209 | 2097 |
if (ISCONNECTED |
2098 |
&& __isSmallInteger(index)) { |
|
1344 | 2099 |
Display *dpy = myDpy; |
2100 |
||
2101 |
color.pixel = __intVal(index); |
|
2102 |
BEGIN_INTERRUPTSBLOCKED |
|
2103 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2104 |
END_INTERRUPTSBLOCKED |
|
2105 |
||
2106 |
/* |
|
2107 |
* have to compensate for an error in X ?, which does not scale |
|
2108 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2109 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2110 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2111 |
*/ |
|
2112 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2113 |
scale = (1<<bits) - 1; |
|
2114 |
shift = 16 - bits; |
|
2115 |
||
2116 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2117 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2118 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2119 |
r = __MKSMALLINT(sr); |
|
2120 |
g = __MKSMALLINT(sg); |
|
2121 |
b = __MKSMALLINT(sb); |
|
295 | 2122 |
} |
2123 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2124 |
^ aBlock value:r value:g value:b |
295 | 2125 |
! |
2126 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2127 |
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
|
2128 |
"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
|
2129 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2130 |
|
2131 |
|r g b| |
|
2132 |
||
2133 |
displayId isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2134 |
self pimitiveFailed. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2135 |
^ nil |
295 | 2136 |
]. |
2137 |
%{ |
|
555 | 2138 |
int screen = __intVal(__INST(screen)); |
295 | 2139 |
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
|
2140 |
int sr, sg, sb; |
295 | 2141 |
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
|
2142 |
int bits, scale, shift; |
295 | 2143 |
|
1209 | 2144 |
if (ISCONNECTED |
2145 |
&& __isString(colorName) || __isSymbol(colorName)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2146 |
Display *dpy = myDpy; |
1209 | 2147 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2148 |
BEGIN_INTERRUPTSBLOCKED |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2149 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2150 |
(char *)_stringVal(colorName), &color)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2151 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2152 |
* 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
|
2153 |
* 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
|
2154 |
* (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
|
2155 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2156 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2157 |
bits = __intVal(__INST(bitsPerRGB)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2158 |
scale = (1<<bits) - 1; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2159 |
shift = 16 - bits; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2160 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2161 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2162 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2163 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2164 |
r = __MKSMALLINT(sr); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2165 |
g = __MKSMALLINT(sg); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2166 |
b = __MKSMALLINT(sb); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2167 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2168 |
END_INTERRUPTSBLOCKED |
295 | 2169 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2170 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2171 |
^ aBlock value:r value:g value:b |
295 | 2172 |
! |
2173 |
||
2174 |
listOfAvailableColors |
|
2175 |
"return a list of all available colornames. |
|
2176 |
This should not be used, since colornames are very |
|
2177 |
display-specific (here X-specific)." |
|
2178 |
||
2179 |
|aStream list line index colorName| |
|
2180 |
||
2181 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2182 |
aStream isNil ifTrue:[^ nil]. |
|
2183 |
list := OrderedCollection new. |
|
2184 |
[aStream atEnd] whileFalse:[ |
|
1344 | 2185 |
line := aStream nextLine. |
2186 |
line notNil ifTrue:[ |
|
2187 |
"skip the r/g/b numbers" |
|
2188 |
index := 1. |
|
2189 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2190 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2191 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2192 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2193 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2194 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2195 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2196 |
colorName := line copyFrom:index. |
|
2197 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2198 |
list add:colorName |
|
2199 |
] |
|
2200 |
] |
|
295 | 2201 |
]. |
2202 |
aStream close. |
|
2203 |
^ list sort |
|
1047 | 2204 |
|
2205 |
" |
|
2206 |
Screen current listOfAvailableColors |
|
2207 |
" |
|
2208 |
||
2209 |
"Modified: 11.9.1996 / 15:26:28 / stefan" |
|
295 | 2210 |
! |
2211 |
||
2212 |
percentToXColorValue:aPercentage |
|
2213 |
"given a color-component value in percent (0..100), return the corresponding |
|
2214 |
x-component value (0..65k) as an integer" |
|
2215 |
||
2216 |
%{ /* NOCONTEXT */ |
|
2217 |
||
2218 |
if (__isSmallInteger(aPercentage)) { |
|
1344 | 2219 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2220 |
} |
2221 |
if (__isFloat(aPercentage)) { |
|
1344 | 2222 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2223 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2224 |
%}. |
295 | 2225 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2226 |
! |
2227 |
||
892 | 2228 |
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
|
2229 |
"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
|
2230 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2231 |
|
2232 |
%{ /* NOCONTEXT */ |
|
2233 |
||
2234 |
char *colorname; |
|
2235 |
XColor color; |
|
555 | 2236 |
int screen = __intVal(__INST(screen)); |
0 | 2237 |
int r, g, b; |
2238 |
int ok = 1; |
|
2239 |
||
892 | 2240 |
if (__isSmallInteger(sred)) |
1344 | 2241 |
r = __intVal(sred); |
0 | 2242 |
else ok = 0; |
2243 |
||
892 | 2244 |
if (__isSmallInteger(sgreen)) |
1344 | 2245 |
g = __intVal(sgreen); |
0 | 2246 |
else ok = 0; |
2247 |
||
892 | 2248 |
if (__isSmallInteger(sblue)) |
1344 | 2249 |
b = __intVal(sblue); |
0 | 2250 |
else ok = 0; |
2251 |
||
1209 | 2252 |
if (ISCONNECTED |
2253 |
&& __isSmallInteger(index) && ok) { |
|
1344 | 2254 |
Display *dpy = myDpy; |
2255 |
||
2256 |
color.pixel = __intVal(index); |
|
2257 |
color.red = r; |
|
2258 |
color.green = g; |
|
2259 |
color.blue = b; |
|
2260 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2261 |
||
2262 |
BEGIN_INTERRUPTSBLOCKED |
|
2263 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2264 |
END_INTERRUPTSBLOCKED |
|
2265 |
RETURN ( self ); |
|
0 | 2266 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2267 |
%}. |
0 | 2268 |
self primitiveFailed |
295 | 2269 |
! ! |
2270 |
||
2271 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2272 |
||
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2273 |
builtInCursorShapes |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2274 |
"return a collection of standard cursor names. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2275 |
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
|
2276 |
user cursors. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2277 |
(actually, there are more than those below ...)" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2278 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2279 |
"/ 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
|
2280 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2281 |
^ #( |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2282 |
#upLeftArrow "/ XC_top_left_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2283 |
#upRightHand "/ XC_hand1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2284 |
#upDownArrow "/ XC_sb_v_double_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2285 |
#leftRightArrow "/ XC_sb_h_double_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2286 |
#upLimitArrow "/ XC_top_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2287 |
#downLimitArrow "/ XC_bottom_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2288 |
#leftLimitArrow "/ XC_left_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2289 |
#rightLimitArrow "/ XC_right_side |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2290 |
#text "/ XC_xterm |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2291 |
#upRightArrow "/ XC_draft_large |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2292 |
#leftHand "/ XC_hand2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2293 |
#questionMark "/ XC_question_arrow |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2294 |
#cross "/ XC_X_cursor |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2295 |
#wait "/ XC_watch |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2296 |
#crossHair "/ XC_tcross |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2297 |
#origin "/ XC_ul_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2298 |
#topLeft "/ XC_ul_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2299 |
#corner "/ XC_lr_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2300 |
#bottomRight "/ XC_lr_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2301 |
#topRight "/ XC_ur_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2302 |
#bottomLeft "/ XC_ll_angle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2303 |
#square "/ XC_dotbox |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2304 |
#fourWay "/ XC_fleur |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2305 |
#crossCursor "/ XC_X_cursor |
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2306 |
) |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2307 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2308 |
"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
|
2309 |
"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
|
2310 |
! |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2311 |
|
295 | 2312 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
2313 |
"change a cursors colors" |
|
2314 |
||
2315 |
|fgR fgG fgB bgR bgG bgB| |
|
2316 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2317 |
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
|
2318 |
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
|
2319 |
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
|
2320 |
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
|
2321 |
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
|
2322 |
bgB := bgColor scaledBlue. |
0 | 2323 |
%{ |
295 | 2324 |
XColor fgcolor, bgcolor; |
2325 |
||
1209 | 2326 |
if (ISCONNECTED |
2327 |
&& __isExternalAddress(aCursorId) |
|
295 | 2328 |
&& __bothSmallInteger(fgG, fgB) |
2329 |
&& __bothSmallInteger(bgR, bgG) |
|
2330 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2331 |
||
1344 | 2332 |
fgcolor.red = __intVal(fgR); |
2333 |
fgcolor.green= __intVal(fgG); |
|
2334 |
fgcolor.blue = __intVal(fgB); |
|
2335 |
bgcolor.red = __intVal(bgR); |
|
2336 |
bgcolor.green= __intVal(bgG); |
|
2337 |
bgcolor.blue = __intVal(bgB); |
|
2338 |
BEGIN_INTERRUPTSBLOCKED |
|
2339 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
2340 |
END_INTERRUPTSBLOCKED |
|
2341 |
RETURN ( self ); |
|
72 | 2342 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2343 |
%}. |
0 | 2344 |
self primitiveFailed |
70 | 2345 |
! |
2346 |
||
295 | 2347 |
createCursorShape:aShape |
974 | 2348 |
"create a cursor given a shape-symbol. This only works |
2349 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2350 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2351 |
|
2352 |
|number id| |
|
2353 |
||
2354 |
displayId isNil ifTrue:[ |
|
1344 | 2355 |
self primitiveFailed. |
2356 |
^ nil |
|
295 | 2357 |
]. |
2358 |
number := self shapeNumberFromSymbol:aShape. |
|
2359 |
%{ |
|
2360 |
Cursor newCursor; |
|
2361 |
||
1209 | 2362 |
if (ISCONNECTED |
2363 |
&& __isSmallInteger(number)) { |
|
1344 | 2364 |
BEGIN_INTERRUPTSBLOCKED |
2365 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2366 |
#ifdef COUNT_RESOURCES |
1344 | 2367 |
if (newCursor) |
2368 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2369 |
#endif |
1344 | 2370 |
END_INTERRUPTSBLOCKED |
2371 |
if (newCursor != (Cursor)0) { |
|
2372 |
id = __MKOBJ(newCursor); |
|
2373 |
} |
|
0 | 2374 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2375 |
%}. |
295 | 2376 |
^ id |
2377 |
! |
|
2378 |
||
974 | 2379 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2380 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2381 |
||
2382 |
|id sourceId maskId| |
|
2383 |
||
2384 |
displayId isNil ifTrue:[ |
|
1344 | 2385 |
self primitiveFailed. |
2386 |
^ nil |
|
295 | 2387 |
]. |
2388 |
sourceId := sourceForm id. |
|
2389 |
maskId := maskForm id. |
|
2390 |
%{ |
|
2391 |
Cursor newCursor; |
|
2392 |
XColor fgColor, bgColor; |
|
2393 |
||
1209 | 2394 |
if (ISCONNECTED |
2395 |
&& __isExternalAddress(sourceId) |
|
295 | 2396 |
&& __isExternalAddress(maskId) |
2397 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2398 |
fgColor.red = 0; /* fg is black */ |
2399 |
fgColor.green = 0; |
|
2400 |
fgColor.blue = 0; |
|
2401 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2402 |
bgColor.green = 0xFFFF; |
|
2403 |
bgColor.blue = 0xFFFF; |
|
2404 |
||
2405 |
BEGIN_INTERRUPTSBLOCKED |
|
2406 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2407 |
_PixmapVal(sourceId), |
|
2408 |
_PixmapVal(maskId), |
|
2409 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2410 |
#ifdef COUNT_RESOURCES |
1344 | 2411 |
if (newCursor) |
2412 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2413 |
#endif |
1344 | 2414 |
END_INTERRUPTSBLOCKED |
2415 |
if (newCursor != (Cursor)0) { |
|
2416 |
id = __MKOBJ(newCursor); |
|
2417 |
} |
|
0 | 2418 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2419 |
%}. |
295 | 2420 |
^ id |
2421 |
! |
|
2422 |
||
2423 |
destroyCursor:aCursorId |
|
974 | 2424 |
"release a cursor - frees any device resources" |
0 | 2425 |
|
2426 |
%{ /* NOCONTEXT */ |
|
2427 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2428 |
if (! ISCONNECTED) { |
1344 | 2429 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2430 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2431 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2432 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2433 |
Cursor curs = _CursorVal(aCursorId); |
2434 |
||
2435 |
if (curs) { |
|
2436 |
BEGIN_INTERRUPTSBLOCKED |
|
2437 |
XFreeCursor(myDpy, curs); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2438 |
#ifdef COUNT_RESOURCES |
1344 | 2439 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2440 |
#endif |
1344 | 2441 |
END_INTERRUPTSBLOCKED |
2442 |
} |
|
2443 |
RETURN ( self ); |
|
0 | 2444 |
} |
974 | 2445 |
%}. |
0 | 2446 |
self primitiveFailed |
295 | 2447 |
! |
2448 |
||
974 | 2449 |
needDeviceFormsForCursor |
2450 |
^ true |
|
2451 |
! |
|
2452 |
||
295 | 2453 |
shapeNumberFromSymbol:shape |
974 | 2454 |
"given a shape-symbol, return the corresponding cursor-number, |
2455 |
or nil if no such standard cursor exists." |
|
295 | 2456 |
|
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2457 |
"/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
|
2458 |
"/ 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
|
2459 |
|
295 | 2460 |
|
2461 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2462 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2463 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2464 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2465 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2466 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2467 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2468 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2469 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2470 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2471 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2472 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2473 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2474 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2475 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2476 |
((shape == #origin) |
|
2477 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2478 |
((shape == #corner) |
|
2479 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2480 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2481 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2482 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2483 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2484 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2485 |
|
2486 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2487 |
^ nil |
0 | 2488 |
! ! |
2489 |
||
1543 | 2490 |
!XWorkstation methodsFor:'drag & drop'! |
2491 |
||
1556 | 2492 |
dndDrop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
2493 |
"drop something in some alien view, using the DND protocol. |
|
2494 |
Returns false, if the drop could not be performed." |
|
2495 |
||
2496 |
|msgType dropColl anyFile anyDir anyText anyOther |
|
2497 |
dropType dropTypeCode strings sz idx val| |
|
2498 |
||
2499 |
(msgType := self atomIDOf:'DndProtocol') notNil ifTrue:[ |
|
2500 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2501 |
"/ 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
|
2502 |
"/ check for this. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2503 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2504 |
dropObjects isCollection ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2505 |
dropColl := Array with:dropObjects |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2506 |
] ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2507 |
dropColl := dropObjects |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2508 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2509 |
anyFile := anyDir := anyText := anyOther := false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2510 |
dropColl do:[:aDropObject | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2511 |
aDropObject isFileObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2512 |
aDropObject theObject isDirectory ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2513 |
anyDir := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2514 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2515 |
anyFile := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2516 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2517 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2518 |
aDropObject isTextObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2519 |
anyText := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2520 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2521 |
anyOther := true |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2522 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2523 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2524 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2525 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2526 |
anyOther ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2527 |
"/ DND does not support this ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2528 |
'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
|
2529 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2530 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2531 |
anyText ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2532 |
(anyFile or:[anyDir]) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2533 |
"/ DND does not support mixed types |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2534 |
'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
|
2535 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2536 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2537 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2538 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2539 |
anyFile ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2540 |
dropType := #DndFiles. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2541 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2542 |
dropType := #DndFile |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2543 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2544 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2545 |
anyDir ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2546 |
dropType := #DndFiles. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2547 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2548 |
dropType := #DndDir |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2549 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2550 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2551 |
anyText ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2552 |
dropColl size == 1 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2553 |
dropType := #DndText |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2554 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2555 |
"/ can only drop a single text object |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2556 |
'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
|
2557 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2558 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2559 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2560 |
"/ mhmh ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2561 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2562 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2563 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2564 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2565 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2566 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2567 |
dropTypeCode := self dndDropTypes indexOf:dropType. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2568 |
dropTypeCode == 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2569 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2570 |
^ false |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2571 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2572 |
dropTypeCode := dropTypeCode - 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2573 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2574 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2575 |
"/ place the selection inTo the DndSelection property |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2576 |
"/ of the rootView ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2577 |
"/ ... need a single string, with 0-terminated parts. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2578 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2579 |
strings := OrderedCollection new. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2580 |
sz := 0. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2581 |
dropColl do:[:anObject | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2582 |
|s| |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2583 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2584 |
anObject isFileObject ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2585 |
s := anObject theObject pathName asString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2586 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2587 |
s := anObject theObject asString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2588 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2589 |
strings add:s. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2590 |
sz := sz + (s size) + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2591 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2592 |
val := String new:sz. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2593 |
idx := 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2594 |
strings do:[:aString | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2595 |
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
|
2596 |
idx := idx + aString size. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2597 |
val at:idx put:(Character value:0). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2598 |
idx := idx + 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2599 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2600 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2601 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2602 |
setProperty:(self atomIDOf:'DndSelection') |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2603 |
type:(stringAtom) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2604 |
value:val |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2605 |
for:rootId. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2606 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2607 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2608 |
sendClientEvent:msgType |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2609 |
format:32 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2610 |
to:destinationId |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2611 |
data1:dropTypeCode |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2612 |
data2:0 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2613 |
data3:(destinationId) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2614 |
data4:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2615 |
data5:nil. |
1556 | 2616 |
]. |
2617 |
||
2618 |
^ false |
|
2619 |
||
2620 |
"Created: 6.4.1997 / 13:39:37 / cg" |
|
1558 | 2621 |
"Modified: 6.4.1997 / 14:30:43 / cg" |
1556 | 2622 |
! |
2623 |
||
2624 |
dndDropTypes |
|
2625 |
"return the dropTypes as supported by DND" |
|
2626 |
||
2627 |
^ #( |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2628 |
DndUnknown "/ 0 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2629 |
DndRawData "/ 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2630 |
DndFile "/ 2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2631 |
DndFiles "/ 3 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2632 |
DndText "/ 4 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2633 |
DndDir "/ 5 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2634 |
DndLink "/ 6 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2635 |
DndExe "/ 7 |
1556 | 2636 |
) |
2637 |
||
2638 |
"Created: 6.4.1997 / 12:57:56 / cg" |
|
2639 |
"Modified: 6.4.1997 / 13:38:52 / cg" |
|
2640 |
! |
|
2641 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2642 |
drop:aCollectionOfDropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
1556 | 2643 |
"drop something in some alien view. |
2644 |
Returns false, if the drop could not be performed." |
|
2645 |
||
2646 |
"/ |
|
1543 | 2647 |
"/ see, if the display supports the DND protocol ... |
1556 | 2648 |
"/ |
1543 | 2649 |
(self atomIDOf:'DndProtocol') notNil ifTrue:[ |
1694 | 2650 |
^ self |
2651 |
dndDrop:aCollectionOfDropObjects |
|
2652 |
inWindowID:destinationId |
|
2653 |
position:destinationPoint |
|
2654 |
rootPosition:rootPoint |
|
1543 | 2655 |
]. |
2656 |
||
1556 | 2657 |
"/ add more drag&drop protocols here. |
2658 |
||
2659 |
^ false |
|
2660 |
||
1583
ca6e6732dc29
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1579
diff
changeset
|
2661 |
"Modified: 11.4.1997 / 12:44:50 / cg" |
1543 | 2662 |
! ! |
2663 |
||
0 | 2664 |
!XWorkstation methodsFor:'drawing'! |
2665 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2666 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2667 |
"do a bit-blt; copy bits from the rectangle defined by |
2668 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2669 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2670 |
argument is not integer." |
|
0 | 2671 |
|
2672 |
%{ /* NOCONTEXT */ |
|
2673 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2674 |
GC gc; |
0 | 2675 |
Drawable source, dest; |
2676 |
||
1209 | 2677 |
if (ISCONNECTED |
2678 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2679 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2680 |
&& __isExternalAddress(destId) |
97 | 2681 |
&& __bothSmallInteger(w, h) |
2682 |
&& __bothSmallInteger(srcX, srcY) |
|
2683 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2684 |
gc = _GCVal(dstGCId); |
2685 |
source = (Drawable) _WindowVal(sourceId); |
|
2686 |
dest = (Drawable) _WindowVal(destId); |
|
2687 |
XCopyArea(myDpy, source, dest, gc, |
|
2688 |
__intVal(srcX), __intVal(srcY), |
|
2689 |
__intVal(w), __intVal(h), |
|
2690 |
__intVal(dstX), __intVal(dstY)); |
|
2691 |
RETURN ( self ); |
|
0 | 2692 |
} |
118 | 2693 |
%}. |
2694 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2695 |
or any non integer coordinate" |
|
2696 |
||
0 | 2697 |
self primitiveFailed |
2698 |
! |
|
2699 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2700 |
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
|
2701 |
"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
|
2702 |
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
|
2703 |
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
|
2704 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2705 |
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
|
2706 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2707 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2708 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2709 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2710 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2711 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2712 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2713 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2714 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2715 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2716 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2717 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2718 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2719 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2720 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2721 |
gc = _GCVal(dstGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2722 |
source = (Drawable) _WindowVal(sourceId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2723 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2724 |
XSetGraphicsExposures(dpy, gc, 0); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2725 |
XCopyArea(dpy, source, dest, gc, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2726 |
__intVal(srcX), __intVal(srcY), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2727 |
__intVal(w), __intVal(h), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2728 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2729 |
XSetGraphicsExposures(dpy, gc, 1); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2730 |
RETURN ( self ); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2731 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2732 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2733 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2734 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2735 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2736 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2737 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2738 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2739 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2740 |
"do a bit-blt, but only copy the low-bit plane; |
2741 |
copy bits from the rectangle defined by |
|
2742 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2743 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2744 |
argument is not integer." |
|
0 | 2745 |
|
2746 |
%{ /* NOCONTEXT */ |
|
2747 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2748 |
GC gc; |
0 | 2749 |
Drawable source, dest; |
2750 |
||
1209 | 2751 |
if (ISCONNECTED |
2752 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2753 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2754 |
&& __isExternalAddress(destId) |
97 | 2755 |
&& __bothSmallInteger(w, h) |
2756 |
&& __bothSmallInteger(srcX, srcY) |
|
2757 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2758 |
gc = _GCVal(dstGCId); |
2759 |
source = (Drawable) _WindowVal(sourceId); |
|
2760 |
dest = (Drawable) _WindowVal(destId); |
|
2761 |
XCopyPlane(myDpy, source, dest, gc, |
|
2762 |
__intVal(srcX), __intVal(srcY), |
|
2763 |
__intVal(w), __intVal(h), |
|
2764 |
__intVal(dstX), __intVal(dstY), 1); |
|
2765 |
RETURN ( self ); |
|
0 | 2766 |
} |
118 | 2767 |
%}. |
2768 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2769 |
or any non integer coordinate" |
|
2770 |
||
0 | 2771 |
self primitiveFailed |
2772 |
! |
|
2773 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2774 |
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
|
2775 |
"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
|
2776 |
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
|
2777 |
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
|
2778 |
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
|
2779 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2780 |
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
|
2781 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2782 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2783 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2784 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2785 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2786 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2787 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2788 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2789 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2790 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2791 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2792 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2793 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2794 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2795 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2796 |
gc = _GCVal(dstGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2797 |
source = (Drawable) _WindowVal(sourceId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2798 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2799 |
XSetGraphicsExposures(dpy, gc, 0); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2800 |
XCopyPlane(dpy, source, dest, gc, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2801 |
__intVal(srcX), __intVal(srcY), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2802 |
__intVal(w), __intVal(h), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2803 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2804 |
XSetGraphicsExposures(dpy, gc, 1); |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2805 |
RETURN ( self ); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2806 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2807 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2808 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2809 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2810 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2811 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2812 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2813 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2814 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2815 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2816 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2817 |
|
2818 |
%{ /* NOCONTEXT */ |
|
2819 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2820 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2821 |
Window win; |
0 | 2822 |
int w, h, angle1, angle2; |
2823 |
double f; |
|
2824 |
||
97 | 2825 |
if (__isSmallInteger(startAngle)) |
1344 | 2826 |
angle1 = __intVal(startAngle) * 64; |
36 | 2827 |
else if (__isFloat(startAngle)) { |
1344 | 2828 |
f = __floatVal(startAngle); |
2829 |
angle1 = f * 64; |
|
0 | 2830 |
} |
97 | 2831 |
if (__isSmallInteger(angle)) |
1344 | 2832 |
angle2 = __intVal(angle) * 64; |
36 | 2833 |
else if (__isFloat(angle)) { |
1344 | 2834 |
f = __floatVal(angle); |
2835 |
angle2 = f * 64; |
|
0 | 2836 |
} |
1209 | 2837 |
if (ISCONNECTED |
2838 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2839 |
&& __isExternalAddress(aDrawableId) |
97 | 2840 |
&& __bothSmallInteger(x, y) |
2841 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2842 |
win = _WindowVal(aDrawableId); |
2843 |
gc = _GCVal(aGCId); |
|
2844 |
w = __intVal(width); |
|
2845 |
h = __intVal(height); |
|
2846 |
/* |
|
2847 |
* need this check here: some servers simply dump core with bad args |
|
2848 |
*/ |
|
2849 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2850 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2851 |
w, h, angle1, angle2); |
|
2852 |
} |
|
2853 |
RETURN ( self ); |
|
0 | 2854 |
} |
73 | 2855 |
%}. |
2856 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2857 |
self primitiveFailed |
2858 |
! |
|
2859 |
||
295 | 2860 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2861 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2862 |
||
2863 |
%{ /* NOCONTEXT */ |
|
2864 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2865 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2866 |
Window win; |
295 | 2867 |
|
1209 | 2868 |
if (ISCONNECTED |
2869 |
&& __isExternalAddress(aGCId) |
|
295 | 2870 |
&& __isExternalAddress(aDrawableId) |
2871 |
&& __bothSmallInteger(x0, y0) |
|
2872 |
&& __bothSmallInteger(x1, y1)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2873 |
gc = _GCVal(aGCId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2874 |
win = _WindowVal(aDrawableId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2875 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2876 |
if ((x0 == x1) && (y0 == y1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2877 |
XDrawPoint(myDpy, win, gc, __intVal(x0), __intVal(y0)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2878 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2879 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2880 |
__intVal(x1), __intVal(y1)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2881 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
2882 |
RETURN ( self ); |
295 | 2883 |
} |
2884 |
%}. |
|
2885 |
"badGC, badDrawable or coordinates not integer" |
|
2886 |
self primitiveFailed |
|
2887 |
! |
|
2888 |
||
2889 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2890 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2891 |
||
2892 |
%{ /* NOCONTEXT */ |
|
2893 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2894 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2895 |
Window win; |
295 | 2896 |
|
1209 | 2897 |
if (ISCONNECTED |
2898 |
&& __isExternalAddress(aGCId) |
|
295 | 2899 |
&& __isExternalAddress(aDrawableId) |
2900 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2901 |
gc = _GCVal(aGCId); |
2902 |
win = _WindowVal(aDrawableId); |
|
2903 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
|
2904 |
RETURN ( self ); |
|
295 | 2905 |
} |
2906 |
%}. |
|
2907 |
"badGC, badDrawable or x/y not integer" |
|
2908 |
self primitiveFailed |
|
2909 |
! |
|
2910 |
||
2911 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2912 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2913 |
define the polygon. |
|
2914 |
If any coordinate is not integer, an error is triggered." |
|
2915 |
||
2916 |
|numberOfPoints newPoints| |
|
2917 |
||
2918 |
numberOfPoints := aPolygon size. |
|
2919 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2920 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2921 |
Window win; |
295 | 2922 |
OBJ point, x, y; |
2923 |
int i, num; |
|
2924 |
XPoint *points; |
|
2925 |
XPoint qPoints[100]; |
|
377 | 2926 |
int mustFree = 0; |
295 | 2927 |
|
1209 | 2928 |
if (ISCONNECTED |
2929 |
&& __isExternalAddress(aGCId) |
|
295 | 2930 |
&& __isExternalAddress(aDrawableId) |
2931 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 2932 |
gc = _GCVal(aGCId); |
2933 |
win = _WindowVal(aDrawableId); |
|
2934 |
num = __intVal(numberOfPoints); |
|
2935 |
/* |
|
2936 |
* avoid a (slow) malloc, if the number of points is small |
|
2937 |
*/ |
|
2938 |
if (num > 100) { |
|
2939 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2940 |
if (! points) goto fail; |
|
2941 |
mustFree = 1; |
|
2942 |
} else |
|
2943 |
points = qPoints; |
|
2944 |
||
2945 |
for (i=0; i<num; i++) { |
|
2946 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2947 |
if (! __isPoint(point)) goto fail; |
|
2948 |
x = _point_X(point); |
|
2949 |
y = _point_Y(point); |
|
2950 |
if (! __bothSmallInteger(x, y)) |
|
2951 |
goto fail; |
|
2952 |
points[i].x = __intVal(x); |
|
2953 |
points[i].y = __intVal(y); |
|
2954 |
} |
|
2955 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
2956 |
if (mustFree) |
|
2957 |
free(points); |
|
2958 |
RETURN ( self ); |
|
295 | 2959 |
} |
2960 |
fail: ; |
|
377 | 2961 |
if (mustFree) |
1344 | 2962 |
free(points); |
295 | 2963 |
%}. |
2964 |
"badGC, badDrawable or coordinates not integer" |
|
2965 |
self primitiveFailed |
|
2966 |
! |
|
2967 |
||
2968 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2969 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2970 |
||
2971 |
%{ /* NOCONTEXT */ |
|
2972 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2973 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2974 |
Window win; |
295 | 2975 |
int w, h; |
2976 |
||
1209 | 2977 |
if (ISCONNECTED |
2978 |
&& __isExternalAddress(aGCId) |
|
295 | 2979 |
&& __isExternalAddress(aDrawableId) |
2980 |
&& __bothSmallInteger(x, y) |
|
2981 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2982 |
gc = _GCVal(aGCId); |
2983 |
win = _WindowVal(aDrawableId); |
|
2984 |
w = __intVal(width); |
|
2985 |
h = __intVal(height); |
|
2986 |
/* |
|
2987 |
* need this check here: some servers simply dump core with bad args |
|
2988 |
*/ |
|
2989 |
if ((w >= 0) && (h >= 0)) { |
|
2990 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
|
2991 |
} |
|
2992 |
RETURN ( self ); |
|
295 | 2993 |
} |
2994 |
%}. |
|
2995 |
"badGC, badDrawable or coordinates not integer" |
|
2996 |
self primitiveFailed |
|
2997 |
! |
|
2998 |
||
2999 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3000 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
3001 |
foreground and background characters. |
|
3002 |
If the coordinates are not integers, an error is triggered." |
|
3003 |
||
3004 |
%{ /* NOCONTEXT */ |
|
3005 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3006 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3007 |
Window win; |
295 | 3008 |
unsigned char *cp; |
3009 |
OBJ cls; |
|
3010 |
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
|
3011 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3012 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3013 |
int nInstBytes; |
295 | 3014 |
|
1209 | 3015 |
if (ISCONNECTED |
3016 |
&& __isExternalAddress(aGCId) |
|
295 | 3017 |
&& __isExternalAddress(aDrawableId) |
3018 |
&& __isNonNilObject(aString) |
|
3019 |
&& __bothSmallInteger(index1, index2) |
|
3020 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3021 |
gc = _GCVal(aGCId); |
3022 |
win = _WindowVal(aDrawableId); |
|
3023 |
cls = __qClass(aString); |
|
3024 |
||
3025 |
i1 = __intVal(index1) - 1; |
|
3026 |
if (i1 >= 0) { |
|
3027 |
i2 = __intVal(index2) - 1; |
|
3028 |
if (i2 < i1) { |
|
3029 |
RETURN (self); |
|
3030 |
} |
|
3031 |
||
3032 |
cp = _stringVal(aString); |
|
3033 |
l = i2 - i1 + 1; |
|
3034 |
||
3035 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3036 |
n = _stringSize(aString); |
|
3037 |
if (i2 < n) { |
|
3038 |
cp += i1; |
|
3039 |
if (l > 1000) l = 1000; |
|
3040 |
if (opaque == true) |
|
3041 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3042 |
else |
|
3043 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3044 |
RETURN ( self ); |
|
3045 |
} |
|
3046 |
} |
|
3047 |
||
3048 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3049 |
cp += nInstBytes; |
|
3050 |
||
3051 |
if (__isBytes(aString)) { |
|
3052 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3053 |
||
3054 |
if (i2 < n) { |
|
3055 |
cp += i1; |
|
3056 |
if (l > 1000) l = 1000; |
|
3057 |
if (opaque == true) |
|
3058 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3059 |
else |
|
3060 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3061 |
RETURN ( self ); |
|
3062 |
} |
|
3063 |
} |
|
3064 |
||
3065 |
/* TWOBYTESTRINGS */ |
|
3066 |
if (__isWords(aString)) { |
|
3067 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3068 |
||
3069 |
if (i2 < n) { |
|
3070 |
union { |
|
3071 |
char b[2]; |
|
3072 |
unsigned short s; |
|
3073 |
} u; |
|
3074 |
int i; |
|
3075 |
XChar2b *cp2 = (XChar2b *)0; |
|
3076 |
int mustFree = 0; |
|
3077 |
||
3078 |
cp += (i1 * 2); |
|
3079 |
if (l > 1000) l = 1000; |
|
3080 |
||
3081 |
/* |
|
3082 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3083 |
* X expects them MSB first |
|
3084 |
* convert as required |
|
3085 |
*/ |
|
3086 |
||
3087 |
u.s = 0x1234; |
|
3088 |
if (u.b[0] != 0x12) { |
|
3089 |
if (l <= NLOCALBUFFER) { |
|
3090 |
cp2 = xlatebuffer; |
|
3091 |
} else { |
|
3092 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
3093 |
mustFree = 1; |
|
3094 |
} |
|
3095 |
for (i=0; i<l; i++) { |
|
3096 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3097 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3098 |
} |
|
3099 |
cp = (char *) cp2; |
|
3100 |
} |
|
3101 |
||
3102 |
if (opaque == true) |
|
3103 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3104 |
else |
|
3105 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3106 |
||
3107 |
if (mustFree) { |
|
3108 |
free(cp2); |
|
3109 |
} |
|
3110 |
||
3111 |
RETURN ( self ); |
|
3112 |
} |
|
3113 |
} |
|
3114 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3115 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3116 |
#undef NLOCALBUFFER |
295 | 3117 |
%}. |
3118 |
"x/y not integer, badGC or drawable, or not a string" |
|
3119 |
self primitiveFailed |
|
3120 |
! |
|
3121 |
||
3122 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3123 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
3124 |
foreground and background characters. |
|
3125 |
If the coordinates are not integers, an error is triggered." |
|
3126 |
||
3127 |
%{ /* NOCONTEXT */ |
|
3128 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3129 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3130 |
Window win; |
295 | 3131 |
unsigned char *cp; |
3132 |
int n; |
|
3133 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3134 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3135 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3136 |
int nInstBytes; |
295 | 3137 |
|
1209 | 3138 |
if (ISCONNECTED |
3139 |
&& __isExternalAddress(aGCId) |
|
295 | 3140 |
&& __isExternalAddress(aDrawableId) |
3141 |
&& __isNonNilObject(aString) |
|
3142 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3143 |
gc = _GCVal(aGCId); |
3144 |
win = _WindowVal(aDrawableId); |
|
3145 |
cls = __qClass(aString); |
|
3146 |
||
3147 |
cp = _stringVal(aString); |
|
3148 |
||
3149 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3150 |
n = _stringSize(aString); |
|
3151 |
if (n > 1000) n = 1000; |
|
3152 |
if (opaque == true) |
|
3153 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3154 |
else |
|
3155 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3156 |
RETURN ( self ); |
|
3157 |
} |
|
3158 |
||
3159 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3160 |
cp += nInstBytes; |
|
3161 |
||
3162 |
if (__isBytes(aString)) { |
|
3163 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3164 |
||
3165 |
if (n > 1000) n = 1000; |
|
3166 |
if (opaque == true) |
|
3167 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3168 |
else |
|
3169 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3170 |
RETURN ( self ); |
|
3171 |
} |
|
3172 |
||
3173 |
/* TWOBYTESTRINGS */ |
|
3174 |
if (__isWords(aString)) { |
|
3175 |
union { |
|
3176 |
char b[2]; |
|
3177 |
unsigned short s; |
|
3178 |
} u; |
|
3179 |
int i; |
|
3180 |
XChar2b *cp2; |
|
3181 |
int mustFree = 0; |
|
3182 |
||
3183 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3184 |
if (n > 1000) n = 1000; |
|
3185 |
||
3186 |
/* |
|
3187 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3188 |
* X expects them MSB first |
|
3189 |
* convert as required |
|
3190 |
*/ |
|
3191 |
||
3192 |
u.s = 0x1234; |
|
3193 |
if (u.b[0] != 0x12) { |
|
3194 |
if (n <= NLOCALBUFFER) { |
|
3195 |
cp2 = xlatebuffer; |
|
3196 |
} else { |
|
3197 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
3198 |
mustFree = 1; |
|
3199 |
} |
|
3200 |
||
3201 |
for (i=0; i<n; i++) { |
|
3202 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3203 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3204 |
} |
|
3205 |
cp = (char *) cp2; |
|
3206 |
} |
|
3207 |
||
3208 |
if (opaque == true) |
|
3209 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3210 |
else |
|
3211 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3212 |
||
3213 |
||
3214 |
if (mustFree) { |
|
3215 |
free(cp2); |
|
3216 |
} |
|
3217 |
||
3218 |
RETURN ( self ); |
|
3219 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3220 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3221 |
#undef NLOCALBUFFER |
295 | 3222 |
%}. |
3223 |
"x/y not integer, badGC or drawable, or not a string" |
|
3224 |
self primitiveFailed |
|
3225 |
! |
|
3226 |
||
3227 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3228 |
width:imageWidth height:imageHeight |
3229 |
x:srcx y:srcy |
|
3230 |
into:aDrawableId |
|
3231 |
x:dstx y:dsty |
|
3232 |
width:w height:h |
|
3233 |
with:aGCId |
|
295 | 3234 |
|
3235 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3236 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3237 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3238 |
depth and pixel-units to be different. |
|
3239 |
It has to be checked elsewhere, that the server can do it with the given |
|
3240 |
depth - otherwise, primitive failure will be signalled. |
|
3241 |
Also it is assumed, that the colormap is setup correctly and the |
|
3242 |
colors are allocated - otherwise the colors may be wrong." |
|
3243 |
||
3244 |
" |
|
3245 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3246 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3247 |
" |
|
3248 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3249 |
width:imageWidth height:imageHeight |
3250 |
x:srcx y:srcy |
|
3251 |
into:aDrawableId |
|
3252 |
x:dstx y:dsty |
|
3253 |
width:w height:h |
|
3254 |
with:aGCId) |
|
295 | 3255 |
ifFalse:[ |
1344 | 3256 |
" |
3257 |
also happens, if a segmentation violation occurs in the |
|
3258 |
XPutImage ... |
|
3259 |
" |
|
3260 |
self primitiveFailed |
|
295 | 3261 |
]. |
3262 |
! |
|
3263 |
||
3264 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3265 |
width:imageWidth height:imageHeight |
3266 |
x:srcx y:srcy |
|
3267 |
into:aDrawableId |
|
3268 |
x:dstx y:dsty |
|
3269 |
width:w height:h |
|
3270 |
with:aGCId |
|
295 | 3271 |
|
3272 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3273 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3274 |
Individual source pixels must have imageDepth bits. |
|
3275 |
It has to be checked elsewhere, that the server can do it with the given |
|
3276 |
depth - otherwise, primitive failure will be signalled. |
|
3277 |
Also it is assumed, that the colormap is setup correctly and the |
|
3278 |
colors are allocated - otherwise the colors may be wrong." |
|
3279 |
||
3280 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3281 |
width:imageWidth height:imageHeight |
3282 |
x:srcx y:srcy |
|
3283 |
into:aDrawableId |
|
3284 |
x:dstx y:dsty |
|
3285 |
width:w height:h |
|
3286 |
with:aGCId |
|
295 | 3287 |
|
3288 |
! |
|
3289 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3290 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3291 |
in:aDrawableId with:aGCId |
90 | 3292 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3293 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3294 |
|
3295 |
%{ /* NOCONTEXT */ |
|
3296 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3297 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3298 |
Window win; |
0 | 3299 |
int w, h, angle1, angle2; |
3300 |
double f; |
|
3301 |
||
97 | 3302 |
if (__isSmallInteger(startAngle)) |
1344 | 3303 |
angle1 = __intVal(startAngle) * 64; |
36 | 3304 |
else if (__isFloat(startAngle)) { |
1344 | 3305 |
f = __floatVal(startAngle); |
3306 |
angle1 = f * 64; |
|
0 | 3307 |
} |
97 | 3308 |
if (__isSmallInteger(angle)) |
1344 | 3309 |
angle2 = __intVal(angle) * 64; |
36 | 3310 |
else if (__isFloat(angle)) { |
1344 | 3311 |
f = __floatVal(angle); |
3312 |
angle2 = f * 64; |
|
0 | 3313 |
} |
1209 | 3314 |
if (ISCONNECTED |
3315 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3316 |
&& __isExternalAddress(aDrawableId) |
97 | 3317 |
&& __bothSmallInteger(x, y) |
3318 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3319 |
gc = _GCVal(aGCId); |
3320 |
win = _WindowVal(aDrawableId); |
|
3321 |
w = __intVal(width); |
|
3322 |
h = __intVal(height); |
|
3323 |
/* |
|
3324 |
* need this check here: some servers simply dump core with bad args |
|
3325 |
*/ |
|
3326 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
3327 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
3328 |
w, h, angle1, angle2); |
|
3329 |
} |
|
3330 |
RETURN ( self ); |
|
0 | 3331 |
} |
73 | 3332 |
%}. |
3333 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3334 |
self primitiveFailed |
3335 |
! |
|
3336 |
||
3337 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3338 |
"fill a polygon given by its points. |
3339 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3340 |
|
3341 |
|numberOfPoints| |
|
0 | 3342 |
|
3343 |
numberOfPoints := aPolygon size. |
|
3344 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3345 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3346 |
Window win; |
73 | 3347 |
OBJ point, x, y; |
3348 |
int i, num; |
|
3349 |
XPoint *points; |
|
3350 |
XPoint qPoints[100]; |
|
377 | 3351 |
int mustFree = 0; |
73 | 3352 |
|
1209 | 3353 |
if (ISCONNECTED |
3354 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3355 |
&& __isExternalAddress(aDrawableId) |
97 | 3356 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3357 |
gc = _GCVal(aGCId); |
3358 |
win = _WindowVal(aDrawableId); |
|
3359 |
num = __intVal(numberOfPoints); |
|
3360 |
if (num < 3) { |
|
3361 |
RETURN ( self ); |
|
3362 |
} |
|
3363 |
/* |
|
3364 |
* avoid (slow) malloc, if not many points |
|
3365 |
*/ |
|
3366 |
if (num > 100) { |
|
3367 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3368 |
if (! points) goto fail; |
|
3369 |
mustFree = 1; |
|
3370 |
} else |
|
3371 |
points = qPoints; |
|
3372 |
for (i=0; i<num; i++) { |
|
3373 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3374 |
if (! __isPoint(point)) goto fail; |
|
3375 |
x = _point_X(point); |
|
3376 |
y = _point_Y(point); |
|
3377 |
if (! __bothSmallInteger(x, y)) |
|
3378 |
goto fail; |
|
3379 |
points[i].x = __intVal(x); |
|
3380 |
points[i].y = __intVal(y); |
|
3381 |
} |
|
3382 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
3383 |
if (mustFree) |
|
3384 |
free(points); |
|
3385 |
RETURN ( self ); |
|
377 | 3386 |
|
0 | 3387 |
fail: ; |
1344 | 3388 |
if (mustFree) |
3389 |
free(points); |
|
0 | 3390 |
} |
73 | 3391 |
%}. |
3392 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3393 |
self primitiveFailed |
3394 |
! |
|
3395 |
||
295 | 3396 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3397 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3398 |
||
3399 |
%{ /* NOCONTEXT */ |
|
3400 |
||
3401 |
int w, h; |
|
3402 |
||
1209 | 3403 |
if (ISCONNECTED |
3404 |
&& __isExternalAddress(aGCId) |
|
295 | 3405 |
&& __isExternalAddress(aDrawableId) |
3406 |
&& __bothSmallInteger(x, y) |
|
3407 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3408 |
w = __intVal(width); |
3409 |
h = __intVal(height); |
|
3410 |
/* |
|
3411 |
* need this check here: some servers simply dump core with bad args |
|
3412 |
*/ |
|
3413 |
if ((w >= 0) && (h >= 0)) { |
|
3414 |
XFillRectangle(myDpy, |
|
3415 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3416 |
__intVal(x), __intVal(y), w, h); |
|
3417 |
} |
|
3418 |
RETURN ( self ); |
|
295 | 3419 |
} |
3420 |
%}. |
|
3421 |
"badGC, badDrawable or coordinates not integer" |
|
3422 |
self primitiveFailed |
|
43 | 3423 |
! |
3424 |
||
3425 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3426 |
width:imageWidth height:imageHeight |
3427 |
x:srcx y:srcy |
|
3428 |
into:aDrawableId |
|
3429 |
x:dstx y:dsty |
|
3430 |
width:w height:h |
|
3431 |
with:aGCId |
|
0 | 3432 |
|
132 | 3433 |
"since XPutImage may allocate huge amount of stack space |
3434 |
(some implementations use alloca), this must run with unlimited stack." |
|
3435 |
||
12 | 3436 |
%{ /* UNLIMITEDSTACK */ |
0 | 3437 |
|
43 | 3438 |
/* |
3439 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3440 |
* XPutImage |
|
3441 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3442 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3443 |
Window win; |
43 | 3444 |
XImage image; |
377 | 3445 |
int imgWdth; |
43 | 3446 |
|
1209 | 3447 |
if (ISCONNECTED |
3448 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3449 |
&& __isExternalAddress(aDrawableId) |
97 | 3450 |
&& __bothSmallInteger(srcx, srcy) |
3451 |
&& __bothSmallInteger(dstx, dsty) |
|
3452 |
&& __bothSmallInteger(w, h) |
|
3453 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3454 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3455 |
&& __isByteArray(imageBits)) { |
1344 | 3456 |
Display *dpy = myDpy; |
3457 |
||
3458 |
gc = _GCVal(aGCId); |
|
3459 |
win = _WindowVal(aDrawableId); |
|
3460 |
if (! gc || !win) |
|
3461 |
goto fail; |
|
46 | 3462 |
#ifdef ARGDEBUG |
1344 | 3463 |
printf("args ok\n"); |
46 | 3464 |
#endif |
1344 | 3465 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3466 |
image.width = imgWdth = __intVal(imageWidth); |
|
3467 |
image.height = __intVal(imageHeight); |
|
3468 |
image.xoffset = 0; |
|
3469 |
image.format = ZPixmap; |
|
3470 |
image.byte_order = MSBFirst; |
|
3471 |
image.bitmap_unit = 8; |
|
3472 |
image.bitmap_bit_order = MSBFirst; |
|
3473 |
image.bitmap_pad = 8; |
|
3474 |
image.depth = __intVal(imageDepth); |
|
3475 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3476 |
switch (image.bits_per_pixel) { |
|
3477 |
case 1: |
|
3478 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3479 |
break; |
|
3480 |
case 2: |
|
3481 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3482 |
break; |
|
3483 |
case 4: |
|
3484 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3485 |
break; |
|
3486 |
case 8: |
|
3487 |
image.bytes_per_line = imgWdth; |
|
3488 |
break; |
|
3489 |
case 16: |
|
3490 |
image.bytes_per_line = imgWdth*2; |
|
3491 |
break; |
|
3492 |
case 24: |
|
3493 |
image.bytes_per_line = imgWdth*3; |
|
3494 |
break; |
|
3495 |
case 32: |
|
3496 |
image.bytes_per_line = imgWdth*4; |
|
3497 |
break; |
|
3498 |
default: |
|
46 | 3499 |
#ifdef ARGDEBUG |
1344 | 3500 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3501 |
#endif |
1344 | 3502 |
goto fail; |
3503 |
} |
|
3504 |
image.red_mask = 0xFFFF; |
|
3505 |
image.green_mask = 0xFFFF; |
|
3506 |
image.blue_mask = 0xFFFF; |
|
3507 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
|
3508 |
__intVal(dstx), __intVal(dsty), |
|
3509 |
__intVal(w), __intVal(h)); |
|
3510 |
RETURN ( true ); |
|
43 | 3511 |
} |
46 | 3512 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3513 |
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
|
3514 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3515 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3516 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3517 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3518 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3519 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3520 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3521 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3522 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3523 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3524 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3525 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3526 |
#endif |
3527 |
||
0 | 3528 |
fail: ; |
3529 |
%} |
|
3530 |
. |
|
12 | 3531 |
^ false |
0 | 3532 |
! ! |
3533 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3534 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3535 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3536 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3537 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3538 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3539 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3540 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3541 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3542 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3543 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3544 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3545 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3546 |
|
1540 | 3547 |
clientMessage:event dataOffset:offs view:targetView |
1757 | 3548 |
self halt:'debug halt: unimplemented client message'. |
1540 | 3549 |
|
3550 |
"Created: 4.4.1997 / 17:23:12 / cg" |
|
1757 | 3551 |
"Modified: 17.6.1997 / 18:04:24 / cg" |
1540 | 3552 |
! |
3553 |
||
1543 | 3554 |
clientMessage:event type:type format:format dataOffset:offs view:targetView |
3555 |
|sensor data| |
|
3556 |
||
3557 |
data := event copyFrom:offs + 1. |
|
3558 |
||
3559 |
"/ DND drag&drop protocol |
|
3560 |
type == (self atomIDOf:'DndProtocol') ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3561 |
format == 32 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3562 |
self dndMessage:event data:data view:targetView. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3563 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3564 |
] |
1543 | 3565 |
]. |
3566 |
||
3567 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3568 |
sensor clientMessage:type format:format eventData:data view:targetView |
1543 | 3569 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3570 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3571 |
not posted, if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3572 |
" |
1543 | 3573 |
] |
3574 |
||
3575 |
"Created: 4.4.1997 / 17:49:26 / cg" |
|
3576 |
"Modified: 4.4.1997 / 18:00:18 / cg" |
|
3577 |
! |
|
3578 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3579 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3580 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3581 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3582 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3583 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3584 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3585 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3586 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3587 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3588 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3589 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3590 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3591 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3592 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3593 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3594 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3595 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3596 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3597 |
|
1543 | 3598 |
dndMessage:event data:data view:targetView |
3599 |
"handle a DND drag&drop protocol message" |
|
3600 |
||
1553 | 3601 |
|sensor dropType dropValue names i1 i2 t| |
1543 | 3602 |
|
3603 |
dropType := data doubleWordAt:1. |
|
3604 |
||
3605 |
"/ see def's in DragAndDropTypes.h |
|
1556 | 3606 |
dropType := (self dndDropTypes) at:dropType+1 ifAbsent:#DndNotDnd. |
1543 | 3607 |
|
3608 |
self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3609 |
getProperty:(self atomIDOf:'DndSelection') |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3610 |
from:rootId |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3611 |
into:[:type :value | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3612 |
t := type. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3613 |
dropValue := value |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3614 |
]. |
1543 | 3615 |
|
1558 | 3616 |
"/ preconvert into a collection |
3617 |
"/ of fileNames, string or byteArray |
|
3618 |
"/ Notice: we do not yet convert into dropObjects |
|
3619 |
"/ here, to allow arbitrary data to be handled by |
|
3620 |
"/ redefined dropMessage methods in applications. |
|
3621 |
"/ Conversion is done for some well known types |
|
3622 |
"/ in the default dropMessage handling of SimpleView. |
|
3623 |
||
1543 | 3624 |
dropType == #DndFiles ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3625 |
"/ actually, a list of fileNames |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3626 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3627 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3628 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3629 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3630 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3631 |
names := OrderedCollection new. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3632 |
i1 := 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3633 |
[i1 ~~ 0] whileTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3634 |
i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3635 |
i2 ~~ 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3636 |
names add:(dropValue copyFrom:i1 to:(i2-1)). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3637 |
i1 := i2 + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3638 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3639 |
i1 := i2 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3640 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3641 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3642 |
dropValue := names. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3643 |
dropValue := dropValue collect:[:nm | nm asFilename]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3644 |
dropType := #files. |
1558 | 3645 |
] ifFalse:[ (dropType == #DndFile) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3646 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3647 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3648 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3649 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3650 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3651 |
dropValue := dropValue asFilename. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3652 |
dropType := #file. |
1558 | 3653 |
] ifFalse:[ (dropType == #DndDir) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3654 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3655 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3656 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3657 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3658 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3659 |
dropValue := dropValue asFilename. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3660 |
dropType := #directory. |
1558 | 3661 |
] ifFalse:[ (dropType == #DndText) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3662 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3663 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3664 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3665 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3666 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3667 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3668 |
dropType := #text. |
1558 | 3669 |
] ifFalse:[ (dropType == #DndExe) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3670 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3671 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3672 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3673 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3674 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3675 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3676 |
dropType := #executable. |
1558 | 3677 |
] ifFalse:[ (dropType == #DndLink) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3678 |
t ~~ stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3679 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3680 |
^ self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3681 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3682 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3683 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3684 |
dropType := #link. |
1558 | 3685 |
] ifFalse:[ (dropType == #DndRawData) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3686 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3687 |
dropType := #rawData. |
1552 | 3688 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3689 |
'XWorkstation [info]: unsupported dropType: ' infoPrint. dropType infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3690 |
'XWorkstation [info]: data: ' infoPrint. dropValue infoPrintCR. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3691 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3692 |
dropValue := dropValue. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3693 |
dropType := #unknown. |
1558 | 3694 |
]]]]]]]. |
1543 | 3695 |
|
3696 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3697 |
sensor dropMessage:dropType data:dropValue view:targetView |
1543 | 3698 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3699 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3700 |
not posted, if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3701 |
" |
1543 | 3702 |
] |
3703 |
||
3704 |
"Created: 4.4.1997 / 17:59:37 / cg" |
|
1558 | 3705 |
"Modified: 6.4.1997 / 14:50:44 / cg" |
1543 | 3706 |
! |
3707 |
||
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3708 |
gravityNotifyView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3709 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3710 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3711 |
"/ aView gravityNotify |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3712 |
! |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3713 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3714 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3715 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3716 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3717 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3718 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3719 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3720 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3721 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3722 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3723 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3724 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3725 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3726 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3727 |
reparentedView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3728 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3729 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3730 |
"/ aView reparented |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3731 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3732 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3733 |
resizeRequestView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3734 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3735 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3736 |
"/ aView resizeRequest |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3737 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3738 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3739 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3740 |
"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
|
3741 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3742 |
|
1344 | 3743 |
"/ |
3744 |
"/ workaround a bug in olvwm: it clears selections |
|
3745 |
"/ on window raise. |
|
3746 |
"/ In this case, keep my last own selection. |
|
3747 |
"/ |
|
3748 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3749 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3750 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3751 |
|
1795 | 3752 |
"/ noone is interested in that ... |
1344 | 3753 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3754 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3755 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3756 |
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
|
3757 |
"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
|
3758 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3759 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3760 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3761 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3762 |
propertyID == 0 ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3763 |
"invalid olvwm behavior" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3764 |
s := self getLastCopyBuffer |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3765 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3766 |
targetID == self atomIDOfSTRING ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3767 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3768 |
a returned string |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3769 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3770 |
s := self getTextProperty:propertyID from:requestorID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3771 |
s notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3772 |
(s endsWith:Character cr) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3773 |
s := s asStringCollection copyWith:'' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3774 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3775 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3776 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3777 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3778 |
a returned object |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3779 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3780 |
s := self getObjectProperty:propertyID from:requestorID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3781 |
]. |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3782 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3783 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3784 |
s notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3785 |
(sensor := aView sensor) notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3786 |
sensor pasteFromClipBoard:s view:aView |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3787 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3788 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3789 |
if there is no sensor ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3790 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3791 |
aView pasteFromClipBoard:s |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3792 |
] |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3793 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3794 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3795 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3796 |
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
|
3797 |
"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
|
3798 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3799 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3800 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3801 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3802 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3803 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3804 |
"/ 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
|
3805 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3806 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3807 |
s := self selectionAsString. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3808 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3809 |
setLengthProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3810 |
value:s size |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3811 |
for:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3812 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3813 |
sendSelectionNotifySelection:selectionID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3814 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3815 |
target:targetID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3816 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3817 |
to:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3818 |
^ self |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3819 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3820 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3821 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3822 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3823 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3824 |
"/ the other view wants the selection as string |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3825 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3826 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3827 |
s := self selectionAsString. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3828 |
self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3829 |
sendSelection:s |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3830 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3831 |
target:targetID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3832 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3833 |
to:windowID. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3834 |
^ self |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3835 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3836 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3837 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3838 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3839 |
"/ (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
|
3840 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3841 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3842 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3843 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3844 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3845 |
self |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3846 |
sendSelection:(stream contents) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3847 |
property:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3848 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3849 |
from:aView id |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3850 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3851 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3852 |
|
86 | 3853 |
!XWorkstation methodsFor:'event handling'! |
0 | 3854 |
|
3855 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3856 |
"central event handling method: |
|
54 | 3857 |
get next event and send appropriate message to the sensor or view. |
0 | 3858 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3859 |
otherwise only events for the view with given id are processed. |
3860 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3861 |
handled." |
|
3862 |
||
54 | 3863 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3864 |
AbortSignal handle:[:ex | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3865 |
ex return |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3866 |
] do:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3867 |
self dispatchLastEvent. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3868 |
] |
54 | 3869 |
]. |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3870 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3871 |
"Modified: 26.3.1997 / 19:00:41 / cg" |
12 | 3872 |
! |
3873 |
||
295 | 3874 |
dispatchExposeEventFor:aViewIdOrNil |
3875 |
"get next expose event and send appropriate message to the sensor or view. |
|
3876 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3877 |
otherwise only events for the view with given id are processed." |
|
3878 |
||
3879 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3880 |
! |
3881 |
||
3882 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3883 |
|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
|
3884 |
eventType| |
12 | 3885 |
|
3886 |
%{ /* STACK: 8000 */ |
|
3887 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3888 |
|
1209 | 3889 |
Display *dpy; |
135 | 3890 |
OBJ eB; |
3891 |
XEvent *ev; |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3892 |
int ev_x, ev_y; |
135 | 3893 |
|
3894 |
# define ae ((XAnyEvent *)ev) |
|
3895 |
# define ee ((XExposeEvent *)ev) |
|
3896 |
# define ke ((XKeyPressedEvent *)ev) |
|
3897 |
# define be ((XButtonPressedEvent *)ev) |
|
3898 |
# define ce ((XConfigureEvent *)ev) |
|
3899 |
# define me ((XMotionEvent *)ev) |
|
3900 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3901 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3902 |
# define de ((XDestroyWindowEvent *)ev) |
|
3903 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3904 |
# define mape ((XMappingEvent *)ev) |
135 | 3905 |
|
0 | 3906 |
KeySym keySym; |
3907 |
unsigned char buffer[10]; |
|
3908 |
int i, nchars; |
|
3909 |
char *keySymString; |
|
3910 |
char keySymStringBuffer[32]; |
|
3911 |
unsigned nextMultiClickTime; |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3912 |
OBJ upDown, t; |
115 | 3913 |
|
3914 |
struct inlineCache *ipS; |
|
0 | 3915 |
static struct inlineCache vid = _ILC1; |
12 | 3916 |
|
3917 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
3918 |
static struct inlineCache gexpS = _ILC6; |
12 | 3919 |
static struct inlineCache nexpS = _ILC1; |
3920 |
static struct inlineCache motS = _ILC4; |
|
3921 |
static struct inlineCache bpS = _ILC4; |
|
3922 |
static struct inlineCache bmpS = _ILC4; |
|
3923 |
static struct inlineCache bspS = _ILC4; |
|
3924 |
static struct inlineCache brS = _ILC4; |
|
3925 |
static struct inlineCache focInS = _ILC1; |
|
3926 |
static struct inlineCache focOutS = _ILC1; |
|
3927 |
static struct inlineCache peS = _ILC4; |
|
3928 |
static struct inlineCache plS = _ILC2; |
|
54 | 3929 |
static struct inlineCache termS = _ILC1; |
3930 |
static struct inlineCache savtermS = _ILC1; |
|
3931 |
static struct inlineCache destrS = _ILC1; |
|
3932 |
static struct inlineCache unmapS = _ILC1; |
|
3933 |
static struct inlineCache mapS = _ILC1; |
|
3934 |
static struct inlineCache confS = _ILC5; |
|
70 | 3935 |
static struct inlineCache coveredS = _ILC2; |
1543 | 3936 |
static struct inlineCache clientMsg = _ILC5; |
12 | 3937 |
|
3938 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3939 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3940 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3941 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3942 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3943 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3944 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3945 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3946 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3947 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3948 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3949 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3950 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3951 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3952 |
static struct inlineCache mapping = _ILC2; |
70 | 3953 |
static struct inlineCache vis = _ILC1; |
12 | 3954 |
|
3955 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3956 |
static struct inlineCache skrS = _ILC4; |
12 | 3957 |
|
1209 | 3958 |
if (! ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3959 |
RETURN (false); |
1209 | 3960 |
} |
3961 |
||
3962 |
dpy = myDpy; |
|
3963 |
||
1210 | 3964 |
eB = __INST(eventBuffer); |
3965 |
||
135 | 3966 |
if (__isByteArray(eB)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3967 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3968 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3969 |
printf("DISPLAY: no eventBuffer\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3970 |
RETURN (false); |
135 | 3971 |
} |
3972 |
||
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3973 |
/* |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3974 |
* 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
|
3975 |
* avoid creation & lookup then. |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3976 |
*/ |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3977 |
if ((t = __INST(lastId)) != nil) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3978 |
if (__isExternalAddress(t)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3979 |
if (_WindowVal(t) == ae->window) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3980 |
theView = __INST(lastView); |
1610
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
3981 |
if (__isNonNilObject(theView)) { |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
3982 |
if (__qClass(theView) == nil) { |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
3983 |
theView = nil; |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
3984 |
} |
8cbd780d9784
paranoia - check for collected lastView (should not happen)
Claus Gittinger <cg@exept.de>
parents:
1583
diff
changeset
|
3985 |
} |
1579
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 |
} |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3988 |
} |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3989 |
|
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3990 |
if (theView == nil) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3991 |
windowID = __MKOBJ(ae->window); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3992 |
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
|
3993 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3994 |
* #viewFromId: could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3995 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3996 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
3997 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3998 |
} |
12 | 3999 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4000 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4001 |
RETURN (nil); |
12 | 4002 |
} |
4003 |
||
4004 |
/* |
|
4005 |
* key, button and pointer events are sent to the sensor, |
|
4006 |
* or (if there is none) to the delegate. |
|
4007 |
* or (if there is none) to the view. |
|
26 | 4008 |
* |
4009 |
* expose events are sent to the sensor, |
|
4010 |
* or (if there is none) to the view |
|
4011 |
* |
|
12 | 4012 |
* sensor and delegate get view as additional argument |
115 | 4013 |
* all of this has been taken out of here to corresponding methods |
4014 |
* in DeviceWorkstation. |
|
12 | 4015 |
*/ |
90 | 4016 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4017 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4018 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4019 |
#endif |
135 | 4020 |
switch (ev->type) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4021 |
case KeyRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4022 |
symS = @symbol(keyRelease:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4023 |
ipS = &skrS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4024 |
upDown = false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4025 |
goto keyPressAndRelease; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4026 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4027 |
case KeyPress: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4028 |
symS = @symbol(keyPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4029 |
ipS = &skpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4030 |
upDown = true; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4031 |
/* FALL INTO */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4032 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4033 |
keyPressAndRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4034 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4035 |
__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
|
4036 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4037 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4038 |
__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
|
4039 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4040 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4041 |
__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
|
4042 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4043 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4044 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4045 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4046 |
ev_x = ke->x; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4047 |
ev_y = ke->y; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4048 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4049 |
arg = nil; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4050 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4051 |
if (nchars |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4052 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4053 |
|| (buffer[0] >= 0x80))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4054 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4055 |
keySymString = NULL; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4056 |
} else { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4057 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4058 |
switch (keySym) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4059 |
case XK_Control_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4060 |
case XK_Control_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4061 |
__INST(ctrlDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4062 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4063 |
case XK_Shift_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4064 |
case XK_Shift_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4065 |
__INST(shiftDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4066 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4067 |
case XK_Meta_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4068 |
case XK_Meta_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4069 |
__INST(metaDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4070 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4071 |
case XK_Alt_L: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4072 |
case XK_Alt_R: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4073 |
__INST(altDown) = upDown; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4074 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4075 |
} |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4076 |
#endif |
150 | 4077 |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4078 |
keySymString = XKeysymToString(keySym); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4079 |
if (keySymString) { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4080 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4081 |
if (keySymString[0] == 'D') { |
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 |
* remove underscore, dont want it in symbols |
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 |
if (strcmp(keySymString, "Delete_line") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4086 |
keySymString = "DeleteLine"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4087 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4088 |
keySymString = "DeleteWord"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4089 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4090 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4091 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4092 |
* make names compatible |
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 (strcmp(keySymString, "Down") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4095 |
keySymString = "CursorDown"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4096 |
} else if (strcmp(keySymString, "Up") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4097 |
keySymString = "CursorUp"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4098 |
} else if (strcmp(keySymString, "Left") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4099 |
keySymString = "CursorLeft"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4100 |
} else if (strcmp(keySymString, "Right") == 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4101 |
keySymString = "CursorRight"; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4102 |
} |
1694 | 4103 |
arg = __MKSYMBOL(keySymString, (OBJ *)0); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4104 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4105 |
arg = __MKSTRING(keySymString); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4106 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4107 |
} |
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 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4110 |
if (arg == nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4111 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4112 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4113 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4114 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4115 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4116 |
arg, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4117 |
__MKSMALLINT(ev_x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4118 |
__MKSMALLINT(ev_y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4119 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4120 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4121 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4122 |
case ButtonPress: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4123 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4124 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4125 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4126 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4127 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4128 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4129 |
else |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4130 |
nextMultiClickTime = 0; |
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 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4133 |
if ((t = __INST(multiClickTime)) != nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4134 |
int _multiClickTime; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4135 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4136 |
_multiClickTime = __longIntVal(t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4137 |
if (be->time < _multiClickTime) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4138 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4139 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4140 |
* MKUINT could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4141 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4142 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4143 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4144 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4145 |
ipS = &bmpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4146 |
symS = @symbol(buttonMultiPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4147 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4148 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4149 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4150 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4151 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4152 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4153 |
* MKUINT could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4154 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4155 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4156 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
4157 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4158 |
#ifdef NO_LONGER |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4159 |
if (be->state & ShiftMask) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4160 |
ipS = &bspS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4161 |
symS = @symbol(buttonShiftPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4162 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4163 |
} |
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4164 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4165 |
ipS = &bpS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4166 |
symS = @symbol(buttonPress:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4167 |
goto sendButtonEvent; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4168 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4169 |
/* NOT REACHED */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4170 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4171 |
case ButtonRelease: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4172 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4173 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4174 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4175 |
ipS = &brS; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4176 |
symS = @symbol(buttonRelease:x:y:view:); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4177 |
/* fall into */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4178 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4179 |
sendButtonEvent: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4180 |
butt = __MKSMALLINT(be->button); |
12 | 4181 |
#ifdef NOTDEF |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4182 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4183 |
* 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
|
4184 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4185 |
if (__INST(metaDown) == true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4186 |
butt = __MKSMALLINT(2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4187 |
else |
0 | 4188 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4189 |
butt = __AT_(__INST(buttonTranslation), butt); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4190 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4191 |
* #at: could lead to a GC - refetch event ptr |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4192 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4193 |
eB = __INST(eventBuffer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4194 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4195 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4196 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4197 |
(*(*ipS).ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4198 |
symS, nil, ipS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4199 |
butt, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4200 |
__MKSMALLINT(ke->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4201 |
__MKSMALLINT(ke->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4202 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4203 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4204 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4205 |
case MotionNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4206 |
if (__INST(motionEventCompression) != false) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4207 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4208 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4209 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4210 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4211 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 4212 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4213 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4214 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4215 |
__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
|
4216 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4217 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4218 |
__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
|
4219 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4220 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4221 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4222 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4223 |
(*motS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4224 |
@symbol(buttonMotion:x:y:view:), nil, &motS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4225 |
__MKSMALLINT(me->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4226 |
__MKSMALLINT(me->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4227 |
__MKSMALLINT(me->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4228 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4229 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4230 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4231 |
case FocusIn: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4232 |
(*focInS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4233 |
@symbol(focusInView:), nil, &focInS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4234 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4235 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4236 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4237 |
case FocusOut: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4238 |
(*focOutS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4239 |
@symbol(focusOutView:), nil, &focOutS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4240 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4241 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4242 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4243 |
case EnterNotify: |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4244 |
#ifdef OLD |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4245 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4246 |
__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
|
4247 |
#else |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4248 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4249 |
__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
|
4250 |
#endif |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4251 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4252 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4253 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4254 |
(*peS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4255 |
@symbol(pointerEnter:x:y:view:), nil, &peS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4256 |
__MKSMALLINT(ewe->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4257 |
__MKSMALLINT(ewe->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4258 |
__MKSMALLINT(ewe->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4259 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4260 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4261 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4262 |
case LeaveNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4263 |
(*plS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4264 |
@symbol(pointerLeave:view:), nil, &plS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4265 |
__MKSMALLINT(lwe->state), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4266 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4267 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4268 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4269 |
case GraphicsExpose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4270 |
(*gexpS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4271 |
@symbol(graphicsExposeX:y:width:height:final:view:), nil, &gexpS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4272 |
__MKSMALLINT(ee->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4273 |
__MKSMALLINT(ee->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4274 |
__MKSMALLINT(ee->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4275 |
__MKSMALLINT(ee->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4276 |
ee->count == 0 ? true : false, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4277 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4278 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4279 |
if (ee->count != 0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4280 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4281 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4282 |
/* fall into */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4283 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4284 |
case NoExpose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4285 |
(*nexpS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4286 |
@symbol(noExposeView:), nil, &nexpS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4287 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4288 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4289 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4290 |
case Expose: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4291 |
(*expS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4292 |
@symbol(exposeX:y:width:height:view:), nil, &expS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4293 |
__MKSMALLINT(ee->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4294 |
__MKSMALLINT(ee->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4295 |
__MKSMALLINT(ee->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4296 |
__MKSMALLINT(ee->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4297 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4298 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4299 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4300 |
case ConfigureNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4301 |
if (ce->above != None) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4302 |
siblingID = __MKOBJ(ce->above); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4303 |
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
|
4304 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4305 |
* MKOBJ or #viewFromId: could lead to a GC - refetch event ptr |
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); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4309 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4310 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4311 |
(*confS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4312 |
@symbol(configureX:y:width:height:view:), nil, &confS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4313 |
__MKSMALLINT(ce->x), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4314 |
__MKSMALLINT(ce->y), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4315 |
__MKSMALLINT(ce->width), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4316 |
__MKSMALLINT(ce->height), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4317 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4318 |
if (sibling != nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4319 |
(*coveredS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4320 |
@symbol(coveredBy:view:), nil, &coveredS, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4321 |
theView, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4322 |
sibling); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4323 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4324 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4325 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4326 |
case ClientMessage: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4327 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4328 |
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
|
4329 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4330 |
(*termS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4331 |
@symbol(terminateView:), nil, &termS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4332 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4333 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4334 |
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
|
4335 |
(*savtermS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4336 |
@symbol(saveAndTerminateView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4337 |
, nil, &savtermS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4338 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4339 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4340 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4341 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4342 |
* any other client message |
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 |
i = (char *)(&(ev->xclient.data)) - (char *)ev; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4345 |
(*clientMsg.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4346 |
@symbol(clientMessage:type:format:dataOffset:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4347 |
, nil, &clientMsg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4348 |
, __INST(eventBuffer) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4349 |
,__MKSMALLINT(ev->xclient.message_type) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4350 |
,__MKSMALLINT(ev->xclient.format) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4351 |
,__MKSMALLINT(i), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4352 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4353 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4354 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4355 |
case DestroyNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4356 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4357 |
, nil, &destrS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4358 |
break; |
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 |
case UnmapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4361 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4362 |
, nil, &unmapS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4363 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4364 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4365 |
case MapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4366 |
(*mapS.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4367 |
@symbol(mappedView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4368 |
, nil, &mapS, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4369 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4370 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4371 |
case KeymapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4372 |
(*keymap.ilc_func)(theView, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4373 |
@symbol(keyMapChange) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4374 |
, nil, &keymap); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4375 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4376 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4377 |
case VisibilityNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4378 |
switch (ve->state) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4379 |
case VisibilityUnobscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4380 |
arg = @symbol(unobscured); |
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 VisibilityPartiallyObscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4383 |
arg = @symbol(partiallyObscured); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4384 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4385 |
case VisibilityFullyObscured: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4386 |
arg = @symbol(fullyObscured); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4387 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4388 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4389 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:), nil, &vis, arg); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4390 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4391 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4392 |
case CreateNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4393 |
(*created.ilc_func)(self, @symbol(createdView:), nil, &created, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4394 |
break; |
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 |
case MapRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4397 |
(*mapReq.ilc_func)(self, @symbol(mapRequestView:), nil, &mapReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4398 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4399 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4400 |
case ReparentNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4401 |
(*repar.ilc_func)(self, @symbol(reparentedView:), nil, &repar, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4402 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4403 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4404 |
case ConfigureRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4405 |
(*confReq.ilc_func)(self, @symbol(configureRequestView:), nil, &confReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4406 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4407 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4408 |
case GravityNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4409 |
(*gravNotify.ilc_func)(self, @symbol(gravityNotifyView:), nil, &resReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4410 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4411 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4412 |
case ResizeRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4413 |
(*resReq.ilc_func)(self, @symbol(resizeRequestView:), nil, &resReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4414 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4415 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4416 |
case CirculateNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4417 |
(*circNotify.ilc_func)(self, @symbol(circulateNotifyView:), nil, &circNotify, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4418 |
break; |
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 |
case CirculateRequest: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4421 |
(*circReq.ilc_func)(self, @symbol(circulateRequestView:), nil, &circReq, theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4422 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4423 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4424 |
case PropertyNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4425 |
(*prop.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4426 |
@symbol(propertyChangeView) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4427 |
, nil, &prop, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4428 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4429 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4430 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4431 |
case SelectionClear: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4432 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4433 |
(*selClear.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4434 |
@symbol(selectionClear:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4435 |
, nil, &selClear, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4436 |
selectionID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4437 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4438 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4439 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4440 |
case SelectionNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4441 |
/* |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4442 |
* returned selection value (answer from SelectionRequest) |
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 |
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
|
4445 |
ev->xselection.property, ev->xselection.target, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4446 |
ev->xselection.selection, ev->xselection.requestor)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4447 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4448 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4449 |
targetID = __MKATOMOBJ(ev->xselection.target); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4450 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4451 |
requestorID = __MKOBJ(ev->xselection.requestor); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4452 |
(*selNotify.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4453 |
@symbol(selectionNotify:target:selection:from:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4454 |
, nil, &selNotify, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4455 |
propertyID, targetID, selectionID, requestorID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4456 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4457 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4458 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4459 |
case SelectionRequest: |
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 |
* someone wants the selection |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4462 |
*/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4463 |
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
|
4464 |
ev->xselectionrequest.property, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4465 |
ev->xselectionrequest.target, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4466 |
ev->xselectionrequest.selection, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4467 |
ev->xselectionrequest.requestor)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4468 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4469 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4470 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4471 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4472 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4473 |
(*selReq.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4474 |
@symbol(selectionRequest:target:selection:from:view:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4475 |
, nil, &selReq, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4476 |
propertyID, targetID, selectionID, requestorID, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4477 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4478 |
break; |
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 |
case ColormapNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4481 |
(*colormap.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4482 |
@symbol(colorMapChangeView:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4483 |
, nil, &colormap, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4484 |
theView); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4485 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4486 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4487 |
case MappingNotify: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4488 |
switch(mape->request) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4489 |
case MappingModifier: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4490 |
arg = @symbol(mappingModifier); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4491 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4492 |
case MappingKeyboard: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4493 |
arg = @symbol(mappingKeyboard); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4494 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4495 |
case MappingPointer: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4496 |
arg = @symbol(mappingPointer); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4497 |
break; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4498 |
default: |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4499 |
arg = nil; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4500 |
break; |
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 |
(*mapping.ilc_func)(self, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4503 |
@symbol(mappingChanged:event:) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4504 |
, nil, &mapping, arg, eB); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4505 |
break; |
0 | 4506 |
} |
135 | 4507 |
#undef ae |
0 | 4508 |
#undef ee |
4509 |
#undef ke |
|
4510 |
#undef be |
|
4511 |
#undef ce |
|
4512 |
#undef me |
|
4513 |
#undef ewe |
|
4514 |
#undef lwe |
|
4515 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4516 |
#undef mape |
0 | 4517 |
%} |
4518 |
. |
|
4519 |
^ true |
|
4520 |
! |
|
4521 |
||
1344 | 4522 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4523 |
"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
|
4524 |
(i.e. this is now only used in the modal debugger) |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4525 |
This code is somewhat special, since X has a concept of graphic |
295 | 4526 |
expose events (which are sent after a bitblt). After such a bitblt, |
4527 |
we only handle exposes until the graphicsExpose arrives. |
|
4528 |
Other systems may not need such a kludge" |
|
4529 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4530 |
"interested in exposes only ?" |
295 | 4531 |
dispatchingExpose notNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4532 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4533 |
self dispatchExposeEventFor:dispatchingExpose |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4534 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4535 |
^ self |
295 | 4536 |
]. |
4537 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4538 |
[self eventPendingWithSync:false] whileTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4539 |
(self getEventFor:nil withMask:nil) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4540 |
AbortSignal handle:[:ex | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4541 |
ex return |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4542 |
] do:[ |
1491 | 4543 |
self dispatchLastEvent |
4544 |
] |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4545 |
]. |
295 | 4546 |
] |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4547 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4548 |
"Modified: 26.3.1997 / 19:04:17 / cg" |
295 | 4549 |
! |
4550 |
||
1344 | 4551 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4552 |
"dispose (throw away) specific events. If aWindowId is nil, |
4553 |
events matching the mask are thrown away regardless of which |
|
4554 |
view they are for. Otherwise, only matching events for that |
|
4555 |
view are flushed." |
|
0 | 4556 |
|
4557 |
%{ /* NOCONTEXT */ |
|
4558 |
||
4559 |
XEvent ev; |
|
4560 |
Window win; |
|
4561 |
||
1209 | 4562 |
if (ISCONNECTED |
4563 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4564 |
Display *dpy = myDpy; |
4565 |
||
4566 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4567 |
win = _WindowVal(aWindowIdOrNil); |
|
4568 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4569 |
} else { |
|
4570 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4571 |
} |
|
4572 |
RETURN ( self ); |
|
0 | 4573 |
} |
4574 |
%} |
|
4575 |
. |
|
4576 |
self primitiveFailed |
|
4577 |
! |
|
4578 |
||
1344 | 4579 |
eventMaskFor:anEventSymbol |
295 | 4580 |
"return the eventMask bit-constant corresponding to an event symbol" |
4581 |
||
4582 |
%{ /* NOCONTEXT */ |
|
4583 |
||
4584 |
int m = 0; |
|
4585 |
||
4586 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4587 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4588 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4589 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4590 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4591 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4592 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4593 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4594 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4595 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4596 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4597 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4598 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4599 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4600 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4601 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4602 |
RETURN (__MKSMALLINT(m)); |
295 | 4603 |
%} |
4604 |
! |
|
4605 |
||
1344 | 4606 |
eventPending |
310 | 4607 |
"return true, if any event is pending. |
4608 |
This looks for both the internal queue and the display connection." |
|
12 | 4609 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4610 |
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
|
4611 |
|
12 | 4612 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4613 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4614 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4615 |
^ self eventPendingWithSync:false |
0 | 4616 |
! |
4617 |
||
1344 | 4618 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4619 |
"return true, if a specific event is pending" |
4620 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4621 |
^ 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
|
4622 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4623 |
|
1344 | 4624 |
eventPendingWithSync:doSync |
7 | 4625 |
"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
|
4626 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4627 |
before checking." |
0 | 4628 |
|
12 | 4629 |
%{ /* UNLIMITEDSTACK */ |
0 | 4630 |
|
150 | 4631 |
if (ISCONNECTED) { |
1344 | 4632 |
Display *dpy = myDpy; |
4633 |
||
4634 |
if (doSync == true) { |
|
4635 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4636 |
} |
|
4637 |
if (XPending(dpy)) { |
|
4638 |
RETURN (true); |
|
4639 |
} |
|
150 | 4640 |
} |
4641 |
RETURN ( false ); |
|
0 | 4642 |
%} |
4643 |
! |
|
4644 |
||
1344 | 4645 |
eventQueued |
341 | 4646 |
"return true, if any event is queued" |
4647 |
||
4648 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 4649 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 4650 |
]. |
4651 |
^ self eventQueuedAlready |
|
4652 |
||
4653 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
4654 |
! |
|
4655 |
||
1344 | 4656 |
eventQueuedAlready |
341 | 4657 |
"return true, if any event is queued internally. |
4658 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
4659 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
4660 |
the display connection)." |
|
4661 |
||
4662 |
%{ /* UNLIMITEDSTACK */ |
|
4663 |
||
4664 |
if (ISCONNECTED) { |
|
1344 | 4665 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
4666 |
RETURN (true); |
|
4667 |
} |
|
341 | 4668 |
} |
4669 |
RETURN ( false ); |
|
4670 |
%} |
|
4671 |
! |
|
4672 |
||
1344 | 4673 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 4674 |
"return true, if any of the masked events is pending" |
4675 |
||
4676 |
%{ /* UNLIMITEDSTACK */ |
|
4677 |
||
4678 |
XEvent ev; |
|
4679 |
Window win; |
|
4680 |
int thereIsOne; |
|
4681 |
||
4682 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 4683 |
Display *dpy = myDpy; |
4684 |
||
4685 |
if (doSync == true) { |
|
4686 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4687 |
} |
|
4688 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4689 |
win = _WindowVal(aWindowIdOrNil); |
|
4690 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
4691 |
} else { |
|
4692 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
4693 |
} |
|
4694 |
if (thereIsOne) { |
|
4695 |
XPutBackEvent(dpy, &ev); |
|
4696 |
RETURN ( true ); |
|
4697 |
} |
|
295 | 4698 |
} |
4699 |
RETURN ( false ); |
|
4700 |
%} |
|
4701 |
! |
|
4702 |
||
1344 | 4703 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 4704 |
"return true, if any expose event is pending for a specific view, |
4705 |
or any view (if the arg is nil). |
|
4706 |
This is an X specific, only required after a scroll operation." |
|
7 | 4707 |
|
12 | 4708 |
%{ /* UNLIMITEDSTACK */ |
7 | 4709 |
|
4710 |
XEvent ev; |
|
4711 |
Window win; |
|
81 | 4712 |
int thereIsOne; |
4713 |
||
150 | 4714 |
if (ISCONNECTED) { |
1344 | 4715 |
Display *dpy = myDpy; |
4716 |
||
4717 |
if (doSync == true) { |
|
4718 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4719 |
} |
|
4720 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4721 |
win = _WindowVal(aWindowIdOrNil); |
|
4722 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
4723 |
} else { |
|
4724 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
4725 |
} |
|
4726 |
if (thereIsOne) { |
|
4727 |
XPutBackEvent(dpy, &ev); |
|
4728 |
RETURN ( true ); |
|
4729 |
} |
|
81 | 4730 |
} |
4731 |
RETURN ( false ); |
|
4732 |
%} |
|
4733 |
! |
|
4734 |
||
1344 | 4735 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 4736 |
"read next event - put into local eventBuffer. |
4737 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
4738 |
otherwise only events for that specific view will be fetched. |
|
4739 |
Returns true, if there was an event, false otherwise. |
|
4740 |
This method may block - so you better check for pending events |
|
4741 |
before calling for it. |
|
4742 |
||
4743 |
Sorry I had to split dispatch into this fetch method and an extra |
|
4744 |
handle method to allow unlimitedstack here. |
|
4745 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
4746 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
4747 |
" |
|
81 | 4748 |
|
4749 |
%{ /* UNLIMITEDSTACK */ |
|
4750 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4751 |
Display *dpy; |
295 | 4752 |
Window win, wWanted; |
4753 |
int evMask; |
|
4754 |
OBJ eB; |
|
4755 |
XEvent *ev; |
|
4756 |
||
4757 |
if (! ISCONNECTED) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4758 |
RETURN (false); |
295 | 4759 |
} |
4760 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4761 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4762 |
|
555 | 4763 |
eB = __INST(eventBuffer); |
295 | 4764 |
if (__isByteArray(eB)) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4765 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4766 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4767 |
printf("DISPLAY: no eventBuffer\n"); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4768 |
RETURN (false); |
295 | 4769 |
} |
4770 |
ev->type = 0; |
|
4771 |
||
4772 |
if (__isSmallInteger(eventMask)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4773 |
evMask = __intVal(eventMask); |
295 | 4774 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4775 |
evMask = ~0; |
295 | 4776 |
} |
4777 |
||
4778 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4779 |
wWanted = _WindowVal(aViewIdOrNil); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4780 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4781 |
RETURN ( true ); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4782 |
} |
295 | 4783 |
} else { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4784 |
if (evMask == ~0) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4785 |
XNextEvent(dpy, ev); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4786 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4787 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4788 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4789 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4790 |
} |
295 | 4791 |
} |
4792 |
%}. |
|
4793 |
^ false |
|
4794 |
! |
|
4795 |
||
1344 | 4796 |
handleAllEvents |
295 | 4797 |
"from now on, handle any kind of event" |
4798 |
||
4799 |
dispatchingExpose := nil |
|
4800 |
! |
|
4801 |
||
1344 | 4802 |
handleExposeOnlyFor:aView |
295 | 4803 |
"from now on, handle expose events only" |
4804 |
||
4805 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4806 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4807 |
|
1344 | 4808 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4809 |
"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
|
4810 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4811 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4812 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 4813 |
self refreshKeyboardMapping:eB. |
4814 |
"Maybe some of our modifiers have been changed" |
|
4815 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4816 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4817 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4818 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4819 |
! |
4820 |
||
1344 | 4821 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4822 |
"tell X that we are only interested in events from aMask, which |
295 | 4823 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4824 |
||
4825 |
%{ /* NOCONTEXT */ |
|
4826 |
||
4827 |
int mask; |
|
4828 |
||
1209 | 4829 |
if (ISCONNECTED |
4830 |
&& __isExternalAddress(aWindowId) |
|
295 | 4831 |
&& __isSmallInteger(aMask)) { |
1344 | 4832 |
mask = __intVal(aMask); |
295 | 4833 |
|
4834 |
#ifdef OLD |
|
1344 | 4835 |
/* these may not be disabled */ |
4836 |
mask |= ExposureMask | StructureNotifyMask | |
|
4837 |
KeyPressMask | KeyReleaseMask | |
|
4838 |
EnterWindowMask | LeaveWindowMask | |
|
4839 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 4840 |
#endif |
4841 |
||
1344 | 4842 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
4843 |
RETURN ( self ); |
|
295 | 4844 |
} |
4845 |
%} |
|
4846 |
. |
|
4847 |
self primitiveFailed |
|
4848 |
! |
|
4849 |
||
1344 | 4850 |
startDispatch |
295 | 4851 |
"redefined to clear dispatchingExpose, which is a special X feature" |
4852 |
||
4853 |
dispatching ifTrue:[^ self]. |
|
4854 |
dispatchingExpose := nil. |
|
4855 |
super startDispatch |
|
0 | 4856 |
! ! |
295 | 4857 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4858 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4859 |
|
1567 | 4860 |
sendClientEvent:msgType format:msgFormat to:targetWindowID data1:d1 data2:d2 data3:d3 data4:d4 data5:d5 |
1556 | 4861 |
"send a ClientMessage to some other (possibly: non-ST/X) view. |
1567 | 4862 |
The client message gets message_type and msgFormat as specified by |
1556 | 4863 |
the arguments. The additional data arguments specify up to |
4864 |
5 longWords of user data; each may be an integer or nil. |
|
4865 |
It is passed transparently in the events data field. |
|
4866 |
See XProtocol specification for more details." |
|
4867 |
||
4868 |
"/ Event.xclient.type = ClientMessage; |
|
4869 |
"/ Event.xclient.display = dpy; |
|
4870 |
"/ Event.xclient.message_type = msgType; |
|
1567 | 4871 |
"/ Event.xclient.format = msgFormat; |
1556 | 4872 |
"/ Event.xclient.window = targetWindowID; |
4873 |
"/ Event.xclient.data.l[0] = d1 |
|
4874 |
"/ Event.xclient.data.l[1] = d2 |
|
4875 |
"/ Event.xclient.data.l[2] = d3 |
|
4876 |
"/ Event.xclient.data.l[3] = d4 |
|
4877 |
"/ Event.xclient.data.l[4] = d5 |
|
4878 |
"/ |
|
4879 |
"/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event); |
|
4880 |
||
4881 |
%{ /* NOCONTEXT */ |
|
4882 |
int type; |
|
4883 |
int state; |
|
4884 |
||
4885 |
if (ISCONNECTED |
|
4886 |
&& __isInteger(msgType) |
|
1567 | 4887 |
&& __isInteger(msgFormat) |
1556 | 4888 |
&& (__isExternalAddress(targetWindowID) || __isInteger(targetWindowID))) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4889 |
Display *dpy = myDpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4890 |
XEvent ev; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4891 |
Status result; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4892 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4893 |
if (__isInteger(d1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4894 |
ev.xclient.data.l[0] = __longIntVal(d1); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4895 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4896 |
if (__isExternalAddress(d1)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4897 |
ev.xclient.data.l[0] = (int)__externalAddressVal(d1); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4898 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4899 |
ev.xclient.data.l[0] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4900 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4901 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4902 |
if (__isInteger(d2)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4903 |
ev.xclient.data.l[1] = __longIntVal(d2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4904 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4905 |
if (__isExternalAddress(d2)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4906 |
ev.xclient.data.l[1] = (int)__externalAddressVal(d2); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4907 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4908 |
ev.xclient.data.l[1] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4909 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4910 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4911 |
if (__isInteger(d3)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4912 |
ev.xclient.data.l[2] = __longIntVal(d3); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4913 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4914 |
if (__isExternalAddress(d3)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4915 |
ev.xclient.data.l[2] = (int)__externalAddressVal(d3); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4916 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4917 |
ev.xclient.data.l[2] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4918 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4919 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4920 |
if (__isInteger(d4)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4921 |
ev.xclient.data.l[3] = __longIntVal(d4); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4922 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4923 |
if (__isExternalAddress(d4)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4924 |
ev.xclient.data.l[3] = (int)__externalAddressVal(d4); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4925 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4926 |
ev.xclient.data.l[3] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4927 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4928 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4929 |
if (__isInteger(d5)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4930 |
ev.xclient.data.l[4] = __longIntVal(d5); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4931 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4932 |
if (__isExternalAddress(d5)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4933 |
ev.xclient.data.l[4] = (int)__externalAddressVal(d5); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4934 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4935 |
ev.xclient.data.l[4] = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4936 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4937 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4938 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4939 |
if (__isExternalAddress(targetWindowID)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4940 |
ev.xclient.window = _WindowVal(targetWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4941 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4942 |
ev.xclient.window = (Window)__longIntVal(targetWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4943 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4944 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4945 |
ev.xclient.type = ClientMessage; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4946 |
ev.xclient.display = dpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4947 |
ev.xclient.message_type = __longIntVal(msgType); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4948 |
ev.xclient.format = __longIntVal(msgFormat); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4949 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4950 |
result = XSendEvent(dpy, ev.xclient.window, True, NoEventMask , &ev); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4951 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4952 |
if ((result == BadValue) || (result == BadWindow)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4953 |
DPRINTF(("bad status in sendClientEvent\n")); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4954 |
RETURN ( false ) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4955 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
4956 |
RETURN (true) |
1556 | 4957 |
} |
4958 |
%}. |
|
4959 |
self primitiveFailed. |
|
4960 |
^ false |
|
4961 |
! |
|
4962 |
||
1344 | 4963 |
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
|
4964 |
"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
|
4965 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4966 |
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
|
4967 |
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
|
4968 |
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
|
4969 |
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
|
4970 |
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
|
4971 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4972 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4973 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4974 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4975 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4976 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4977 |
if (__isSmallInteger(stateMask)) { |
1344 | 4978 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4979 |
} else { |
1344 | 4980 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4981 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4982 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4983 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4984 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4985 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4986 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 4987 |
Display *dpy = myDpy; |
4988 |
||
4989 |
XEvent ev; |
|
4990 |
Window target; |
|
4991 |
Status result; |
|
4992 |
KeySym keySym, *syms; |
|
4993 |
int screen = __intVal(__INST(screen)); |
|
4994 |
char s[2]; |
|
4995 |
int nSyms; |
|
4996 |
||
4997 |
if ((typeSymbol == @symbol(keyPress)) |
|
4998 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
4999 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
5000 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
5001 |
} else { |
|
5002 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
5003 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
5004 |
s[1] = '\0'; |
|
5005 |
keySym = XStringToKeysym(s); |
|
5006 |
} else { |
|
5007 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
5008 |
} |
|
5009 |
} |
|
5010 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
5011 |
||
5012 |
if (stateMask == nil) { |
|
5013 |
/* |
|
5014 |
* get the modifier from the keySym |
|
5015 |
*/ |
|
5016 |
nSyms = 0; |
|
5017 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
5018 |
if (syms) { |
|
5019 |
int i; |
|
5020 |
||
5021 |
for (i=0; i<nSyms; i++) { |
|
5022 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5023 |
#ifdef MODIFIERDEBUG |
1344 | 5024 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5025 |
#endif |
1344 | 5026 |
if (i) state = (1 << (i-1)); |
5027 |
break; |
|
5028 |
} |
|
5029 |
} |
|
5030 |
XFree(syms); |
|
5031 |
} |
|
5032 |
} |
|
5033 |
} else { |
|
5034 |
if ((typeSymbol == @symbol(buttonPress)) |
|
5035 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
5036 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
5037 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
5038 |
} else { |
|
5039 |
ev.xbutton.button = 1; |
|
5040 |
} |
|
5041 |
} else { |
|
5042 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
5043 |
RETURN (false); |
|
5044 |
} |
|
5045 |
} |
|
5046 |
||
5047 |
if (typeSymbol == @symbol(keyPress)) |
|
5048 |
ev.xany.type = KeyPress; |
|
5049 |
else if (typeSymbol == @symbol(keyRelease)) |
|
5050 |
ev.xany.type = KeyRelease; |
|
5051 |
else if (typeSymbol == @symbol(buttonPress)) |
|
5052 |
ev.xany.type = ButtonPress; |
|
5053 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
5054 |
ev.xany.type = ButtonRelease; |
|
5055 |
||
5056 |
if (__isExternalAddress(targetId)) { |
|
5057 |
target = _WindowVal(targetId); |
|
5058 |
} else { |
|
5059 |
target = (Window) __longIntVal(targetId); |
|
5060 |
} |
|
5061 |
ev.xkey.window = target; |
|
5062 |
ev.xkey.same_screen = 1; |
|
5063 |
ev.xkey.subwindow = 0; |
|
5064 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
5065 |
ev.xkey.x = __intVal(xPos); |
|
5066 |
ev.xkey.y = __intVal(yPos); |
|
5067 |
ev.xkey.state = state; |
|
5068 |
ev.xkey.time = CurrentTime; |
|
5069 |
||
5070 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
|
5071 |
if ((result == BadValue) || (result == BadWindow)) { |
|
5072 |
DPRINTF(("bad status\n")); |
|
5073 |
RETURN ( false ) |
|
5074 |
} |
|
5075 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5076 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5077 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5078 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5079 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5080 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5081 |
|
1344 | 5082 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5083 |
"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
|
5084 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5085 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5086 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 5087 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5088 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5089 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5090 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5091 |
aCharacterOrString isString ifTrue:[ |
1344 | 5092 |
aCharacterOrString do:[:char | |
5093 |
self simulateKeyboardInput:char inViewId:viewId |
|
5094 |
]. |
|
5095 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5096 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5097 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5098 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5099 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5100 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5101 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 5102 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5103 |
] ifFalse:[ |
1344 | 5104 |
(aCharacterOrString == Character tab) ifTrue:[ |
5105 |
code := #Tab |
|
5106 |
] ifFalse:[ |
|
5107 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
5108 |
code := #Escape |
|
5109 |
] |
|
5110 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5111 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5112 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5113 |
control ifTrue:[ |
1344 | 5114 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5115 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5116 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5117 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5118 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5119 |
"/ (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
|
5120 |
"/ 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
|
5121 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5122 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5123 |
code isNumber ifTrue:[ |
1344 | 5124 |
code >= $A asciiValue ifTrue:[ |
5125 |
code <= $Z asciiValue ifTrue:[ |
|
5126 |
state := self shiftMask |
|
5127 |
] |
|
5128 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5129 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5130 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5131 |
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
|
5132 |
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
|
5133 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5134 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5135 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5136 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5137 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5138 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5139 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5140 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5141 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5142 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5143 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5144 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5145 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5146 |
|
295 | 5147 |
!XWorkstation methodsFor:'font stuff'! |
5148 |
||
1344 | 5149 |
createFontFor:aFontName |
295 | 5150 |
"a basic method for X-font allocation; this method allows |
5151 |
any font to be aquired (even those not conforming to |
|
5152 |
standard naming conventions, such as cursor, fixed or k14)" |
|
5153 |
||
5154 |
%{ /* UNLIMITEDSTACK */ |
|
5155 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
5156 |
||
5157 |
XFontStruct *newFont; |
|
5158 |
||
5159 |
if (ISCONNECTED) { |
|
1344 | 5160 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
5161 |
BEGIN_INTERRUPTSBLOCKED |
|
5162 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5163 |
#ifdef COUNT_RESOURCES |
1344 | 5164 |
if (newFont) |
5165 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5166 |
#endif |
1344 | 5167 |
END_INTERRUPTSBLOCKED |
5168 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
5169 |
} |
|
295 | 5170 |
} |
5171 |
%}. |
|
5172 |
^ nil |
|
5173 |
! |
|
5174 |
||
1344 | 5175 |
decomposeXFontName:aString into:aBlock |
295 | 5176 |
"extract family, face, style and size from an |
5177 |
X-font name |
|
5178 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
5179 |
evaluate aBlock with these" |
|
5180 |
||
5181 |
|origin family face style moreStyle skip fheight size |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5182 |
resX resY x1 x2 registry encoding coding start end | |
295 | 5183 |
|
5184 |
aString isNil ifTrue:[^ false]. |
|
5185 |
(aString startsWith:'-') ifFalse:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5186 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5187 |
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
|
5188 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5189 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5190 |
end := aString indexOf:$- startingAt:1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5191 |
family := aString copyFrom:1 to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5192 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5193 |
end := aString indexOf:$- startingAt:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5194 |
style := aString copyFrom:start to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5195 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5196 |
size := aString copyFrom:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5197 |
size := (Number readFromString:size onError:[^false]). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5198 |
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
|
5199 |
^ true. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5200 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5201 |
('*-[0-9]*' match:aString) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5202 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5203 |
something like lucidasans-24 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5204 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5205 |
end := aString indexOf:$- startingAt:1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5206 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5207 |
family := aString copyFrom:1 to:(end - 1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5208 |
start := end + 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5209 |
size := aString copyFrom:start. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5210 |
size := (Number readFromString:size onError:[^false]). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5211 |
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
|
5212 |
^ true. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5213 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5214 |
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
|
5215 |
^ true. |
295 | 5216 |
]. |
5217 |
||
5218 |
end := aString indexOf:$- startingAt:2. |
|
5219 |
(end == 0) ifTrue:[^ false]. |
|
5220 |
origin := aString copyFrom:2 to:(end - 1). |
|
5221 |
||
5222 |
start := end + 1. |
|
5223 |
end := aString indexOf:$- startingAt:start. |
|
5224 |
(end == 0) ifTrue:[^ false]. |
|
5225 |
family := aString copyFrom:start to:(end - 1). |
|
5226 |
||
5227 |
start := end + 1. |
|
5228 |
end := aString indexOf:$- startingAt:start. |
|
5229 |
(end == 0) ifTrue:[^ false]. |
|
5230 |
face := aString copyFrom:start to:(end - 1). |
|
5231 |
||
5232 |
start := end + 1. |
|
5233 |
end := aString indexOf:$- startingAt:start. |
|
5234 |
(end == 0) ifTrue:[^ false]. |
|
5235 |
style := aString copyFrom:start to:(end - 1). |
|
5236 |
(style = 'o') ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5237 |
style := 'oblique' |
295 | 5238 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5239 |
(style = 'i') ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5240 |
style := 'italic' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5241 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5242 |
(style = 'r') ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5243 |
style := 'roman' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5244 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5245 |
] |
295 | 5246 |
]. |
5247 |
||
5248 |
start := end + 1. |
|
5249 |
end := aString indexOf:$- startingAt:start. |
|
5250 |
(end == 0) ifTrue:[^ false]. |
|
5251 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
5252 |
||
5253 |
start := end + 1. |
|
5254 |
end := aString indexOf:$- startingAt:start. |
|
5255 |
(end == 0) ifTrue:[^ false]. |
|
5256 |
skip := aString copyFrom:start to:(end - 1). |
|
5257 |
||
5258 |
start := end + 1. |
|
5259 |
end := aString indexOf:$- startingAt:start. |
|
5260 |
(end == 0) ifTrue:[^ false]. |
|
5261 |
fheight := aString copyFrom:start to:(end - 1). |
|
5262 |
||
5263 |
start := end + 1. |
|
5264 |
end := aString indexOf:$- startingAt:start. |
|
5265 |
(end == 0) ifTrue:[^ false]. |
|
5266 |
size := aString copyFrom:start to:(end - 1). |
|
5267 |
size := (Number readFromString:size) / 10. |
|
5268 |
||
5269 |
start := end + 1. |
|
5270 |
end := aString indexOf:$- startingAt:start. |
|
5271 |
(end == 0) ifTrue:[^ false]. |
|
5272 |
resX := aString copyFrom:start to:(end - 1). |
|
5273 |
||
5274 |
start := end + 1. |
|
5275 |
end := aString indexOf:$- startingAt:start. |
|
5276 |
(end == 0) ifTrue:[^ false]. |
|
5277 |
resY := aString copyFrom:start to:(end - 1). |
|
5278 |
||
5279 |
start := end + 1. |
|
5280 |
end := aString indexOf:$- startingAt:start. |
|
5281 |
(end == 0) ifTrue:[^ false]. |
|
5282 |
x1 := aString copyFrom:start to:(end - 1). |
|
5283 |
||
5284 |
start := end + 1. |
|
5285 |
end := aString indexOf:$- startingAt:start. |
|
5286 |
(end == 0) ifTrue:[^ false]. |
|
5287 |
x2 := aString copyFrom:start to:(end - 1). |
|
5288 |
||
5289 |
start := end + 1. |
|
5290 |
end := aString indexOf:$- startingAt:start. |
|
5291 |
(end == 0) ifTrue:[^ false]. |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5292 |
registry := aString copyFrom:start to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5293 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5294 |
encoding := aString copyFrom:end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5295 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5296 |
coding := registry , '-' , encoding. |
295 | 5297 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5298 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5299 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5300 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5301 |
|
295 | 5302 |
aBlock value:family value:face value:style value:size value:coding. |
5303 |
^ true |
|
5304 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5305 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5306 |
"Modified: 10.4.1997 / 09:45:36 / cg" |
295 | 5307 |
! |
5308 |
||
1344 | 5309 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5310 |
"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
|
5311 |
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
|
5312 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5313 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5314 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5315 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5316 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5317 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5318 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5319 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5320 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5321 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5322 |
if (ISCONNECTED) { |
1344 | 5323 |
Display *dpy = myDpy; |
5324 |
||
5325 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
5326 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
5327 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
5328 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5329 |
||
5330 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5331 |
|
1344 | 5332 |
f = _FontVal(aFontId); |
5333 |
if (f) { |
|
5334 |
n = f->n_properties; |
|
5335 |
prop = f->properties; |
|
5336 |
if (prop) { |
|
5337 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5338 |
#ifdef SUPERDEBUG |
1344 | 5339 |
cp = XGetAtomName(dpy, prop->name); |
5340 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5341 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5342 |
#endif |
1344 | 5343 |
if (prop->name == XA_FULL_NAME) { |
5344 |
cp = XGetAtomName(dpy, prop->card32); |
|
5345 |
if (cp) { |
|
5346 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5347 |
#ifdef SUPERDEBUG |
1344 | 5348 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5349 |
#endif |
1344 | 5350 |
XFree(cp); |
5351 |
} |
|
5352 |
} else if (prop->name == fontAtom) { |
|
5353 |
cp = XGetAtomName(dpy, prop->card32); |
|
5354 |
if (cp) { |
|
5355 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5356 |
#ifdef SUPERDEBUG |
1344 | 5357 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5358 |
#endif |
1344 | 5359 |
XFree(cp); |
5360 |
} |
|
5361 |
} else if (prop->name == encodingAtom) { |
|
5362 |
cp = XGetAtomName(dpy, prop->card32); |
|
5363 |
if (cp) { |
|
5364 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5365 |
#ifdef SUPERDEBUG |
1344 | 5366 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5367 |
#endif |
1344 | 5368 |
XFree(cp); |
5369 |
} |
|
5370 |
} else if (prop->name == registryAtom) { |
|
5371 |
cp = XGetAtomName(dpy, prop->card32); |
|
5372 |
if (cp) { |
|
5373 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5374 |
#ifdef SUPERDEBUG |
1344 | 5375 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5376 |
#endif |
1344 | 5377 |
XFree(cp); |
5378 |
} |
|
5379 |
} else if (prop->name == charSetCollAtom) { |
|
5380 |
cp = XGetAtomName(dpy, prop->card32); |
|
5381 |
if (cp) { |
|
5382 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5383 |
#ifdef SUPERDEBUG |
1344 | 5384 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5385 |
#endif |
1344 | 5386 |
XFree(cp); |
5387 |
} |
|
5388 |
} |
|
5389 |
prop++; |
|
5390 |
} |
|
5391 |
} |
|
5392 |
} |
|
5393 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5394 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5395 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5396 |
^ self |
1344 | 5397 |
extractEncodingFromRegistry:registry |
5398 |
encoding:encoding |
|
5399 |
charSetCollections:charSetCollections |
|
5400 |
! |
|
5401 |
||
5402 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5403 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5404 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5405 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5406 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5407 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 5408 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5409 |
] ifFalse:[ |
1344 | 5410 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
5411 |
enc := encoding asLowercase asSymbol |
|
5412 |
] ifFalse:[ |
|
5413 |
charSets := charSetCollections. |
|
5414 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
5415 |
charSets := charSets asUppercase asCollectionOfWords. |
|
5416 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
5417 |
enc := #iso8859 |
|
5418 |
] ifFalse:[ |
|
5419 |
(charSets includes:'ISO8859') ifTrue:[ |
|
5420 |
enc := #iso8859 |
|
5421 |
] ifFalse:[ |
|
5422 |
(charSets includes:'ASCII') ifTrue:[ |
|
5423 |
enc := #ascii |
|
5424 |
] ifFalse:[ |
|
5425 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
5426 |
enc := #iso8859 |
|
5427 |
] |
|
5428 |
] |
|
5429 |
] |
|
5430 |
] |
|
5431 |
] |
|
5432 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5433 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5434 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5435 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5436 |
"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
|
5437 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5438 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5439 |
|
1344 | 5440 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5441 |
"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
|
5442 |
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
|
5443 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5444 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5445 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5446 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5447 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5448 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5449 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5450 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5451 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5452 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5453 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5454 |
|
1344 | 5455 |
fontMetricsOf:fontId into:aBlock |
991 | 5456 |
"evaluate aBlock, passing a fonts metrics as arguments" |
5457 |
||
5458 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5459 |
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
|
5460 |
res resX resY| |
991 | 5461 |
|
994 | 5462 |
%{ |
991 | 5463 |
XFontStruct *f; |
5464 |
int len; |
|
5465 |
||
5466 |
if (ISCONNECTED) { |
|
1344 | 5467 |
if (__isExternalAddress(fontId)) { |
5468 |
f = _FontVal(fontId); |
|
5469 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5470 |
#ifdef NOTDEF |
1344 | 5471 |
char *cp; |
5472 |
XFontProp *prop; |
|
5473 |
||
5474 |
n = f->n_properties; |
|
5475 |
prop = f->properties; |
|
5476 |
||
5477 |
if (prop) { |
|
5478 |
while (n--) { |
|
5479 |
if (prop->name == RESOLUTION_X) { |
|
5480 |
resX = __MKSMALLINT(prop->card32); |
|
5481 |
} else if (prop->name == RESOLUTION_Y) { |
|
5482 |
resY = __MKSMALLINT(prop->card32); |
|
5483 |
} else if (prop->name == RESOLUTION) { |
|
5484 |
res = __MKSMALLINT(prop->card32); |
|
5485 |
} |
|
5486 |
prop++; |
|
5487 |
} |
|
5488 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5489 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5490 |
|
1344 | 5491 |
avgAscent = __MKSMALLINT(f->ascent); |
5492 |
avgDescent = __MKSMALLINT(f->descent); |
|
5493 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
5494 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
5495 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
5496 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
5497 |
BEGIN_INTERRUPTSBLOCKED |
|
5498 |
len = XTextWidth(f, " ", 1); |
|
5499 |
END_INTERRUPTSBLOCKED |
|
5500 |
avgWidth = __MKSMALLINT( len ); |
|
5501 |
} |
|
5502 |
} |
|
991 | 5503 |
} |
5504 |
%}. |
|
5505 |
encoding := self encodingOf:fontId. |
|
5506 |
aBlock value:encoding |
|
1344 | 5507 |
value:avgAscent |
5508 |
value:avgDescent |
|
5509 |
value:maxAscent |
|
5510 |
value:maxDescent |
|
5511 |
value:minWidth |
|
5512 |
value:maxWidth |
|
5513 |
value:avgWidth |
|
5514 |
! |
|
5515 |
||
5516 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5517 |
"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
|
5518 |
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
|
5519 |
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
|
5520 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5521 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5522 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5523 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5524 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5525 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5526 |
if (ISCONNECTED) { |
1344 | 5527 |
Display *dpy = myDpy; |
5528 |
||
5529 |
if (__isExternalAddress(fontId)) { |
|
5530 |
f = _FontVal(fontId); |
|
5531 |
if (f) { |
|
5532 |
char *cp; |
|
5533 |
XFontProp *prop; |
|
5534 |
Atom resolutionXAtom, resolutionYAtom; |
|
5535 |
int n; |
|
5536 |
||
5537 |
n = f->n_properties; |
|
5538 |
prop = f->properties; |
|
5539 |
||
5540 |
if (prop) { |
|
5541 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
5542 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
5543 |
||
5544 |
while (n--) { |
|
5545 |
if (prop->name == resolutionXAtom) { |
|
5546 |
resX = __MKSMALLINT(prop->card32); |
|
5547 |
} else if (prop->name == resolutionYAtom) { |
|
5548 |
resY = __MKSMALLINT(prop->card32); |
|
5549 |
} else if (prop->name == XA_RESOLUTION) { |
|
5550 |
res = __MKSMALLINT(prop->card32); |
|
5551 |
} |
|
5552 |
prop++; |
|
5553 |
} |
|
5554 |
} |
|
5555 |
} |
|
5556 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5557 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5558 |
%}. |
1046 | 5559 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 5560 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5561 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5562 |
res notNil ifTrue:[ |
1344 | 5563 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5564 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5565 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5566 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5567 |
|
1344 | 5568 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5569 |
"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
|
5570 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5571 |
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
|
5572 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5573 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5574 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5575 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5576 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5577 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5578 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5579 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5580 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5581 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5582 |
if (ISCONNECTED) { |
1344 | 5583 |
Display *dpy = myDpy; |
5584 |
||
5585 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5586 |
||
5587 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5588 |
|
1344 | 5589 |
f = _FontVal(aFontId); |
5590 |
if (f) { |
|
5591 |
n = f->n_properties; |
|
5592 |
prop = f->properties; |
|
5593 |
if (prop) { |
|
5594 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5595 |
#ifdef SUPERDEBUG |
1344 | 5596 |
cp = XGetAtomName(dpy, prop->name); |
5597 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5598 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5599 |
#endif |
1344 | 5600 |
if (prop->name == XA_FULL_NAME) { |
5601 |
cp = XGetAtomName(dpy, prop->card32); |
|
5602 |
if (cp) { |
|
5603 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5604 |
#ifdef SUPERDEBUG |
1344 | 5605 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5606 |
#endif |
1344 | 5607 |
XFree(cp); |
5608 |
} |
|
5609 |
} |
|
5610 |
if (prop->name == fontAtom) { |
|
5611 |
cp = XGetAtomName(dpy, prop->card32); |
|
5612 |
if (cp) { |
|
5613 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5614 |
#ifdef SUPERDEBUG |
1344 | 5615 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5616 |
#endif |
1344 | 5617 |
XFree(cp); |
5618 |
} |
|
5619 |
} |
|
5620 |
prop++; |
|
5621 |
} |
|
5622 |
} |
|
5623 |
} |
|
5624 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5625 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5626 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5627 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 5628 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5629 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5630 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5631 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5632 |
|
1344 | 5633 |
getAvailableFontsMatching:pattern |
295 | 5634 |
"return an Array filled with font names matching aPattern" |
5635 |
||
5636 |
%{ /* UNLIMITEDSTACK */ |
|
5637 |
||
5638 |
int nnames = 1500; |
|
5639 |
int available = nnames + 1; |
|
5640 |
char **fonts; |
|
5641 |
OBJ arr, str; |
|
5642 |
int i; |
|
5643 |
||
5644 |
if (ISCONNECTED) { |
|
1344 | 5645 |
if (__isString(pattern)) { |
5646 |
for (;;) { |
|
5647 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
5648 |
if ((fonts == NULL) || (available < nnames)) break; |
|
5649 |
XFreeFontNames(fonts); |
|
5650 |
nnames = available * 2; |
|
5651 |
} |
|
5652 |
if (fonts == NULL) { |
|
5653 |
RETURN ( nil ); |
|
5654 |
} |
|
5655 |
/* |
|
5656 |
* now, that we know the number of font names, |
|
5657 |
* create the array ... |
|
5658 |
*/ |
|
5659 |
arr = __ARRAY_NEW_INT(available); |
|
5660 |
if (! arr) { |
|
5661 |
RETURN (nil); |
|
5662 |
} |
|
5663 |
/* |
|
5664 |
* ... and fill it |
|
5665 |
*/ |
|
5666 |
for (i=0; i<available; i++) { |
|
5667 |
__PROTECT__(arr); |
|
5668 |
str = __MKSTRING(fonts[i]); |
|
5669 |
__UNPROTECT__(arr); |
|
5670 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
5671 |
} |
|
5672 |
RETURN (arr); |
|
5673 |
} |
|
295 | 5674 |
} |
5675 |
%}. |
|
5676 |
^ nil |
|
5677 |
! |
|
5678 |
||
1344 | 5679 |
getDefaultFont |
295 | 5680 |
"return a default font id - used when class Font cannot |
5681 |
find anything usable" |
|
5682 |
||
5683 |
^ self createFontFor:'fixed' |
|
5684 |
! |
|
5685 |
||
1344 | 5686 |
getFontWithFamily:familyString face:faceString |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5687 |
style:styleArgString size:sizeArg encoding:encoding |
295 | 5688 |
|
5689 |
"try to get the specified font, if not available, try next smaller |
|
5690 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
5691 |
as family and the other parameters as nil. For example, the cursor font |
|
5692 |
can be aquired that way." |
|
5693 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5694 |
|styleString theName theId xlatedStyle |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5695 |
id spacing encodingMatch registryMatch idx| |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5696 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5697 |
styleString := styleArgString. |
295 | 5698 |
|
5699 |
"special: if face is nil, allow access to X-fonts" |
|
5700 |
faceString isNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5701 |
sizeArg notNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5702 |
theName := familyString , '-' , sizeArg printString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5703 |
] ifFalse:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5704 |
theName := familyString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5705 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5706 |
theName isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5707 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5708 |
mhmh - fall back to the default font |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5709 |
" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5710 |
theName := 'fixed' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5711 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5712 |
theId := self createFontFor:theName. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5713 |
theId isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5714 |
theId := self getDefaultFont |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5715 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5716 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5717 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5718 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5719 |
"/ 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
|
5720 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5721 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5722 |
(styleString notNil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5723 |
and:[(styleString endsWith:'-narrow') |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5724 |
or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5725 |
|i| |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5726 |
i := styleString lastIndexOf:$-. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5727 |
spacing := styleString copyFrom:(i+1). |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5728 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5729 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5730 |
spacing := 'normal'. |
295 | 5731 |
]. |
5732 |
||
5733 |
xlatedStyle := styleString. |
|
5734 |
xlatedStyle notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5735 |
xlatedStyle := xlatedStyle first asString |
295 | 5736 |
]. |
5737 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5738 |
encodingMatch := encoding. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5739 |
registryMatch := '*'. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5740 |
encoding isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5741 |
encodingMatch := '*'. |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5742 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5743 |
idx := encoding indexOf:$-. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5744 |
idx ~~ 0 ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5745 |
encodingMatch := encoding copyTo:idx - 1. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5746 |
registryMatch := encoding copyFrom:idx + 1 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5747 |
]. |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5748 |
]. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5749 |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5750 |
id := self |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5751 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5752 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5753 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5754 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5755 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5756 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5757 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5758 |
registry:encodingMatch |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5759 |
encoding:registryMatch. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5760 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5761 |
id isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5762 |
(encodingMatch notNil and:[encodingMatch ~= '*']) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5763 |
"/ too stupid: encodings come in both cases |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5764 |
"/ and X does not ignore case |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5765 |
"/ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5766 |
id := self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5767 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5768 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5769 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5770 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5771 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5772 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5773 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5774 |
registry:encodingMatch asUppercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5775 |
encoding:registryMatch. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5776 |
id isNil ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5777 |
id := self |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5778 |
getFontWithFoundry:'*' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5779 |
family:familyString asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5780 |
weight:faceString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5781 |
slant:xlatedStyle |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5782 |
spacing:spacing |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5783 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5784 |
size:sizeArg |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5785 |
registry:encodingMatch asLowercase |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5786 |
encoding:registryMatch. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5787 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5788 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5789 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5790 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5791 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5792 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5793 |
"Modified: 10.4.1997 / 19:20:06 / cg" |
295 | 5794 |
! |
5795 |
||
1344 | 5796 |
getFontWithFoundry:foundry family:family weight:weight |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5797 |
slant:slant spacing:spc pixelSize:pSize size:size |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5798 |
registry:registry encoding:encoding |
295 | 5799 |
|
5800 |
"get the specified font, if not available, return nil. |
|
5801 |
This is the new font creation method - all others will be changed to |
|
5802 |
use this entry. |
|
5803 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
5804 |
||
5805 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
5806 |
family: 'helvetica' 'courier' 'times' ... |
|
5807 |
weight: 'bold' 'medium' 'demi' ... |
|
5808 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
5809 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
5810 |
pixelSize: 16,18 ... usually left empty |
|
5811 |
size: size in point (1/72th of an inch) |
|
5812 |
registry: iso8859, sgi ... '*' |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5813 |
encoding: registry specific encoding (usually '*') |
295 | 5814 |
" |
5815 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5816 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5817 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 5818 |
pSizeMatch registryMatch encodingMatch| |
295 | 5819 |
|
5820 |
"this works only on 'Release >= 3' - X-servers" |
|
5821 |
"name is: |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5822 |
-foundry-family -weight -slant- |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5823 |
sony helvetica bold r |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5824 |
adobe courier medium i |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5825 |
msic fixed o |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5826 |
... ... |
295 | 5827 |
" |
5828 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5829 |
size isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5830 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5831 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5832 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5833 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5834 |
foundry isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5835 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5836 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5837 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5838 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5839 |
family isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5840 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5841 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5842 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5843 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5844 |
weight isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5845 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5846 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5847 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5848 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5849 |
slant isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5850 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5851 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5852 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5853 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5854 |
spc isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5855 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5856 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5857 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5858 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5859 |
pSize isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5860 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5861 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5862 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5863 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5864 |
registry isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5865 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5866 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5867 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5868 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5869 |
encoding isNil ifTrue:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5870 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5871 |
] ifFalse:[ |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5872 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5873 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5874 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5875 |
theName := ('-' , foundryMatch, |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5876 |
'-' , familyMatch, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5877 |
'-' , weightMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5878 |
'-' , slantMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5879 |
'-' , spcMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5880 |
'-*' , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5881 |
'-' , pSizeMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5882 |
'-' , sizeMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5883 |
'-*-*-*-*' , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5884 |
'-' , registryMatch , |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5885 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5886 |
|
697 | 5887 |
"/ Transcript showCR:theName; endEntry. |
295 | 5888 |
|
5889 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5890 |
|
295 | 5891 |
|
5892 |
" |
|
5893 |
Display getFontWithFoundry:'*' |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5894 |
family:'courier' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5895 |
weight:'medium' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5896 |
slant:'r' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5897 |
spacing:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5898 |
pixelSize:nil |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5899 |
size:13 |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5900 |
registry:'iso8859' |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
5901 |
encoding:'*' |
295 | 5902 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5903 |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5904 |
"Modified: 10.4.1997 / 19:15:44 / cg" |
295 | 5905 |
! |
5906 |
||
1344 | 5907 |
listOfAvailableFonts |
295 | 5908 |
"return a list with all available fonts on this display. |
5909 |
Since this takes a long time, keep the result of the query for the |
|
5910 |
next time. The elements of the returned collection are instances of |
|
5911 |
FontDescription." |
|
5912 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
5913 |
|"stream aName fntDescr" names| |
295 | 5914 |
|
5915 |
listOfXFonts isNil ifTrue:[ |
|
5916 |
"/ |
|
5917 |
"/ old code; using a pipe to xlsfonts |
|
5918 |
"/ |
|
5919 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
5920 |
"/ stream isNil ifTrue:[^ nil]. |
|
5921 |
"/ listOfXFonts := OrderedCollection new. |
|
5922 |
"/ [stream atEnd] whileFalse:[ |
|
5923 |
"/ aName := stream nextLine. |
|
5924 |
"/ aName notNil ifTrue:[ |
|
5925 |
"/ self decomposeXFontName:aName into: |
|
5926 |
"/ [:family :face :style :size :coding | |
|
5927 |
"/ family notNil ifTrue:[ |
|
5928 |
"/ fntDescr := FontDescription |
|
5929 |
"/ family:family |
|
5930 |
"/ face:face |
|
5931 |
"/ style:style |
|
5932 |
"/ size:size |
|
5933 |
"/ encoding:coding. |
|
5934 |
"/ listOfXFonts add:fntDescr |
|
5935 |
"/ ] |
|
5936 |
"/ ] |
|
5937 |
"/ ] |
|
5938 |
"/ ]. |
|
5939 |
"/ stream close. |
|
5940 |
"/ "if xlsfont is broken ... (hey sco)" |
|
5941 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
5942 |
"/ listOfXFonts := nil |
|
5943 |
"/ ] ifFalse:[ |
|
5944 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
5945 |
"/ ]. |
|
5946 |
||
1344 | 5947 |
"/ |
5948 |
"/ new code: |
|
5949 |
"/ use new primitive to get font names; |
|
5950 |
"/ this is much faster, and also works on systems where |
|
5951 |
"/ a) xlsfonts is broken (sco) |
|
5952 |
"/ b) xlsfonts is not available (aix) |
|
5953 |
"/ |
|
5954 |
names := self getAvailableFontsMatching:'*'. |
|
5955 |
names isNil ifTrue:[ |
|
5956 |
"no names returned ..." |
|
5957 |
^ nil |
|
5958 |
]. |
|
5959 |
listOfXFonts := names collect:[:aName | |
|
5960 |
|fntDescr| |
|
5961 |
||
5962 |
(self decomposeXFontName:aName into: |
|
5963 |
[:family :face :style :size :coding | |
|
5964 |
family notNil ifTrue:[ |
|
5965 |
fntDescr := FontDescription |
|
5966 |
family:family |
|
5967 |
face:face |
|
5968 |
style:style |
|
5969 |
size:size |
|
5970 |
encoding:coding. |
|
5971 |
] ifFalse:[ |
|
5972 |
fntDescr := FontDescription |
|
5973 |
name:aName |
|
5974 |
] |
|
5975 |
] |
|
5976 |
) ifFalse:[ |
|
5977 |
fntDescr := FontDescription name:aName. |
|
5978 |
]. |
|
5979 |
fntDescr |
|
5980 |
]. |
|
295 | 5981 |
|
5982 |
]. |
|
5983 |
^ listOfXFonts |
|
5984 |
||
5985 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5986 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5987 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5988 |
Display getAvailableFontsMatching:'*'. |
295 | 5989 |
" |
5990 |
||
5991 |
"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
|
5992 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5993 |
! |
5994 |
||
1344 | 5995 |
releaseFont:aFontId |
295 | 5996 |
|
5997 |
%{ /* NOCONTEXT */ |
|
5998 |
||
5999 |
XFontStruct *f; |
|
6000 |
||
1212 | 6001 |
if (! ISCONNECTED) { |
1344 | 6002 |
RETURN ( self ); |
1212 | 6003 |
} |
6004 |
||
6005 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 6006 |
f = _FontVal(aFontId); |
6007 |
if (f) { |
|
6008 |
BEGIN_INTERRUPTSBLOCKED |
|
6009 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
6010 |
#ifdef COUNT_RESOURCES |
1344 | 6011 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
6012 |
#endif |
1344 | 6013 |
END_INTERRUPTSBLOCKED |
6014 |
RETURN ( self ); |
|
6015 |
} |
|
295 | 6016 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6017 |
%}. |
295 | 6018 |
self primitiveFailed |
6019 |
! |
|
6020 |
||
1344 | 6021 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 6022 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
6023 |
on this display. |
|
6024 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
6025 |
||
6026 |
|sizes| |
|
6027 |
||
466 | 6028 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 6029 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 6030 |
"special: in X11R5 and above, size 0 means: |
6031 |
there are scaled versions in all sizes available" |
|
6032 |
||
6033 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 6034 |
]. |
6035 |
^ sizes |
|
6036 |
||
6037 |
" |
|
6038 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
6039 |
" |
|
466 | 6040 |
|
6041 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 6042 |
! |
6043 |
||
1344 | 6044 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 6045 |
|
6046 |
%{ /* NOCONTEXT */ |
|
6047 |
||
6048 |
XFontStruct *f; |
|
6049 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6050 |
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
|
6051 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6052 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6053 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6054 |
int nInstBytes; |
295 | 6055 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6056 |
if (ISCONNECTED) { |
1344 | 6057 |
if (__bothSmallInteger(index1, index2) |
6058 |
&& __isExternalAddress(aFontId) |
|
6059 |
&& __isNonNilObject(aString)) { |
|
6060 |
f = _FontVal(aFontId); |
|
6061 |
if (! f) goto fail; |
|
6062 |
||
6063 |
i1 = __intVal(index1) - 1; |
|
6064 |
cls = __qClass(aString); |
|
6065 |
||
6066 |
if (i1 >= 0) { |
|
6067 |
i2 = __intVal(index2) - 1; |
|
6068 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6069 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 6070 |
} |
6071 |
||
6072 |
cp = (char *) _stringVal(aString); |
|
6073 |
l = i2 - i1 + 1; |
|
6074 |
||
6075 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6076 |
n = _stringSize(aString); |
|
6077 |
if (i2 < n) { |
|
6078 |
cp += i1; |
|
6079 |
BEGIN_INTERRUPTSBLOCKED |
|
6080 |
len = XTextWidth(f, cp, l); |
|
6081 |
END_INTERRUPTSBLOCKED |
|
6082 |
RETURN ( __MKSMALLINT(len) ); |
|
6083 |
} |
|
6084 |
} |
|
6085 |
||
6086 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6087 |
cp += nInstBytes; |
|
6088 |
||
6089 |
if (__isBytes(aString)) { |
|
6090 |
n = __byteArraySize(aString) - nInstBytes; |
|
6091 |
if (i2 < n) { |
|
6092 |
cp += i1; |
|
6093 |
BEGIN_INTERRUPTSBLOCKED |
|
6094 |
len = XTextWidth(f, cp, l); |
|
6095 |
END_INTERRUPTSBLOCKED |
|
6096 |
RETURN ( __MKSMALLINT(len) ); |
|
6097 |
} |
|
6098 |
} |
|
6099 |
||
6100 |
/* TWOBYTESTRINGS */ |
|
6101 |
if (__isWords(aString)) { |
|
6102 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6103 |
||
6104 |
if (i2 < n) { |
|
6105 |
union { |
|
6106 |
char b[2]; |
|
6107 |
unsigned short s; |
|
6108 |
} u; |
|
6109 |
int i; |
|
6110 |
XChar2b *cp2 = (XChar2b *)0; |
|
6111 |
int mustFree = 0; |
|
6112 |
||
6113 |
cp += (i1 * 2); |
|
6114 |
if (l > 1000) l = 1000; |
|
6115 |
||
6116 |
/* |
|
6117 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6118 |
* X expects them MSB first |
|
6119 |
* convert as required |
|
6120 |
*/ |
|
6121 |
||
6122 |
u.s = 0x1234; |
|
6123 |
if (u.b[0] != 0x12) { |
|
6124 |
if (l <= NLOCALBUFFER) { |
|
6125 |
cp2 = xlatebuffer; |
|
6126 |
} else { |
|
6127 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
6128 |
mustFree = 1; |
|
6129 |
} |
|
6130 |
for (i=0; i<l; i++) { |
|
6131 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6132 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6133 |
} |
|
6134 |
cp = (char *) cp2; |
|
6135 |
} |
|
6136 |
BEGIN_INTERRUPTSBLOCKED |
|
6137 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
6138 |
END_INTERRUPTSBLOCKED |
|
6139 |
||
6140 |
if (mustFree) { |
|
6141 |
free(cp2); |
|
6142 |
} |
|
6143 |
||
6144 |
RETURN ( __MKSMALLINT(len) ); |
|
6145 |
} |
|
6146 |
} |
|
6147 |
} |
|
6148 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6149 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6150 |
#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
|
6151 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6152 |
%}. |
295 | 6153 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6154 |
^ 0 |
295 | 6155 |
! |
6156 |
||
1344 | 6157 |
widthOf:aString inFont:aFontId |
295 | 6158 |
|
6159 |
%{ /* NOCONTEXT */ |
|
6160 |
||
6161 |
XFontStruct *f; |
|
6162 |
char *cp; |
|
6163 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
6164 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6165 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6166 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6167 |
int nInstBytes; |
295 | 6168 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6169 |
if (ISCONNECTED) { |
1344 | 6170 |
if (__isExternalAddress(aFontId) |
6171 |
&& __isNonNilObject(aString)) { |
|
6172 |
f = _FontVal(aFontId); |
|
6173 |
if (! f) goto fail; |
|
6174 |
||
6175 |
cls = __qClass(aString); |
|
6176 |
||
6177 |
cp = (char *)_stringVal(aString); |
|
6178 |
||
6179 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6180 |
n = _stringSize(aString); |
|
6181 |
BEGIN_INTERRUPTSBLOCKED |
|
6182 |
len = XTextWidth(f, cp, n); |
|
6183 |
END_INTERRUPTSBLOCKED |
|
6184 |
RETURN ( __MKSMALLINT(len) ); |
|
6185 |
} |
|
6186 |
||
6187 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6188 |
cp += nInstBytes; |
|
6189 |
||
6190 |
if (__isBytes(aString)) { |
|
6191 |
n = __byteArraySize(aString) - nInstBytes; |
|
6192 |
||
6193 |
BEGIN_INTERRUPTSBLOCKED |
|
6194 |
len = XTextWidth(f, cp, n); |
|
6195 |
END_INTERRUPTSBLOCKED |
|
6196 |
RETURN ( __MKSMALLINT(len) ); |
|
6197 |
} |
|
6198 |
||
6199 |
/* TWOBYTESTRINGS */ |
|
6200 |
if (__isWords(aString)) { |
|
6201 |
union { |
|
6202 |
char b[2]; |
|
6203 |
unsigned short s; |
|
6204 |
} u; |
|
6205 |
int i; |
|
6206 |
XChar2b *cp2; |
|
6207 |
int mustFree = 0; |
|
6208 |
||
6209 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6210 |
if (n > 1000) n = 1000; |
|
6211 |
||
6212 |
/* |
|
6213 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6214 |
* X expects them MSB first |
|
6215 |
* convert as required |
|
6216 |
*/ |
|
6217 |
||
6218 |
u.s = 0x1234; |
|
6219 |
if (u.b[0] != 0x12) { |
|
6220 |
if (n <= NLOCALBUFFER) { |
|
6221 |
cp2 = xlatebuffer; |
|
6222 |
} else { |
|
6223 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
6224 |
mustFree = 1; |
|
6225 |
} |
|
6226 |
||
6227 |
for (i=0; i<n; i++) { |
|
6228 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6229 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6230 |
} |
|
6231 |
cp = (char *) cp2; |
|
6232 |
} |
|
6233 |
||
6234 |
BEGIN_INTERRUPTSBLOCKED |
|
6235 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
6236 |
END_INTERRUPTSBLOCKED |
|
6237 |
||
6238 |
if (mustFree) { |
|
6239 |
free(cp2); |
|
6240 |
} |
|
6241 |
||
6242 |
RETURN ( __MKSMALLINT(len) ); |
|
6243 |
} |
|
6244 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6245 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6246 |
#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
|
6247 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6248 |
%}. |
295 | 6249 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6250 |
^ 0 |
295 | 6251 |
! ! |
6252 |
||
6253 |
!XWorkstation methodsFor:'grabbing '! |
|
6254 |
||
1344 | 6255 |
allowEvents:mode |
295 | 6256 |
%{ /* NOCONTEXT */ |
6257 |
||
6258 |
int _mode, ok = 1; |
|
6259 |
||
6260 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 6261 |
_mode = AsyncPointer; |
295 | 6262 |
else if (mode == @symbol(syncPointer)) |
1344 | 6263 |
_mode = SyncPointer; |
295 | 6264 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 6265 |
_mode = AsyncKeyboard; |
295 | 6266 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 6267 |
_mode = SyncKeyboard; |
295 | 6268 |
else if (mode == @symbol(syncBoth)) |
1344 | 6269 |
_mode = SyncBoth; |
295 | 6270 |
else if (mode == @symbol(asyncBoth)) |
1344 | 6271 |
_mode = AsyncBoth; |
295 | 6272 |
else if (mode == @symbol(replayPointer)) |
1344 | 6273 |
_mode = ReplayPointer; |
295 | 6274 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 6275 |
_mode = ReplayKeyboard; |
295 | 6276 |
else |
1344 | 6277 |
ok = 0; |
295 | 6278 |
|
6279 |
if (ok) { |
|
1344 | 6280 |
if (ISCONNECTED) { |
6281 |
BEGIN_INTERRUPTSBLOCKED |
|
6282 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
6283 |
END_INTERRUPTSBLOCKED |
|
6284 |
RETURN (self); |
|
6285 |
} |
|
295 | 6286 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6287 |
%}. |
295 | 6288 |
self primitiveFailed |
6289 |
! |
|
6290 |
||
1344 | 6291 |
grabKeyboardIn:aWindowId |
295 | 6292 |
"grab the keyboard" |
6293 |
||
6294 |
%{ /* NOCONTEXT */ |
|
6295 |
int result, ok; |
|
6296 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6297 |
if (ISCONNECTED) { |
1344 | 6298 |
if (__isExternalAddress(aWindowId)) { |
6299 |
BEGIN_INTERRUPTSBLOCKED |
|
6300 |
result = XGrabKeyboard(myDpy, |
|
6301 |
_WindowVal(aWindowId), |
|
6302 |
True /* False */, |
|
6303 |
GrabModeAsync, |
|
6304 |
GrabModeAsync, |
|
6305 |
CurrentTime); |
|
6306 |
END_INTERRUPTSBLOCKED |
|
6307 |
ok = 0; |
|
6308 |
switch(result) { |
|
6309 |
case AlreadyGrabbed: |
|
6310 |
if (@global(ErrorPrinting) == true) { |
|
6311 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
6312 |
} |
|
6313 |
break; |
|
6314 |
case GrabNotViewable: |
|
6315 |
if (@global(ErrorPrinting) == true) { |
|
6316 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
6317 |
} |
|
6318 |
break; |
|
6319 |
case GrabInvalidTime: |
|
6320 |
if (@global(ErrorPrinting) == true) { |
|
6321 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
6322 |
} |
|
6323 |
break; |
|
6324 |
case GrabFrozen: |
|
6325 |
if (@global(ErrorPrinting) == true) { |
|
6326 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
6327 |
} |
|
6328 |
break; |
|
6329 |
default: |
|
6330 |
ok = 1; |
|
6331 |
break; |
|
6332 |
} |
|
6333 |
if (! ok) { |
|
6334 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6335 |
RETURN (false); |
|
6336 |
} |
|
6337 |
||
6338 |
RETURN ( true ); |
|
6339 |
} |
|
295 | 6340 |
} |
1183 | 6341 |
%}. |
295 | 6342 |
self primitiveFailed |
6343 |
! |
|
6344 |
||
1344 | 6345 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 6346 |
"grap the pointer - return true if ok" |
6347 |
||
6348 |
%{ /* NOCONTEXT */ |
|
6349 |
||
6350 |
int result, ok; |
|
6351 |
Window confineWin; |
|
6352 |
Cursor curs; |
|
6353 |
int pointer_mode, keyboard_mode; |
|
6354 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6355 |
if (ISCONNECTED) { |
1344 | 6356 |
if (__isExternalAddress(aWindowId)) { |
6357 |
if (__isExternalAddress(confineId)) |
|
6358 |
confineWin = _WindowVal(confineId); |
|
6359 |
else |
|
6360 |
confineWin = (Window) None; |
|
6361 |
||
6362 |
if (__isExternalAddress(aCursorId)) |
|
6363 |
curs = _CursorVal(aCursorId); |
|
6364 |
else |
|
6365 |
curs = (Cursor) None; |
|
6366 |
||
6367 |
if (pMode == @symbol(sync)) |
|
6368 |
pointer_mode = GrabModeSync; |
|
6369 |
else |
|
6370 |
pointer_mode = GrabModeAsync; |
|
6371 |
||
6372 |
if (kMode == @symbol(sync)) |
|
6373 |
keyboard_mode = GrabModeSync; |
|
6374 |
else |
|
6375 |
keyboard_mode = GrabModeAsync; |
|
6376 |
||
6377 |
BEGIN_INTERRUPTSBLOCKED |
|
6378 |
result = XGrabPointer(myDpy, |
|
6379 |
_WindowVal(aWindowId), |
|
6380 |
False, |
|
6381 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
6382 |
pointer_mode, keyboard_mode, |
|
6383 |
confineWin, |
|
6384 |
curs, |
|
6385 |
CurrentTime); |
|
6386 |
END_INTERRUPTSBLOCKED |
|
6387 |
||
6388 |
ok = 0; |
|
6389 |
switch (result) { |
|
6390 |
case AlreadyGrabbed: |
|
6391 |
if (@global(ErrorPrinting) == true) { |
|
6392 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
6393 |
} |
|
6394 |
break; |
|
6395 |
case GrabNotViewable: |
|
6396 |
if (@global(ErrorPrinting) == true) { |
|
6397 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
6398 |
} |
|
6399 |
break; |
|
6400 |
case GrabInvalidTime: |
|
6401 |
if (@global(ErrorPrinting) == true) { |
|
6402 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
6403 |
} |
|
6404 |
break; |
|
6405 |
case GrabFrozen: |
|
6406 |
if (@global(ErrorPrinting) == true) { |
|
6407 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
6408 |
} |
|
6409 |
break; |
|
6410 |
default: |
|
6411 |
ok = 1; |
|
6412 |
break; |
|
6413 |
} |
|
6414 |
||
6415 |
if (! ok) { |
|
6416 |
XUngrabPointer(myDpy, CurrentTime); |
|
6417 |
RETURN (false); |
|
6418 |
} |
|
6419 |
RETURN ( true ); |
|
6420 |
} |
|
295 | 6421 |
} |
1183 | 6422 |
%}. |
295 | 6423 |
self primitiveFailed |
6424 |
! |
|
6425 |
||
1344 | 6426 |
ungrabKeyboard |
295 | 6427 |
"release the keyboard" |
6428 |
||
6429 |
%{ /* NOCONTEXT */ |
|
6430 |
||
6431 |
if (ISCONNECTED) { |
|
1344 | 6432 |
BEGIN_INTERRUPTSBLOCKED |
6433 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6434 |
XSync(myDpy, 0); |
|
6435 |
END_INTERRUPTSBLOCKED |
|
295 | 6436 |
} |
6437 |
%}. |
|
6438 |
activeKeyboardGrab := nil |
|
6439 |
! |
|
6440 |
||
1344 | 6441 |
ungrabPointer |
295 | 6442 |
"release the pointer" |
6443 |
||
6444 |
%{ /* NOCONTEXT */ |
|
6445 |
||
6446 |
if (ISCONNECTED) { |
|
1344 | 6447 |
BEGIN_INTERRUPTSBLOCKED |
6448 |
XUngrabPointer(myDpy, CurrentTime); |
|
6449 |
XSync(myDpy, 0); |
|
6450 |
END_INTERRUPTSBLOCKED |
|
295 | 6451 |
} |
6452 |
%}. |
|
6453 |
activePointerGrab := nil |
|
6454 |
! ! |
|
6455 |
||
6456 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
6457 |
||
1709
342fc0eb3517
pass drawableId to clip methods (req'd for Windows)
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
6458 |
noClipIn:aDrawableId gc:aGCId |
295 | 6459 |
"disable clipping rectangle" |
6460 |
||
6461 |
%{ /* NOCONTEXT */ |
|
6462 |
||
6463 |
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
|
6464 |
GC gc; |
295 | 6465 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6466 |
if (ISCONNECTED) { |
1344 | 6467 |
if (__isExternalAddress(aGCId)) { |
6468 |
gc = _GCVal(aGCId); |
|
6469 |
gcv.clip_mask = None; |
|
6470 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
6471 |
RETURN ( self ); |
|
6472 |
} |
|
295 | 6473 |
} |
6474 |
%}. |
|
6475 |
self primitiveFailed |
|
6476 |
! |
|
6477 |
||
1344 | 6478 |
setBackground:bgColorIndex in:aGCId |
295 | 6479 |
"set background color to be drawn with" |
6480 |
||
6481 |
%{ /* NOCONTEXT */ |
|
6482 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6483 |
if (ISCONNECTED) { |
1344 | 6484 |
if (__isExternalAddress(aGCId) |
6485 |
&& __isSmallInteger(bgColorIndex)) { |
|
6486 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
|
6487 |
RETURN ( self ); |
|
6488 |
} |
|
295 | 6489 |
} |
6490 |
%}. |
|
6491 |
self primitiveFailed |
|
6492 |
! |
|
6493 |
||
1344 | 6494 |
setBitmapMask:aBitmapId in:aGCId |
295 | 6495 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
6496 |
||
6497 |
%{ /* NOCONTEXT */ |
|
6498 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6499 |
GC gc; |
295 | 6500 |
Pixmap bitmap; |
6501 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6502 |
if (ISCONNECTED) { |
1344 | 6503 |
Display *dpy = myDpy; |
6504 |
||
6505 |
if (__isExternalAddress(aGCId)) { |
|
6506 |
gc = _GCVal(aGCId); |
|
6507 |
if (__isExternalAddress(aBitmapId)) { |
|
6508 |
bitmap = _PixmapVal(aBitmapId); |
|
6509 |
XSetStipple(dpy, gc, bitmap); |
|
6510 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
6511 |
RETURN ( self ); |
|
6512 |
} |
|
6513 |
if (aBitmapId == nil) { |
|
6514 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6515 |
RETURN ( self ); |
|
6516 |
} |
|
6517 |
} |
|
295 | 6518 |
} |
6519 |
%}. |
|
6520 |
self primitiveFailed |
|
6521 |
! |
|
6522 |
||
1681
069ede63fb19
pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents:
1627
diff
changeset
|
6523 |
setClipByChildren:aBool in:aDrawableId gc:aGCId |
295 | 6524 |
"enable/disable drawing into child views" |
6525 |
||
6526 |
%{ /* NOCONTEXT */ |
|
6527 |
||
6528 |
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
|
6529 |
GC gc; |
295 | 6530 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6531 |
if (ISCONNECTED) { |
1694 | 6532 |
if (__isExternalAddress(aGCId)) { |
6533 |
gc = _GCVal(aGCId); |
|
6534 |
if (aBool == true) |
|
6535 |
gcv.subwindow_mode = ClipByChildren; |
|
6536 |
else |
|
6537 |
gcv.subwindow_mode = IncludeInferiors; |
|
6538 |
||
6539 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
6540 |
RETURN ( self ); |
|
6541 |
} |
|
295 | 6542 |
} |
6543 |
%}. |
|
6544 |
self primitiveFailed |
|
6545 |
! |
|
6546 |
||
1709
342fc0eb3517
pass drawableId to clip methods (req'd for Windows)
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
6547 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:drawableId gc:aGCId |
295 | 6548 |
"clip to a rectangle" |
6549 |
||
6550 |
%{ /* NOCONTEXT */ |
|
6551 |
||
6552 |
XRectangle r; |
|
6553 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6554 |
if (ISCONNECTED) { |
1344 | 6555 |
if (__isExternalAddress(aGCId) |
6556 |
&& __bothSmallInteger(clipX, clipY) |
|
6557 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
6558 |
r.x = __intVal(clipX); |
|
6559 |
r.y = __intVal(clipY); |
|
6560 |
r.width = __intVal(clipWidth); |
|
6561 |
r.height = __intVal(clipHeight); |
|
6562 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
6563 |
RETURN ( self ); |
|
6564 |
} |
|
295 | 6565 |
} |
6566 |
%}. |
|
6567 |
self primitiveFailed |
|
6568 |
! |
|
6569 |
||
1344 | 6570 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 6571 |
"set line attributes" |
6572 |
||
6573 |
%{ /* NOCONTEXT */ |
|
6574 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6575 |
if (ISCONNECTED) { |
1344 | 6576 |
if (__isExternalAddress(aGCId) |
6577 |
&& __isSmallInteger(offset) |
|
6578 |
&& __isByteArray(dashList)) { |
|
6579 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
6580 |
__intVal(offset), |
|
6581 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
6582 |
__byteArraySize(dashList)); |
|
6583 |
RETURN ( self ); |
|
6584 |
} |
|
788 | 6585 |
} |
6586 |
bad: ; |
|
6587 |
%}. |
|
6588 |
" |
|
6589 |
either aGCId is invalid, |
|
6590 |
and/or dashList is not a byteArray |
|
6591 |
and/or offset is not a smallInteger |
|
6592 |
" |
|
6593 |
self primitiveFailed |
|
6594 |
! |
|
6595 |
||
1344 | 6596 |
setFont:aFontId in:aGCId |
295 | 6597 |
"set font to be drawn in" |
6598 |
||
6599 |
%{ /* NOCONTEXT */ |
|
6600 |
||
6601 |
XFontStruct *f; |
|
6602 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6603 |
if (ISCONNECTED) { |
1344 | 6604 |
if (__isExternalAddress(aFontId) |
6605 |
&& __isExternalAddress(aGCId)) { |
|
6606 |
f = (XFontStruct *) _FontVal(aFontId); |
|
6607 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
6608 |
RETURN ( self ); |
|
6609 |
} |
|
295 | 6610 |
} |
6611 |
%}. |
|
6612 |
" |
|
6613 |
aGCId and/or aFontId are invalid |
|
6614 |
" |
|
6615 |
self primitiveFailed |
|
6616 |
! |
|
6617 |
||
1344 | 6618 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 6619 |
"set foreground and background colors to be drawn with" |
6620 |
||
6621 |
%{ /* NOCONTEXT */ |
|
6622 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6623 |
GC gc; |
295 | 6624 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6625 |
if (ISCONNECTED) { |
1344 | 6626 |
Display *dpy = myDpy; |
6627 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
6628 |
&& __isExternalAddress(aGCId)) { |
|
6629 |
gc = _GCVal(aGCId); |
|
6630 |
||
6631 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
|
6632 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
6633 |
RETURN ( self ); |
|
6634 |
} |
|
295 | 6635 |
} |
6636 |
%}. |
|
6637 |
self primitiveFailed |
|
6638 |
! |
|
6639 |
||
1344 | 6640 |
setForeground:fgColorIndex in:aGCId |
295 | 6641 |
"set foreground color to be drawn with" |
6642 |
||
6643 |
%{ /* NOCONTEXT */ |
|
6644 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6645 |
if (ISCONNECTED) { |
1344 | 6646 |
if (__isExternalAddress(aGCId) |
6647 |
&& __isSmallInteger(fgColorIndex)) { |
|
6648 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
|
6649 |
RETURN ( self ); |
|
6650 |
} |
|
295 | 6651 |
} |
6652 |
%}. |
|
6653 |
self primitiveFailed |
|
6654 |
! |
|
6655 |
||
1344 | 6656 |
setFunction:aFunctionSymbol in:aGCId |
295 | 6657 |
"set alu function to be drawn with" |
6658 |
||
6659 |
%{ /* NOCONTEXT */ |
|
6660 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6661 |
GC gc; |
295 | 6662 |
int fun = -1; |
6663 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6664 |
if (ISCONNECTED) { |
1344 | 6665 |
if (__isExternalAddress(aGCId)) { |
6666 |
gc = _GCVal(aGCId); |
|
6667 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
6668 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
6669 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
6670 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
6671 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
6672 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
6673 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
6674 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
6675 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
6676 |
if (fun != -1) { |
|
6677 |
XSetFunction(myDpy, gc, fun); |
|
6678 |
RETURN ( self ); |
|
6679 |
} |
|
6680 |
} |
|
295 | 6681 |
} |
6682 |
%}. |
|
6683 |
" |
|
6684 |
either aGCId is not an integer, or an invalid symbol |
|
6685 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
6686 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
6687 |
" |
|
6688 |
self primitiveFailed |
|
6689 |
! |
|
6690 |
||
1344 | 6691 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 6692 |
"set or clear the graphics exposures flag" |
6693 |
||
6694 |
%{ /* NOCONTEXT */ |
|
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(aGCId)) { |
6698 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
6699 |
RETURN ( self ); |
|
6700 |
} |
|
295 | 6701 |
} |
6702 |
%} |
|
6703 |
. |
|
6704 |
self primitiveFailed |
|
6705 |
! |
|
6706 |
||
1344 | 6707 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
1455 | 6708 |
"set line attributes; |
6709 |
lineStyle must be one of #solid, #dashed or #doubleDashed; |
|
6710 |
capStyle one of: #notLast, #butt, #round or #projecting; |
|
6711 |
joinStyle one of: #miter, #bevel or #round." |
|
295 | 6712 |
|
6713 |
%{ /* NOCONTEXT */ |
|
6714 |
||
6715 |
int x_style, x_cap, x_join; |
|
6716 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6717 |
if (ISCONNECTED) { |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6718 |
if (__isExternalAddress(aGCId) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6719 |
&& __isSmallInteger(aNumber)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6720 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6721 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6722 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6723 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6724 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6725 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6726 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6727 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6728 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6729 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6730 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6731 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6732 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6733 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6734 |
else goto bad; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6735 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6736 |
XSetLineAttributes(myDpy, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6737 |
_GCVal(aGCId), __intVal(aNumber), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6738 |
x_style, x_cap, x_join); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6739 |
RETURN ( self ); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6740 |
} |
295 | 6741 |
} |
6742 |
bad: ; |
|
6743 |
%}. |
|
6744 |
" |
|
6745 |
either aGCId is invalid, |
|
1455 | 6746 |
and/or lineWidth is not a smallInteger, |
295 | 6747 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
6748 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
6749 |
and/or joinStyle is none of #miter, #bevel, #round |
|
6750 |
" |
|
6751 |
self primitiveFailed |
|
6752 |
! |
|
6753 |
||
1344 | 6754 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 6755 |
"set the mask origin" |
6756 |
||
6757 |
%{ /* NOCONTEXT */ |
|
6758 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6759 |
if (ISCONNECTED) { |
1344 | 6760 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
6761 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
|
6762 |
RETURN ( self ); |
|
6763 |
} |
|
295 | 6764 |
} |
6765 |
%}. |
|
6766 |
self primitiveFailed |
|
6767 |
! |
|
6768 |
||
1344 | 6769 |
setPixmapMask:aPixmapId in:aGCId |
295 | 6770 |
"set or clear the drawing mask - a pixmap mask providing full color" |
6771 |
||
6772 |
%{ /* NOCONTEXT */ |
|
6773 |
||
6774 |
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
|
6775 |
GC gc; |
295 | 6776 |
Pixmap pixmap; |
6777 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6778 |
if (ISCONNECTED) { |
1344 | 6779 |
if (__isExternalAddress(aGCId)) { |
6780 |
gc = _GCVal(aGCId); |
|
6781 |
if (__isExternalAddress(aPixmapId)) { |
|
6782 |
pixmap = _PixmapVal(aPixmapId); |
|
6783 |
XSetTile(dpy, gc, pixmap); |
|
6784 |
XSetFillStyle(dpy, gc, FillTiled); |
|
6785 |
RETURN ( self ); |
|
6786 |
} |
|
6787 |
if (aPixmapId == nil) { |
|
6788 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6789 |
RETURN ( self ); |
|
6790 |
} |
|
6791 |
} |
|
295 | 6792 |
} |
6793 |
%}. |
|
6794 |
self primitiveFailed |
|
6795 |
! ! |
|
6796 |
||
6797 |
!XWorkstation methodsFor:'initialize / release'! |
|
6798 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6799 |
brokenConnection |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6800 |
"the connection to the X-server was lost" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6801 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6802 |
displayId := nil. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6803 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6804 |
"/ tell all of my views about this. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6805 |
"/ first, all topViews get a notification ... |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6806 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6807 |
self allViewsDo:[:aView | |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6808 |
aView isTopView ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6809 |
aView destroyed |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6810 |
] |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6811 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6812 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6813 |
self releaseDeviceResources. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6814 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6815 |
"Modified: 11.4.1997 / 10:44:33 / cg" |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6816 |
! |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6817 |
|
1344 | 6818 |
closeConnection |
295 | 6819 |
"close down the connection to the X-server" |
6820 |
||
6821 |
%{ /* NOCONTEXT */ |
|
6822 |
||
6823 |
if (ISCONNECTED) { |
|
1344 | 6824 |
Display *dpy = myDpy; |
6825 |
||
6826 |
BEGIN_INTERRUPTSBLOCKED |
|
6827 |
__INST(displayId) = nil; |
|
6828 |
XCloseDisplay(dpy); |
|
6829 |
END_INTERRUPTSBLOCKED |
|
295 | 6830 |
} |
6831 |
%} |
|
6832 |
! |
|
6833 |
||
1344 | 6834 |
initializeDefaultValues |
295 | 6835 |
buttonTranslation := ButtonTranslation. |
6836 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
6837 |
||
6838 |
self initializeModifierMappings |
|
6839 |
! |
|
6840 |
||
1344 | 6841 |
initializeEventBuffer |
295 | 6842 |
|sz| |
6843 |
||
6844 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6845 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 6846 |
%}. |
6847 |
eventBuffer isNil ifTrue:[ |
|
1344 | 6848 |
eventBuffer := ByteArray new:sz. |
295 | 6849 |
]. |
6850 |
! |
|
6851 |
||
1344 | 6852 |
initializeFor:aDisplayName |
295 | 6853 |
"initialize the receiver for a connection to an X-Server; |
6854 |
the argument, aDisplayName may be nil (for the default server from |
|
6855 |
DISPLAY-variable or command line argument) or the name of the server |
|
6856 |
as hostname:number" |
|
6857 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
6858 |
|dpyName index arguments| |
295 | 6859 |
|
6860 |
dpyName := aDisplayName. |
|
6861 |
dpyName isNil ifTrue:[ |
|
1344 | 6862 |
"look for a '-display xxx' argument" |
6863 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
6864 |
index := arguments indexOf:'-display'. |
|
6865 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
6866 |
dpyName := arguments at:index+1 |
|
6867 |
] |
|
6868 |
] |
|
295 | 6869 |
]. |
6870 |
%{ |
|
6871 |
int scr; |
|
6872 |
Display *dpy; |
|
6873 |
Visual *visual; |
|
6874 |
XVisualInfo viproto; |
|
6875 |
XVisualInfo *vip; /* retured info */ |
|
6876 |
int maxRGBDepth; |
|
6877 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6878 |
int rgbVisualID; |
|
6879 |
int nvi, i; |
|
6880 |
char *type, *nm; |
|
6881 |
int dummy; |
|
6882 |
OBJ dpyID; |
|
6883 |
||
555 | 6884 |
if (__INST(displayId) != nil) { |
1344 | 6885 |
/* |
6886 |
* already connected - you bad guy try to |
|
6887 |
* trick me manually ? |
|
6888 |
*/ |
|
6889 |
RETURN ( self ); |
|
295 | 6890 |
} |
6891 |
||
6892 |
BEGIN_INTERRUPTSBLOCKED |
|
6893 |
||
6894 |
if (__isString(dpyName)) |
|
1344 | 6895 |
nm = (char *)_stringVal(dpyName); |
295 | 6896 |
else { |
1344 | 6897 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
6898 |
nm = NULL; |
|
295 | 6899 |
} |
6900 |
dpy = XOpenDisplay(nm); |
|
6901 |
||
6902 |
if (dpy) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6903 |
static int firstCall = 1; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6904 |
|
1344 | 6905 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 6906 |
|
6907 |
#ifdef SUPERDEBUG |
|
1344 | 6908 |
XSynchronize(dpy, 1); |
295 | 6909 |
#endif |
6910 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6911 |
if (firstCall) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6912 |
firstCall = 0; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6913 |
XSetErrorHandler(__XErrorHandler__); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6914 |
XSetIOErrorHandler(__XIOErrorHandler__); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6915 |
} |
295 | 6916 |
} |
6917 |
||
6918 |
END_INTERRUPTSBLOCKED |
|
6919 |
%}. |
|
6920 |
displayId isNil ifTrue:[ |
|
1344 | 6921 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
6922 |
^ nil |
|
295 | 6923 |
]. |
6924 |
||
6925 |
dispatching := false. |
|
6926 |
dispatchingExpose := false. |
|
6927 |
isSlow := false. |
|
6928 |
shiftDown := false. |
|
6929 |
ctrlDown := false. |
|
6930 |
metaDown := false. |
|
6931 |
altDown := false. |
|
6932 |
motionEventCompression := true. |
|
6933 |
buttonsPressed := 0. |
|
6934 |
displayName := dpyName. |
|
6935 |
||
6936 |
protocolsAtom := nil. |
|
6937 |
deleteWindowAtom := nil. |
|
6938 |
saveYourselfAtom := nil. |
|
6939 |
quitAppAtom := nil. |
|
6940 |
||
6941 |
self initializeScreenProperties. |
|
1366 | 6942 |
self initializeDeviceResourceTables. |
295 | 6943 |
|
6944 |
self initializeDefaultValues. |
|
6945 |
self initializeEventBuffer. |
|
6946 |
self initializeSpecialFlags. |
|
6947 |
self initializeKeyboardMap. |
|
6948 |
||
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6949 |
deviceErrorSignal := DeviceErrorSignal newSignalMayProceed:false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6950 |
deviceErrorSignal nameClass:self class message:#deviceErrorSignal. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6951 |
deviceIOErrorSignal := DeviceIOErrorSignal newSignalMayProceed:false. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6952 |
deviceIOErrorSignal nameClass:self class message:#deviceIOErrorSignal. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6953 |
|
295 | 6954 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
6955 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayIOError. |
295 | 6956 |
! |
6957 |
||
1344 | 6958 |
initializeModifierMappings |
295 | 6959 |
|map mod| |
6960 |
||
6961 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6962 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6963 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6964 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6965 |
||
6966 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6967 |
altModifierMask := metaModifierMask := nil. |
|
6968 |
||
6969 |
map := self modifierMapping. |
|
342 | 6970 |
map isNil ifTrue:[ |
1344 | 6971 |
"/ |
6972 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6973 |
"/ setup some reasonable default. If that is not sufficient, |
|
6974 |
"/ you have to change things from your display.rc file. |
|
6975 |
"/ |
|
6976 |
altModifierMask := self modifier1Mask. |
|
6977 |
metaModifierMask := self modifier2Mask. |
|
6978 |
||
6979 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6980 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6981 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6982 |
altModifiers := #(Alt_R Alt). |
|
342 | 6983 |
] ifFalse:[ |
1344 | 6984 |
altModifierMask := 0. |
6985 |
metaModifierMask := 0. |
|
6986 |
||
6987 |
mod := map at:1. |
|
6988 |
mod notNil ifTrue:[ |
|
6989 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6990 |
]. |
|
6991 |
mod := map at:3. |
|
6992 |
mod notNil ifTrue:[ |
|
6993 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6994 |
]. |
|
6995 |
mod := map at:4. |
|
6996 |
mod notNil ifTrue:[ |
|
6997 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6998 |
metaModifierMask := 1 bitShift:(4-1). |
|
6999 |
]. |
|
7000 |
mod := map at:5. |
|
7001 |
mod notNil ifTrue:[ |
|
7002 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
7003 |
altModifierMask := 1 bitShift:(5-1). |
|
7004 |
] |
|
295 | 7005 |
]. |
7006 |
||
7007 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
7008 |
! |
|
7009 |
||
1344 | 7010 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7011 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7012 |
|
1627
e7ba6be03b14
removed dangerous NOCONTEXT primitives
Claus Gittinger <cg@exept.de>
parents:
1610
diff
changeset
|
7013 |
%{ |
295 | 7014 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7015 |
Display *dpy; |
295 | 7016 |
int scr; |
7017 |
Visual *visual; |
|
7018 |
XVisualInfo viproto; |
|
7019 |
XVisualInfo *vip; /* retured info */ |
|
7020 |
int maxRGBDepth; |
|
7021 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
7022 |
int rgbVisualID; |
|
7023 |
int nvi, i; |
|
7024 |
int shapeEventBase, shapeErrorBase; |
|
7025 |
int shmEventBase, shmErrorBase; |
|
7026 |
char *type, *nm; |
|
7027 |
int dummy; |
|
7028 |
int mask, shift, nBits; |
|
7029 |
||
7030 |
if (ISCONNECTED) { |
|
1344 | 7031 |
dpy = myDpy; |
7032 |
||
7033 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
7034 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
7035 |
||
7036 |
BEGIN_INTERRUPTSBLOCKED |
|
7037 |
||
7038 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
7039 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
7040 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
7041 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
7042 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
7043 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
7044 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
7045 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
7046 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 7047 |
|
7048 |
#ifdef SHAPE |
|
1344 | 7049 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
7050 |
__INST(hasShapeExtension) = true; |
|
7051 |
else |
|
295 | 7052 |
#endif |
1344 | 7053 |
__INST(hasShapeExtension) = false; |
295 | 7054 |
|
7055 |
#ifdef SHM |
|
1344 | 7056 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
7057 |
__INST(hasShmExtension) = true; |
|
7058 |
else |
|
295 | 7059 |
#endif |
1344 | 7060 |
__INST(hasShmExtension) = false; |
295 | 7061 |
|
7062 |
#ifdef DPS |
|
1344 | 7063 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
7064 |
__INST(hasDPSExtension) = true; |
|
7065 |
else |
|
295 | 7066 |
#endif |
1344 | 7067 |
__INST(hasDPSExtension) = false; |
295 | 7068 |
|
7069 |
#ifdef XVIDEO |
|
1344 | 7070 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
7071 |
__INST(hasXVideoExtension) = true; |
|
7072 |
else |
|
295 | 7073 |
#endif |
1344 | 7074 |
__INST(hasXVideoExtension) = false; |
295 | 7075 |
|
7076 |
#ifdef MBUF |
|
1344 | 7077 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
7078 |
__INST(hasMbufExtension) = true; |
|
7079 |
else |
|
295 | 7080 |
#endif |
1344 | 7081 |
__INST(hasMbufExtension) = false; |
295 | 7082 |
|
7083 |
#ifdef PEX5 |
|
1344 | 7084 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
7085 |
__INST(hasPEXExtension) = true; |
|
7086 |
else |
|
295 | 7087 |
#endif |
1344 | 7088 |
__INST(hasPEXExtension) = false; |
295 | 7089 |
|
7090 |
#ifdef XIE |
|
1344 | 7091 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
7092 |
__INST(hasImageExtension) = true; |
|
7093 |
else |
|
295 | 7094 |
#endif |
1344 | 7095 |
__INST(hasImageExtension) = false; |
295 | 7096 |
|
7097 |
#ifdef XI |
|
1344 | 7098 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
7099 |
__INST(hasInputExtension) = true; |
|
7100 |
else |
|
295 | 7101 |
#endif |
1344 | 7102 |
__INST(hasInputExtension) = false; |
7103 |
||
7104 |
/* |
|
7105 |
* look for RGB visual |
|
7106 |
*/ |
|
7107 |
nvi = 0; |
|
7108 |
viproto.screen = scr; |
|
7109 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
7110 |
maxRGBDepth = 0; |
|
7111 |
for (i = 0; i < nvi; i++) { |
|
7112 |
switch (vip[i].class) { |
|
7113 |
case TrueColor: |
|
7114 |
if (vip[i].depth > maxRGBDepth) { |
|
7115 |
maxRGBDepth = vip[i].depth; |
|
7116 |
rgbRedMask = vip[i].red_mask; |
|
7117 |
rgbGreenMask = vip[i].green_mask; |
|
7118 |
rgbBlueMask = vip[i].blue_mask; |
|
7119 |
rgbVisualID = vip[i].visualid; |
|
7120 |
} |
|
7121 |
break; |
|
7122 |
} |
|
7123 |
} |
|
7124 |
if (vip) XFree ((char *) vip); |
|
7125 |
||
7126 |
if (maxRGBDepth) { |
|
7127 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
7128 |
} |
|
7129 |
||
7130 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
7131 |
__INST(monitorType) = @symbol(unknown); |
|
7132 |
__INST(hasColors) = true; |
|
7133 |
__INST(hasGreyscales) = true; |
|
7134 |
switch (visual->class) { |
|
7135 |
case StaticGray: |
|
7136 |
__INST(visualType) = @symbol(StaticGray); |
|
7137 |
__INST(hasColors) = false; |
|
7138 |
__INST(monitorType) = @symbol(monochrome); |
|
7139 |
break; |
|
7140 |
case GrayScale: |
|
7141 |
__INST(visualType) = @symbol(GrayScale); |
|
7142 |
__INST(hasColors) = false; |
|
7143 |
__INST(monitorType) = @symbol(monochrome); |
|
7144 |
break; |
|
7145 |
case StaticColor: |
|
7146 |
__INST(visualType) = @symbol(StaticColor); |
|
7147 |
break; |
|
7148 |
case PseudoColor: |
|
7149 |
__INST(visualType) = @symbol(PseudoColor); |
|
7150 |
break; |
|
7151 |
case TrueColor: |
|
7152 |
__INST(visualType) = @symbol(TrueColor); |
|
7153 |
break; |
|
7154 |
case DirectColor: |
|
7155 |
__INST(visualType) = @symbol(DirectColor); |
|
7156 |
break; |
|
7157 |
} |
|
7158 |
if (DisplayCells(dpy, scr) == 2) { |
|
7159 |
__INST(hasColors) = false; |
|
7160 |
__INST(hasGreyscales) = false; |
|
7161 |
__INST(monitorType) = @symbol(monochrome); |
|
7162 |
} |
|
7163 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
7164 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
7165 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
7166 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
7167 |
switch (visual->class) { |
|
7168 |
case TrueColor: |
|
7169 |
/* extract number of bits and shift counts */ |
|
7170 |
mask = visual->red_mask; |
|
7171 |
shift = 0; |
|
7172 |
while (mask && ((mask & 1) == 0)) { |
|
7173 |
mask >>= 1; |
|
7174 |
shift++; |
|
7175 |
} |
|
7176 |
__INST(redShift) = __MKSMALLINT(shift); |
|
7177 |
nBits = 0; |
|
7178 |
while (mask) { |
|
7179 |
mask >>= 1; |
|
7180 |
nBits++; |
|
7181 |
} |
|
7182 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
7183 |
||
7184 |
mask = visual->green_mask; |
|
7185 |
shift = 0; |
|
7186 |
while (mask && ((mask & 1) == 0)) { |
|
7187 |
mask >>= 1; |
|
7188 |
shift++; |
|
7189 |
} |
|
7190 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
7191 |
nBits = 0; |
|
7192 |
while (mask) { |
|
7193 |
mask >>= 1; |
|
7194 |
nBits++; |
|
7195 |
} |
|
7196 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
7197 |
||
7198 |
mask = visual->blue_mask; |
|
7199 |
shift = 0; |
|
7200 |
while (mask && ((mask & 1) == 0)) { |
|
7201 |
mask >>= 1; |
|
7202 |
shift++; |
|
7203 |
} |
|
7204 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
7205 |
nBits = 0; |
|
7206 |
while (mask) { |
|
7207 |
mask >>= 1; |
|
7208 |
nBits++; |
|
7209 |
} |
|
7210 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
7211 |
break; |
|
7212 |
} |
|
295 | 7213 |
|
7214 |
#ifndef XA_PRIMARY |
|
1344 | 7215 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 7216 |
#else |
1344 | 7217 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 7218 |
#endif |
7219 |
#ifndef XA_SECONDARY |
|
1344 | 7220 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 7221 |
#else |
1344 | 7222 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 7223 |
#endif |
7224 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 7225 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 7226 |
#else |
1344 | 7227 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 7228 |
#endif |
7229 |
#ifndef XA_STRING |
|
1344 | 7230 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 7231 |
#else |
1344 | 7232 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 7233 |
#endif |
7234 |
#ifndef XA_LENGTH |
|
1344 | 7235 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 7236 |
#else |
1344 | 7237 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 7238 |
#endif |
1533 | 7239 |
#ifndef WM_STATE |
7240 |
__INST(wmStateAtom) = __MKATOMOBJ( XInternAtom(dpy, "WM_STATE", True) ); |
|
7241 |
#else |
|
7242 |
__INST(wmStateAtom) = __MKATOMOBJ( WM_STATE ); |
|
7243 |
#endif |
|
295 | 7244 |
|
1344 | 7245 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7246 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7247 |
%}. |
295 | 7248 |
! |
7249 |
||
1344 | 7250 |
initializeSpecialFlags |
295 | 7251 |
"perform additional special server implementation flags" |
7252 |
||
7253 |
"/ |
|
7254 |
"/ assume we have it ... (should check) |
|
7255 |
"/ |
|
7256 |
hasSaveUnder := true. |
|
7257 |
ignoreBackingStore := false. |
|
7258 |
||
7259 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 7260 |
"/ |
7261 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
7262 |
"/ which does not correctly handle saveUnder |
|
7263 |
"/ |
|
7264 |
hasSaveUnder := false. |
|
295 | 7265 |
]. |
7266 |
! |
|
7267 |
||
1344 | 7268 |
reinitialize |
295 | 7269 |
virtualRootId := rootId := nil. |
7270 |
super reinitialize. |
|
7271 |
dispatchingExpose := nil |
|
7272 |
! ! |
|
7273 |
||
7274 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
7275 |
||
1344 | 7276 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7277 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7278 |
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
|
7279 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7280 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7281 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7282 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7283 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7284 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7285 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7286 |
|
1344 | 7287 |
altModifierMask:aSmallInteger |
341 | 7288 |
"define which key takes the role of an alt-key. |
7289 |
By default, this is X's modifier1, which is the ALT key on |
|
7290 |
most keyboards. However, there may be exceptions to this, |
|
7291 |
and the setting can be changed with: |
|
1344 | 7292 |
Display altModifierMask:(Display modifier2Mask) |
341 | 7293 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
7294 |
" |
|
7295 |
||
7296 |
altModifierMask := aSmallInteger |
|
7297 |
! |
|
7298 |
||
1344 | 7299 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7300 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7301 |
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
|
7302 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7303 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7304 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7305 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7306 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7307 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7308 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7309 |
|
1344 | 7310 |
metaModifierMask:aSmallInteger |
341 | 7311 |
"define which key takes the role of a meta key. |
7312 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
7313 |
most keyboards (if present at all). |
|
7314 |
However, there may be exceptions to this, and the setting can |
|
7315 |
be changed with: |
|
1344 | 7316 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 7317 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
7318 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
7319 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
7320 |
all the time. On those, you should disable the meta key by setting |
|
7321 |
the mask to 0. |
|
7322 |
" |
|
7323 |
||
7324 |
metaModifierMask := aSmallInteger |
|
7325 |
! |
|
7326 |
||
1344 | 7327 |
modifier1Mask |
341 | 7328 |
"return the Xlib mask bit for the 1st modifier key. |
7329 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7330 |
this could be used." |
|
7331 |
||
7332 |
%{ /* NOCONTEXT */ |
|
7333 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
7334 |
%} |
|
7335 |
! |
|
7336 |
||
1344 | 7337 |
modifier2Mask |
341 | 7338 |
"return the Xlib mask bit for the 2nd modifier key. |
7339 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7340 |
this could be used." |
|
7341 |
||
7342 |
%{ /* NOCONTEXT */ |
|
7343 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
7344 |
%} |
|
7345 |
! |
|
7346 |
||
1344 | 7347 |
modifierMapping |
341 | 7348 |
"Get the Modifier Mapping. |
7349 |
We return an array of arrays of keycodes" |
|
7350 |
||
7351 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
7352 |
||
7353 |
%{ |
|
7354 |
XModifierKeymap *modmap; |
|
7355 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
7356 |
||
7357 |
if (ISCONNECTED) { |
|
1344 | 7358 |
Display *dpy = myDpy; |
7359 |
||
7360 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
7361 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7362 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
7363 |
if (modifierKeyMap != nil) { |
|
7364 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7365 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
7366 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
7367 |
} |
|
7368 |
XFreeModifiermap(modmap); |
|
7369 |
} |
|
341 | 7370 |
} |
7371 |
%}. |
|
7372 |
||
7373 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
7374 |
||
7375 |
ret := Array new:8. |
|
7376 |
nextKey := 1. |
|
7377 |
1 to:8 do:[ :i | |
|
1344 | 7378 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
7379 |
|mod| |
|
7380 |
||
7381 |
mod := OrderedCollection new:maxKeyPerMod. |
|
7382 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
7383 |
key ~= 0 ifTrue:[ |
|
7384 |
mod add:key |
|
7385 |
]. |
|
7386 |
]. |
|
7387 |
ret at:i put:mod. |
|
7388 |
]. |
|
7389 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 7390 |
]. |
7391 |
||
7392 |
^ ret |
|
7393 |
||
7394 |
" |
|
1344 | 7395 |
Display modifierMapping |
341 | 7396 |
" |
7397 |
! |
|
7398 |
||
1344 | 7399 |
stringFromKeycode:code |
341 | 7400 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
7401 |
||
7402 |
|str| |
|
7403 |
||
7404 |
%{ |
|
7405 |
KeySym keysym; |
|
7406 |
char *keystring; |
|
7407 |
||
7408 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 7409 |
Display *dpy = myDpy; |
7410 |
||
7411 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
7412 |
(keystring = XKeysymToString(keysym)) != 0) |
|
7413 |
str = __MKSTRING(keystring); |
|
341 | 7414 |
} |
7415 |
%}. |
|
7416 |
^ str |
|
7417 |
||
7418 |
" |
|
1344 | 7419 |
Display stringFromKeycode:28 |
341 | 7420 |
" |
7421 |
! |
|
7422 |
||
1344 | 7423 |
translateKey:untranslatedKey |
295 | 7424 |
"Return the key translated via the translation table. |
7425 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
7426 |
which gets further processed in the superclasses translation method." |
|
7427 |
||
7428 |
|key| |
|
7429 |
||
7430 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 7431 |
key := RawKeysymTranslation at:key ifAbsent:key. |
7432 |
key := key asSymbol. |
|
295 | 7433 |
]. |
7434 |
^ super translateKey:key |
|
7435 |
! ! |
|
7436 |
||
7437 |
!XWorkstation methodsFor:'misc'! |
|
7438 |
||
1344 | 7439 |
beep |
295 | 7440 |
"output an audible beep or bell" |
7441 |
||
7442 |
self beep:50 |
|
7443 |
! |
|
7444 |
||
1344 | 7445 |
beep:volumeInPercent |
295 | 7446 |
"output an audible beep" |
7447 |
%{ |
|
7448 |
int volume; |
|
7449 |
||
7450 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 7451 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
7452 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
7453 |
if (volume < -100) volume = -100; |
|
7454 |
else if (volume > 100) volume = 100; |
|
7455 |
BEGIN_INTERRUPTSBLOCKED |
|
7456 |
XBell(myDpy, volume); |
|
7457 |
END_INTERRUPTSBLOCKED |
|
295 | 7458 |
} |
7459 |
%} |
|
7460 |
! |
|
7461 |
||
1344 | 7462 |
buffered |
295 | 7463 |
"buffer drawing - do not send it immediately to the display. |
374 | 7464 |
This is the default anyway. |
7465 |
See #unBuffered for additional info." |
|
295 | 7466 |
|
7467 |
%{ /* NOCONTEXT */ |
|
7468 |
||
7469 |
if (ISCONNECTED) { |
|
1344 | 7470 |
BEGIN_INTERRUPTSBLOCKED |
7471 |
XSynchronize(myDpy, 0); |
|
7472 |
END_INTERRUPTSBLOCKED |
|
295 | 7473 |
} |
7474 |
%} |
|
374 | 7475 |
" |
7476 |
Display buffered |
|
7477 |
" |
|
295 | 7478 |
! |
7479 |
||
1344 | 7480 |
flush |
295 | 7481 |
"send all buffered drawing to the display. |
7482 |
This may be required to make certain, that all previous operations |
|
7483 |
are really sent to the display before continuing. For example, |
|
7484 |
after a cursor-change with a followup long computation. |
|
374 | 7485 |
(otherwise, the cursor change request may still be in the output buffer) |
7486 |
See also #sync, which even waits until the request has been processed." |
|
295 | 7487 |
|
7488 |
%{ /* NOCONTEXT */ |
|
7489 |
||
7490 |
if (ISCONNECTED) { |
|
1344 | 7491 |
BEGIN_INTERRUPTSBLOCKED |
7492 |
XFlush(myDpy); |
|
7493 |
END_INTERRUPTSBLOCKED |
|
310 | 7494 |
} |
7495 |
%} |
|
7496 |
! |
|
7497 |
||
1344 | 7498 |
flushDpsContext:aDPSContext |
295 | 7499 |
|
7500 |
%{ /* NOCONTEXT */ |
|
7501 |
#ifdef DPS |
|
7502 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 7503 |
BEGIN_INTERRUPTSBLOCKED |
7504 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
7505 |
END_INTERRUPTSBLOCKED |
|
7506 |
RETURN ( self ); |
|
295 | 7507 |
} |
7508 |
#endif |
|
374 | 7509 |
%}. |
295 | 7510 |
self primitiveFailed |
7511 |
! |
|
7512 |
||
1344 | 7513 |
refreshKeyboardMapping:eB |
295 | 7514 |
%{ |
7515 |
XMappingEvent *ev; |
|
7516 |
||
7517 |
if (__isByteArray(eB)) { |
|
1344 | 7518 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
7519 |
XRefreshKeyboardMapping(ev); |
|
295 | 7520 |
} |
7521 |
%} |
|
7522 |
! |
|
7523 |
||
1344 | 7524 |
setInputFocusTo:aWindowId |
295 | 7525 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
7526 |
self setInputFocusTo:aWindowId revertTo:#root |
|
7527 |
! |
|
7528 |
||
1344 | 7529 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 7530 |
"set the focus to the view as defined by aWindowId. |
7531 |
Passing nil set the focus to no window and lets the display discard all |
|
7532 |
input until a new focus is set. |
|
7533 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
7534 |
passing one of #parent, #root or nil specifies that the focus should be |
|
7535 |
given to the parent view, the root view or no view." |
|
7536 |
||
7537 |
%{ /* NOCONTEXT */ |
|
7538 |
int arg; |
|
7539 |
Window focusWindow; |
|
7540 |
||
7541 |
if (ISCONNECTED) { |
|
1344 | 7542 |
if (__isExternalAddress(aWindowId)) { |
7543 |
focusWindow = _WindowVal(aWindowId); |
|
7544 |
} else { |
|
7545 |
focusWindow = None; |
|
7546 |
} |
|
7547 |
if (revertSymbol == @symbol(parent)) |
|
7548 |
arg = RevertToParent; |
|
7549 |
else if (revertSymbol == @symbol(root)) |
|
7550 |
arg = RevertToPointerRoot; |
|
7551 |
else |
|
7552 |
arg = RevertToNone; |
|
7553 |
||
7554 |
BEGIN_INTERRUPTSBLOCKED |
|
7555 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
7556 |
END_INTERRUPTSBLOCKED |
|
7557 |
RETURN ( self ); |
|
295 | 7558 |
} |
7559 |
%}. |
|
7560 |
self primitiveFailed |
|
7561 |
! |
|
7562 |
||
1344 | 7563 |
sync |
341 | 7564 |
"send all buffered drawing to the display AND wait until the display |
7565 |
has finished drawing it. |
|
7566 |
This is almost never needed, except if you are about to read previously |
|
374 | 7567 |
drawn pixels back from the display screen, or you want to wait for a beep |
7568 |
to be finished. See also #flush." |
|
341 | 7569 |
|
7570 |
%{ /* NOCONTEXT */ |
|
7571 |
||
7572 |
if (ISCONNECTED) { |
|
1344 | 7573 |
BEGIN_INTERRUPTSBLOCKED |
7574 |
XSync(myDpy, 0); |
|
7575 |
END_INTERRUPTSBLOCKED |
|
341 | 7576 |
} |
7577 |
%} |
|
7578 |
! |
|
7579 |
||
1344 | 7580 |
unBuffered |
374 | 7581 |
"make all drawing be sent immediately to the display. |
7582 |
This makes all graphics synchronous and turns off any buffering |
|
7583 |
(i.e. each individual draw-request is sent immediately without |
|
7584 |
packing multiple requests into a larger message buffer). |
|
7585 |
Be prepared, that this slows down graphics considerably. |
|
7586 |
However, it allows display errors to be handled immediately and |
|
7587 |
may be useful if you get Xdisplay errors and want to find the request |
|
1813 | 7588 |
which was responsible for it. See also #buffered." |
295 | 7589 |
|
7590 |
%{ /* NOCONTEXT */ |
|
7591 |
||
7592 |
if (ISCONNECTED) { |
|
1344 | 7593 |
BEGIN_INTERRUPTSBLOCKED |
7594 |
XSynchronize(myDpy, 1); |
|
7595 |
END_INTERRUPTSBLOCKED |
|
295 | 7596 |
} |
7597 |
%} |
|
1813 | 7598 |
" |
7599 |
Display unBuffered |
|
7600 |
" |
|
295 | 7601 |
! ! |
7602 |
||
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7603 |
!XWorkstation methodsFor:'pointer stuff'! |
295 | 7604 |
|
1344 | 7605 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7606 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7607 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7608 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7609 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7610 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7611 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7612 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7613 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7614 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7615 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7616 |
|
1344 | 7617 |
buttonStates |
295 | 7618 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7619 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7620 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7621 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 7622 |
|
7623 |
%{ /* NOCONTEXT*/ |
|
7624 |
Window w; |
|
555 | 7625 |
int screen = __intVal(__INST(screen)); |
295 | 7626 |
Window rootRet, childRet; |
7627 |
int rootX, rootY, winX, winY; |
|
7628 |
unsigned int mask; |
|
7629 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7630 |
if (ISCONNECTED) { |
1344 | 7631 |
Display *dpy = myDpy; |
7632 |
||
7633 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7634 |
#ifdef VIRTUAL_ROOT |
1344 | 7635 |
w = getRootWindow(myDpy, screen); |
295 | 7636 |
#else |
1344 | 7637 |
w = RootWindow(dpy, screen); |
295 | 7638 |
#endif |
1344 | 7639 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7640 |
&rootX, &rootY, |
|
7641 |
&winX, &winY, |
|
7642 |
&mask); |
|
7643 |
END_INTERRUPTSBLOCKED |
|
7644 |
RETURN (__MKSMALLINT(mask)); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7645 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7646 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7647 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7648 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7649 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7650 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7651 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7652 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7653 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7654 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7655 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7656 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7657 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7658 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7659 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7660 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7661 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7662 |
" |
295 | 7663 |
! |
7664 |
||
1344 | 7665 |
leftButtonStateMask |
295 | 7666 |
"return an integer for masking out the left button from a |
7667 |
buttonStates value" |
|
7668 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7669 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7670 |
|
295 | 7671 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7672 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7673 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 7674 |
! |
7675 |
||
1344 | 7676 |
middleButtonStateMask |
295 | 7677 |
"return an integer for masking out the middle button from a |
7678 |
buttonStates value" |
|
7679 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7680 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7681 |
|
295 | 7682 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7683 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7684 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 7685 |
! |
7686 |
||
1344 | 7687 |
pointerPosition |
295 | 7688 |
"return the current pointer position in root-window coordinates" |
7689 |
||
7690 |
|xpos ypos| |
|
7691 |
||
7692 |
%{ |
|
7693 |
Window w; |
|
555 | 7694 |
int screen = __intVal(__INST(screen)); |
295 | 7695 |
Window rootRet, childRet; |
7696 |
int rootX, rootY, winX, winY; |
|
7697 |
unsigned int mask; |
|
7698 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7699 |
if (ISCONNECTED) { |
1344 | 7700 |
Display *dpy = myDpy; |
7701 |
||
7702 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7703 |
#ifdef VIRTUAL_ROOT |
1344 | 7704 |
w = getRootWindow(myDpy, screen); |
295 | 7705 |
#else |
1344 | 7706 |
w = RootWindow(dpy, screen); |
295 | 7707 |
#endif |
1344 | 7708 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7709 |
&rootX, &rootY, |
|
7710 |
&winX, &winY, |
|
7711 |
&mask); |
|
7712 |
xpos = __MKSMALLINT(rootX); |
|
7713 |
ypos = __MKSMALLINT(rootY); |
|
7714 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7715 |
} |
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7716 |
%}. |
295 | 7717 |
^ xpos @ ypos |
7718 |
! |
|
7719 |
||
1344 | 7720 |
rightButtonStateMask |
295 | 7721 |
"return an integer for masking out the right button from a |
7722 |
buttonStates value" |
|
7723 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7724 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7725 |
|
295 | 7726 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7727 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7728 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 7729 |
! |
7730 |
||
1344 | 7731 |
rootPositionOfLastEvent |
295 | 7732 |
"return the position in root-window coordinates |
7733 |
of the last button, key or pointer event" |
|
7734 |
||
7735 |
^ eventRootX @ eventRootY |
|
1718
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7736 |
! |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7737 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7738 |
setPointerPosition:newPosition in:aWindowId |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7739 |
"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
|
7740 |
given windows origin (which may be the rootWindow). |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7741 |
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
|
7742 |
to change the mousePointer position. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7743 |
This interface is provided for special applications (presentation |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7744 |
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
|
7745 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7746 |
|xpos ypos| |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7747 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7748 |
xpos := newPosition x. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7749 |
ypos := newPosition y. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7750 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7751 |
%{ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7752 |
if (ISCONNECTED |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7753 |
&& __isExternalAddress(aWindowId) |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7754 |
&& __bothSmallInteger(xpos, ypos)) { |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7755 |
Display *dpy = myDpy; |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7756 |
Window w = _WindowVal(aWindowId); |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7757 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7758 |
XWarpPointer(dpy, |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7759 |
None, /* src window */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7760 |
w, /* dst window */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7761 |
0, /* src_x */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7762 |
0, /* src_y */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7763 |
0, /* src_w */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7764 |
0, /* src_h */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7765 |
__intVal(xpos), /* dst_x */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7766 |
__intVal(ypos) /* dst_y */ |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7767 |
); |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7768 |
} |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7769 |
%}. |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7770 |
^ self |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7771 |
|
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7772 |
" |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7773 |
Display setPointerPosition:1000@1000 |
886b895eb2f3
added setPointerPosition: for recorder/playback support
Claus Gittinger <cg@exept.de>
parents:
1709
diff
changeset
|
7774 |
" |
295 | 7775 |
! ! |
7776 |
||
1556 | 7777 |
!XWorkstation methodsFor:'properties'! |
7778 |
||
7779 |
getObjectProperty:propertyID from:aWindowID |
|
7780 |
"get an object property from the server; return object or nil" |
|
7781 |
||
7782 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7783 |
type == stringAtom ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7784 |
^ value |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7785 |
]. |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7786 |
(value isMemberOf:ByteArray) ifTrue:[ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7787 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7788 |
] |
1556 | 7789 |
]. |
7790 |
^ nil |
|
7791 |
||
7792 |
"Modified: 6.4.1997 / 13:27:07 / cg" |
|
7793 |
! |
|
7794 |
||
7795 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7796 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7797 |
||
7798 |
|val typeID cls| |
|
7799 |
||
7800 |
cls := ByteArray. |
|
7801 |
%{ |
|
7802 |
Window window; |
|
7803 |
Atom property; |
|
7804 |
char *cp, *cp2; |
|
7805 |
Atom actual_type; |
|
7806 |
int actual_format,i; |
|
7807 |
unsigned long nitems, bytes_after, nread; |
|
7808 |
unsigned char *data; |
|
7809 |
int ok = 1; |
|
7810 |
# define PROP_SIZE 2048 |
|
7811 |
||
7812 |
if (ISCONNECTED) { |
|
7813 |
Display *dpy = myDpy; |
|
7814 |
||
7815 |
if (__isAtomID(propertyID)) { |
|
7816 |
property = _AtomVal(propertyID); |
|
7817 |
if (__isExternalAddress(aWindowID)) { |
|
7818 |
window = _WindowVal(aWindowID); |
|
7819 |
} else { |
|
7820 |
window = DefaultRootWindow(dpy); |
|
7821 |
} |
|
7822 |
||
7823 |
nread = 0; |
|
7824 |
cp = 0; |
|
7825 |
/* |
|
7826 |
fprintf(stderr, "getProperty: "); |
|
7827 |
*/ |
|
7828 |
do { |
|
7829 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7830 |
AnyPropertyType,&actual_type,&actual_format, |
|
7831 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7832 |
!= Success) { |
|
7833 |
ok = 0; |
|
7834 |
break; |
|
7835 |
} |
|
7836 |
typeID = __MKATOMOBJ(actual_type); |
|
7837 |
if (! cp) { |
|
7838 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7839 |
} else { |
|
7840 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7841 |
cp2 = cp + nread; |
|
7842 |
} |
|
7843 |
if (! cp) { |
|
7844 |
XFree(data); |
|
7845 |
goto fail; |
|
7846 |
} |
|
7847 |
||
7848 |
nread += nitems; |
|
7849 |
bcopy(data, cp2, nitems); |
|
7850 |
XFree(data); |
|
7851 |
/* |
|
7852 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7853 |
*/ |
|
7854 |
} while (bytes_after > 0); |
|
7855 |
/* |
|
7856 |
fprintf(stderr, "\n"); |
|
7857 |
*/ |
|
7858 |
||
7859 |
if (ok) { |
|
7860 |
if (actual_type == XA_STRING) { |
|
7861 |
cp[nread] = '\0'; |
|
7862 |
val = __MKSTRING_L(cp, nread); |
|
7863 |
} else { |
|
7864 |
val = __new(nread + OHDR_SIZE); |
|
7865 |
val->o_class = cls; |
|
7866 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
7867 |
} |
|
7868 |
} |
|
7869 |
if (cp) |
|
7870 |
free(cp); |
|
7871 |
} |
|
7872 |
} |
|
7873 |
fail: ; |
|
7874 |
%}. |
|
7875 |
typeID isNil ifTrue:[ |
|
7876 |
^ false |
|
7877 |
]. |
|
7878 |
aTwoArgBlock value:typeID value:val. |
|
7879 |
^ true |
|
7880 |
! |
|
7881 |
||
7882 |
getTextProperty:propertyID from:aWindowID |
|
7883 |
"get a text property; return string or nil" |
|
7884 |
||
1798 | 7885 |
|stringClass| |
7886 |
||
1556 | 7887 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
1793 | 7888 |
type == stringAtom ifTrue:[ |
7889 |
clipBoardEncoding notNil ifTrue:[ |
|
1798 | 7890 |
stringClass := (CharacterArray classForEncoding:clipBoardEncoding). |
7891 |
stringClass ~~ String ifTrue:[ |
|
7892 |
^ stringClass fromBytes:(value asByteArray) |
|
7893 |
]. |
|
1793 | 7894 |
^ value decodeFrom:clipBoardEncoding |
7895 |
]. |
|
7896 |
^ value |
|
7897 |
] |
|
1556 | 7898 |
]. |
7899 |
^ nil |
|
1793 | 7900 |
|
1798 | 7901 |
"Modified: 30.6.1997 / 20:54:59 / cg" |
1556 | 7902 |
! |
7903 |
||
7904 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7905 |
"set a size property" |
|
7906 |
||
7907 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7908 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7909 |
type:(self atomIDOfLENGTH) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7910 |
value:aNumber |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7911 |
for:aWindowID |
1556 | 7912 |
|
7913 |
"Modified: 6.4.1997 / 13:27:26 / cg" |
|
7914 |
! |
|
7915 |
||
7916 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7917 |
"set a property to a smalltalk object in the XServer. |
|
7918 |
Can only be retrieved by another ST/X smalltalk" |
|
7919 |
||
7920 |
|s| |
|
7921 |
||
7922 |
(anObject isMemberOf:String) ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7923 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
1556 | 7924 |
]. |
7925 |
s := WriteStream on:(ByteArray new:200). |
|
7926 |
anObject storeBinaryOn:s. |
|
7927 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7928 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7929 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7930 |
value:(s contents) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7931 |
for:aWindowID |
1556 | 7932 |
|
7933 |
"Modified: 6.4.1997 / 13:27:57 / cg" |
|
7934 |
! |
|
7935 |
||
7936 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7937 |
"set a property in the XServer" |
|
7938 |
||
7939 |
%{ /* UNLIMITEDSTACK */ |
|
7940 |
||
7941 |
Atom prop, type; |
|
7942 |
Window window; |
|
7943 |
unsigned int value; |
|
7944 |
||
7945 |
if (__isAtomID(propertyID) |
|
7946 |
&& __isAtomID(typeID) |
|
7947 |
&& ISCONNECTED |
|
7948 |
&& (__isString(anObject) |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7949 |
|| __isSmallInteger(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7950 |
|| __isSymbol(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7951 |
|| __isByteArray(anObject) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7952 |
|| __isWords(anObject))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7953 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7954 |
Display *dpy = myDpy; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7955 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7956 |
prop = _AtomVal(propertyID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7957 |
type = _AtomVal(typeID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7958 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7959 |
if (__isExternalAddress(aWindowID)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7960 |
window = _WindowVal(aWindowID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7961 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7962 |
window = DefaultRootWindow(dpy); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7963 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7964 |
if (__isSmallInteger(anObject)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7965 |
value = __intVal(anObject); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7966 |
XChangeProperty(dpy, window, prop, type, 32, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7967 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7968 |
(unsigned char *)(&value), sizeof(unsigned int)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7969 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7970 |
if (__isByteArray(anObject)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7971 |
XChangeProperty(dpy, window, prop, type, 8, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7972 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7973 |
__ByteArrayInstPtr(anObject)->ba_element, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7974 |
__byteArraySize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7975 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7976 |
/* string or symbol or wordArray-like (16bit-string) object */ |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7977 |
type = _AtomVal(typeID); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7978 |
if (__isWords(__qClass(anObject))) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7979 |
XChangeProperty(dpy, window, prop, type, 16, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7980 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7981 |
__stringVal(anObject), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7982 |
__wordArraySize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7983 |
} else { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7984 |
XChangeProperty(dpy, window, prop, type, 8, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7985 |
PropModeReplace, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7986 |
__stringVal(anObject), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7987 |
__stringSize(anObject)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7988 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7989 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7990 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
7991 |
RETURN (true); |
1556 | 7992 |
} |
7993 |
%}. |
|
7994 |
^ false |
|
7995 |
! |
|
7996 |
||
7997 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7998 |
"set a property to a stringValue in the XServer" |
|
7999 |
||
8000 |
^ self |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8001 |
setProperty:propertyID |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8002 |
type:(self atomIDOfSTRING) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8003 |
value:aString |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
8004 |
for:aWindowID |
1556 | 8005 |
|
8006 |
"Modified: 6.4.1997 / 13:26:32 / cg" |
|
8007 |
! ! |
|
8008 |
||
295 | 8009 |
!XWorkstation methodsFor:'resources'! |
8010 |
||
1344 | 8011 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8012 |
"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
|
8013 |
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
|
8014 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8015 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8016 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8017 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8018 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8019 |
Display atomIDOf:'FULL_NAME' |
1535 | 8020 |
Display atomIDOf:'DndProtocol' |
8021 |
Display atomIDOf:'DndSelection' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8022 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8023 |
|
1535 | 8024 |
"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
|
8025 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8026 |
|
1344 | 8027 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8028 |
"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
|
8029 |
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
|
8030 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8031 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8032 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8033 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8034 |
if (ISCONNECTED) { |
1344 | 8035 |
if (__isString(aStringOrSymbol) |
8036 |
|| __isSymbol(aStringOrSymbol)) { |
|
8037 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
8038 |
(create == true) ? False : True); |
|
8039 |
if (prop == None) { |
|
8040 |
RETURN (nil); |
|
8041 |
} |
|
8042 |
RETURN ( __MKATOMOBJ(prop) ); |
|
8043 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8044 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8045 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8046 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8047 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8048 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8049 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8050 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8051 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8052 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8053 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8054 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8055 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8056 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8057 |
|
1344 | 8058 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8059 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8060 |
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
|
8061 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8062 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8063 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8064 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8065 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8066 |
|
1344 | 8067 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8068 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8069 |
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
|
8070 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8071 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8072 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8073 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8074 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8075 |
|
1344 | 8076 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8077 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8078 |
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
|
8079 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8080 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8081 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8082 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8083 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8084 |
|
1344 | 8085 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8086 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8087 |
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
|
8088 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8089 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8090 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8091 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8092 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8093 |
|
1344 | 8094 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8095 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8096 |
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
|
8097 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8098 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8099 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8100 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8101 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8102 |
|
1344 | 8103 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8104 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8105 |
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
|
8106 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8107 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8108 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8109 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8110 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8111 |
if (ISCONNECTED) { |
1344 | 8112 |
if (__isAtomID(anAtomID)) { |
8113 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
8114 |
if (name == 0) { |
|
8115 |
RETURN (nil); |
|
8116 |
} |
|
8117 |
str = __MKSTRING(name); |
|
8118 |
XFree(name); |
|
8119 |
RETURN ( str ); |
|
8120 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8121 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8122 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8123 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8124 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8125 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8126 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8127 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8128 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8129 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8130 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8131 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8132 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8133 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8134 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8135 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8136 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8137 |
|
1344 | 8138 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8139 |
"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
|
8140 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8141 |
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
|
8142 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8143 |
Notice: |
1344 | 8144 |
we do not plan to use X's resources for ST/X's defaults, |
8145 |
styles or resources. This would make porting of applications |
|
8146 |
to different platforms much more difficult (Windows has no resource |
|
8147 |
database). If you stay within ST/X's resource files, these can be |
|
8148 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8149 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8150 |
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
|
8151 |
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
|
8152 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8153 |
|
295 | 8154 |
%{ |
8155 |
char *rslt; |
|
8156 |
||
8157 |
if ((__isString(name) || __isSymbol(name)) |
|
8158 |
&& (__isString(cls) || __isSymbol(cls)) |
|
8159 |
&& ISCONNECTED) { |
|
1344 | 8160 |
BEGIN_INTERRUPTSBLOCKED |
8161 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
8162 |
(char *)_stringVal(name)); |
|
8163 |
END_INTERRUPTSBLOCKED |
|
8164 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8165 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8166 |
%}. |
295 | 8167 |
self primitiveFailed. |
8168 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8169 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8170 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 8171 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8172 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8173 |
|
1344 | 8174 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8175 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8176 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 8177 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8178 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8179 |
|
1344 | 8180 |
Display getResource:'beNiceToColormap' class:'any' |
8181 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8182 |
" |
295 | 8183 |
! ! |
8184 |
||
8185 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
8186 |
||
1462
f8b2909deb3c
renamed getBitsFrom to getBitsFromId
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
8187 |
getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 8188 |
"get bits from a drawable into the imageBits. The storage for the bits |
8189 |
must be big enough for the data to fit. If ok, returns an array with some |
|
8190 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
8191 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
8192 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
8193 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8194 |
|rawInfo info| |
295 | 8195 |
|
8196 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 8197 |
self primitiveFailed. |
8198 |
^ nil |
|
295 | 8199 |
]. |
8200 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8201 |
rawInfo := Array new:8. |
1344 | 8202 |
"1 -> bit order" |
8203 |
"2 -> depth" |
|
8204 |
"3 -> bytes_per_line" |
|
8205 |
"4 -> byte_order" |
|
8206 |
"5 -> format" |
|
8207 |
"6 -> bitmap_unit" |
|
8208 |
"7 -> bitmap_pad" |
|
8209 |
"8 -> bits_per_pixel" |
|
295 | 8210 |
|
8211 |
"/ had to extract the getPixel call into a separate method, to specify |
|
8212 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
8213 |
"/ of temporary stack space |
|
8214 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8215 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 8216 |
info := IdentityDictionary new. |
8217 |
info at:#bitOrder put:(rawInfo at:1). |
|
8218 |
info at:#depth put:(rawInfo at:2). |
|
8219 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
8220 |
info at:#byteOrder put:(rawInfo at:4). |
|
8221 |
info at:#format put:(rawInfo at:5). |
|
8222 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
8223 |
info at:#bitmapPad put:(rawInfo at:7). |
|
8224 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
8225 |
^ info |
|
295 | 8226 |
]. |
8227 |
" |
|
8228 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
8229 |
or is too small to hold the bits |
|
8230 |
" |
|
8231 |
^ self primitiveFailed |
|
8232 |
! |
|
8233 |
||
1344 | 8234 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
8235 |
"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
|
8236 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 8237 |
|
8238 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
8239 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8240 |
Window win; |
295 | 8241 |
XImage *img; |
8242 |
int ret; |
|
8243 |
int xpos, ypos; |
|
8244 |
||
1209 | 8245 |
if (ISCONNECTED |
8246 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 8247 |
win = _WindowVal(aDrawableId); |
8248 |
xpos = __intVal(x); |
|
8249 |
ypos = __intVal(y); |
|
8250 |
if ((xpos < 0) || (ypos < 0)) { |
|
8251 |
RETURN ( __MKSMALLINT(0) ); |
|
8252 |
} |
|
8253 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
8254 |
if (img != 0) { |
|
8255 |
ret = XGetPixel(img, 0, 0); |
|
8256 |
XDestroyImage(img); |
|
8257 |
RETURN ( __MKSMALLINT(ret) ); |
|
8258 |
} |
|
295 | 8259 |
} |
8260 |
%}. |
|
8261 |
^ nil |
|
8262 |
! |
|
8263 |
||
1344 | 8264 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 8265 |
"since XGetImage may allocate huge amount of stack space |
8266 |
(some implementations use alloca), this must run with unlimited stack." |
|
8267 |
||
8268 |
%{ /* UNLIMITEDSTACK */ |
|
8269 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8270 |
Window win; |
295 | 8271 |
XImage *image = (XImage *)0; |
8272 |
int pad, bytes_per_line, numBytes; |
|
8273 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8274 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8275 |
&& __isExternalAddress(aDrawableId) |
295 | 8276 |
&& __bothSmallInteger(srcx, srcy) |
8277 |
&& __bothSmallInteger(w, h) |
|
8278 |
&& __isArray(info) |
|
8279 |
&& __isByteArray(imageBits)) { |
|
1344 | 8280 |
Display *dpy = myDpy; |
8281 |
||
8282 |
win = _WindowVal(aDrawableId); |
|
8283 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
|
8284 |
__intVal(w), __intVal(h), |
|
8285 |
(unsigned)AllPlanes, ZPixmap); |
|
8286 |
||
8287 |
if (! image) { |
|
8288 |
RETURN ( false ); |
|
8289 |
} |
|
8290 |
||
8291 |
pad = image->bitmap_pad; |
|
295 | 8292 |
#ifdef SUPERDEBUG |
1344 | 8293 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 8294 |
#endif |
1344 | 8295 |
switch (image->depth) { |
8296 |
case 1: |
|
8297 |
case 2: |
|
8298 |
case 4: |
|
8299 |
case 8: |
|
8300 |
case 16: |
|
8301 |
case 24: |
|
8302 |
case 32: |
|
8303 |
numBytes = image->bytes_per_line * image->height; |
|
8304 |
break; |
|
1728 | 8305 |
|
1344 | 8306 |
default: |
8307 |
/* unsupported depth ? */ |
|
8308 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
8309 |
numBytes = image->bytes_per_line * image->height; |
|
8310 |
break; |
|
8311 |
} |
|
295 | 8312 |
|
8313 |
#ifdef SUPERDEBUG |
|
1344 | 8314 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 8315 |
#endif |
8316 |
||
1344 | 8317 |
if (numBytes > __byteArraySize(imageBits)) { |
8318 |
/* imageBits too small */ |
|
1728 | 8319 |
fprintf(stderr, "Workstation [warning]: byteArray too small in primGetBits\n"); |
8320 |
fprintf(stderr, " bytes need:%d given:%d\n", numBytes, __byteArraySize(imageBits)); |
|
8321 |
fprintf(stderr, " pad:%d depth:%d imgBytesPerLine:%d\n", |
|
8322 |
image->bitmap_pad, image->depth, image->bytes_per_line); |
|
1344 | 8323 |
goto fail; |
8324 |
} |
|
8325 |
if (image->bitmap_bit_order == MSBFirst) |
|
8326 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
8327 |
else |
|
8328 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
8329 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
8330 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
8331 |
if (image->byte_order == MSBFirst) |
|
8332 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
8333 |
else |
|
8334 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
8335 |
if (image->format == XYBitmap) |
|
8336 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
8337 |
else if (image->format == XYPixmap) |
|
8338 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
8339 |
else if (image->format == ZPixmap) |
|
8340 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
8341 |
|
1344 | 8342 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
8343 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
8344 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
8345 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
8346 |
XDestroyImage(image); |
|
8347 |
RETURN ( true ); |
|
295 | 8348 |
} |
8349 |
fail: |
|
8350 |
if (image) { |
|
1344 | 8351 |
XDestroyImage(image); |
295 | 8352 |
} |
8353 |
%}. |
|
8354 |
^ false |
|
8355 |
! ! |
|
8356 |
||
8357 |
!XWorkstation methodsFor:'selections'! |
|
8358 |
||
1344 | 8359 |
getSelectionFor:drawableId |
295 | 8360 |
"get the object selection - either immediate, or asynchronous. |
8361 |
Returns nil, if async request is on its way" |
|
8362 |
||
8363 |
|selProp sel| |
|
8364 |
||
8365 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8366 |
"no primary selection - use cut buffer" |
8367 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
8368 |
^ sel |
|
295 | 8369 |
]. |
8370 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
8371 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
8372 |
^ nil |
|
8373 |
! |
|
8374 |
||
1344 | 8375 |
getSelectionOwnerOf:selectionAtomID |
295 | 8376 |
"get the owner of a selection" |
8377 |
||
8378 |
%{ /* NOCONTEXT */ |
|
8379 |
Atom selection; |
|
8380 |
Window window; |
|
8381 |
||
8382 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 8383 |
Display *dpy = myDpy; |
8384 |
||
8385 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
8386 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
295 | 8387 |
} |
8388 |
%}. |
|
8389 |
self primitiveFailed. |
|
8390 |
^ nil |
|
8391 |
! |
|
8392 |
||
1344 | 8393 |
getTextSelectionFor:drawableId |
295 | 8394 |
"get the text selection - either immediate, or asynchronous. |
8395 |
Returns nil, if async request is on its way" |
|
8396 |
||
8397 |
|selProp sel| |
|
8398 |
||
8399 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8400 |
"no primary selection - use cut buffer" |
8401 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
8402 |
^ sel |
|
295 | 8403 |
]. |
8404 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
8405 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
8406 |
^ nil |
|
8407 |
! |
|
8408 |
||
1344 | 8409 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 8410 |
"ask the server to send us the selection - the view with ID aWindowID |
8411 |
will later receive a SelectionNotify event for it." |
|
8412 |
||
8413 |
^ self requestSelection:selectionID |
|
1344 | 8414 |
property:propertyID |
8415 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
8416 |
for:aWindowId |
|
8417 |
! |
|
8418 |
||
8419 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 8420 |
"ask the server to send us the selection - the view with id aWindowID |
8421 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
8422 |
with the selections value)." |
|
8423 |
||
8424 |
%{ /* NOCONTEXT */ |
|
8425 |
Atom sel_prop; |
|
8426 |
char *cp; |
|
8427 |
||
8428 |
if (__isExternalAddress(aWindowId) |
|
8429 |
&& ISCONNECTED |
|
8430 |
&& __isSmallInteger(typeID) |
|
8431 |
&& __isAtomID(selectionID)) { |
|
1344 | 8432 |
Display *dpy = myDpy; |
8433 |
||
8434 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
8435 |
/* |
|
8436 |
* no owner of primary selection |
|
8437 |
*/ |
|
8438 |
RETURN (false); |
|
8439 |
} |
|
8440 |
/* |
|
8441 |
* PRIMARY selection |
|
8442 |
*/ |
|
8443 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
8444 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
8445 |
RETURN (true); |
|
295 | 8446 |
} |
8447 |
%}. |
|
8448 |
self primitiveFailed. |
|
8449 |
^ false |
|
8450 |
||
8451 |
" |
|
8452 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 8453 |
property:(Display atomIDOf:'VT_SELECTION') |
8454 |
for:0 |
|
295 | 8455 |
" |
8456 |
! |
|
8457 |
||
1344 | 8458 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 8459 |
"ask the server to send us the selection - the view with ID aWindowID |
8460 |
will later receive a SelectionNotify event for it." |
|
8461 |
||
8462 |
^ self requestSelection:selectionID |
|
1344 | 8463 |
property:propertyID |
8464 |
type:stringAtom |
|
8465 |
for:aWindowId |
|
8466 |
! |
|
8467 |
||
8468 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8469 |
"send aString back from a SelectionRequest" |
8470 |
||
8471 |
self |
|
1344 | 8472 |
sendSelection:something |
8473 |
selection:primaryAtom |
|
8474 |
property:propertyID |
|
8475 |
target:targetID |
|
8476 |
from:windowID |
|
8477 |
to:requestorID |
|
8478 |
! |
|
8479 |
||
8480 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8481 |
"send aString back from a SelectionRequest" |
8482 |
||
8483 |
self |
|
1344 | 8484 |
setProperty:propertyID |
8485 |
type:targetID |
|
8486 |
value:something |
|
8487 |
for:requestorID. |
|
295 | 8488 |
self |
1344 | 8489 |
sendSelectionNotifySelection:selectionID |
8490 |
property:propertyID |
|
8491 |
target:targetID |
|
8492 |
from:requestorID |
|
8493 |
to:requestorID. |
|
8494 |
! |
|
8495 |
||
8496 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8497 |
"send a selectionNotify back from a SelectionRequest" |
8498 |
||
8499 |
%{ /* NOCONTEXT */ |
|
8500 |
||
8501 |
if (__isAtomID(propertyID) |
|
8502 |
&& __isExternalAddress(requestorID) |
|
8503 |
&& ISCONNECTED |
|
8504 |
&& __isAtomID(targetID) |
|
8505 |
&& __isAtomID(selectionID)) { |
|
1344 | 8506 |
Display *dpy = myDpy; |
8507 |
XEvent ev; |
|
8508 |
Window requestor = _WindowVal(requestorID); |
|
8509 |
Atom property = _AtomVal(propertyID); |
|
8510 |
Atom target = _AtomVal(targetID); |
|
8511 |
Atom selection = _AtomVal(selectionID); |
|
8512 |
Status result; |
|
8513 |
||
8514 |
ev.xselection.type = SelectionNotify; |
|
8515 |
ev.xselection.selection = selection; |
|
8516 |
ev.xselection.target = target; |
|
8517 |
if (__isExternalAddress(windowID)) |
|
8518 |
ev.xselection.requestor = _WindowVal(windowID); |
|
8519 |
else |
|
8520 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
8521 |
ev.xselection.time = CurrentTime; |
|
8522 |
if (property == None) |
|
8523 |
ev.xselection.property = target; |
|
8524 |
else |
|
8525 |
ev.xselection.property = property; |
|
8526 |
||
8527 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
8528 |
ev.xselection.selection, |
|
8529 |
ev.xselection.property, |
|
8530 |
ev.xselection.target, |
|
8531 |
ev.xselection.requestor, |
|
8532 |
requestor)); |
|
8533 |
||
8534 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
8535 |
if ((result == BadValue) || (result == BadWindow)) { |
|
8536 |
DPRINTF(("bad status\n")); |
|
8537 |
RETURN (false); |
|
8538 |
} |
|
8539 |
RETURN (true) |
|
382 | 8540 |
} |
8541 |
%}. |
|
8542 |
self primitiveFailed. |
|
8543 |
^ false |
|
295 | 8544 |
! |
8545 |
||
1344 | 8546 |
setSelection:anObject owner:aWindowId |
295 | 8547 |
"set the object selection, and make aWindowId be the owner. |
8548 |
This can be used by other Smalltalk(X) applications only." |
|
8549 |
||
8550 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8551 |
^ false |
295 | 8552 |
]. |
8553 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
8554 |
^ true |
|
8555 |
! |
|
8556 |
||
1344 | 8557 |
setSelectionOwner:aWindowId of:selectionID |
295 | 8558 |
"set the owner of a selection; return false if failed" |
8559 |
||
8560 |
%{ /* NOCONTEXT */ |
|
8561 |
Window win; |
|
8562 |
||
8563 |
if (__isExternalAddress(aWindowId) |
|
8564 |
&& __isAtomID(selectionID) |
|
8565 |
&& ISCONNECTED) { |
|
1344 | 8566 |
Display *dpy = myDpy; |
8567 |
||
8568 |
win = _WindowVal(aWindowId); |
|
8569 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
8570 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
8571 |
RETURN (false); |
|
8572 |
} |
|
8573 |
RETURN (true); |
|
295 | 8574 |
} |
8575 |
%} |
|
8576 |
. |
|
8577 |
self primitiveFailed. |
|
8578 |
^ nil |
|
8579 |
! |
|
8580 |
||
1344 | 8581 |
setTextSelection:aString owner:aWindowId |
295 | 8582 |
"set the text selection, and make aWindowId be the owner. |
8583 |
This can be used by any other X application." |
|
8584 |
||
8585 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8586 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 8587 |
]. |
8588 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8589 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8590 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 8591 |
! ! |
8592 |
||
8593 |
!XWorkstation methodsFor:'window stuff'! |
|
8594 |
||
1344 | 8595 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 8596 |
"clear a rectangular area to viewbackground" |
8597 |
||
8598 |
%{ /* NOCONTEXT */ |
|
8599 |
||
8600 |
int w, h; |
|
8601 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8602 |
if (ISCONNECTED) { |
1344 | 8603 |
if (__isExternalAddress(aWindowId) |
8604 |
&& __bothSmallInteger(x, y) |
|
8605 |
&& __bothSmallInteger(width, height)) { |
|
8606 |
w = __intVal(width); |
|
8607 |
h = __intVal(height); |
|
8608 |
/* |
|
8609 |
* need this check here: some servers simply dump core with bad args |
|
8610 |
*/ |
|
8611 |
if ((w >= 0) && (h >= 0)) { |
|
8612 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
|
8613 |
} |
|
8614 |
RETURN ( self ); |
|
8615 |
} |
|
295 | 8616 |
} |
8617 |
%} |
|
8618 |
. |
|
8619 |
self primitiveFailed |
|
8620 |
! |
|
8621 |
||
1344 | 8622 |
clearWindow:aWindowId |
295 | 8623 |
"clear a window to viewbackground" |
8624 |
||
8625 |
%{ /* NOCONTEXT */ |
|
8626 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8627 |
if (ISCONNECTED) { |
1344 | 8628 |
if (__isExternalAddress(aWindowId)) { |
8629 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
8630 |
RETURN ( self ); |
|
8631 |
} |
|
295 | 8632 |
} |
8633 |
%} |
|
8634 |
. |
|
8635 |
self primitiveFailed |
|
8636 |
! |
|
8637 |
||
1344 | 8638 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 8639 |
"configure stacking operation of aWindowId w.r.t siblingId" |
8640 |
||
8641 |
%{ /* NOCONTEXT */ |
|
8642 |
||
8643 |
XWindowChanges chg; |
|
8644 |
int mask = CWSibling | CWStackMode; |
|
8645 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8646 |
if (ISCONNECTED) { |
1344 | 8647 |
if (__isExternalAddress(aWindowId) |
8648 |
&& __isExternalAddress(siblingId)) { |
|
8649 |
if (modeSymbol == @symbol(above)) { |
|
8650 |
chg.stack_mode = Above; |
|
8651 |
} else if (modeSymbol == @symbol(below)) { |
|
8652 |
chg.stack_mode = Below; |
|
8653 |
} else if (modeSymbol == @symbol(topIf)) { |
|
8654 |
chg.stack_mode = TopIf; |
|
8655 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
8656 |
chg.stack_mode = BottomIf; |
|
8657 |
} else if (modeSymbol == @symbol(opposite)) { |
|
8658 |
chg.stack_mode = Opposite; |
|
8659 |
} else { |
|
8660 |
mask = CWSibling; |
|
8661 |
} |
|
8662 |
||
8663 |
chg.sibling = _WindowVal(siblingId); |
|
8664 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
8665 |
mask, &chg); |
|
8666 |
RETURN ( self ); |
|
8667 |
} |
|
295 | 8668 |
} |
8669 |
bad: ; |
|
8670 |
%} |
|
8671 |
. |
|
8672 |
self primitiveFailed |
|
8673 |
! |
|
8674 |
||
1344 | 8675 |
lowerWindow:aWindowId |
295 | 8676 |
"bring a window to back" |
8677 |
||
8678 |
%{ /* NOCONTEXT */ |
|
8679 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8680 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8681 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8682 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
8683 |
RETURN ( self ); |
|
295 | 8684 |
} |
8685 |
%} |
|
8686 |
. |
|
8687 |
self primitiveFailed |
|
8688 |
! |
|
8689 |
||
1344 | 8690 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 8691 |
"make a window visible - either as icon or as a real view - needed for restart" |
8692 |
||
8693 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
8694 |
||
8695 |
aBoolean ifTrue:[ |
|
1344 | 8696 |
wicon := aView icon. |
8697 |
wicon notNil ifTrue:[ |
|
8698 |
wiconId := wicon id |
|
8699 |
]. |
|
8700 |
wiconView := aView iconView. |
|
8701 |
wiconView notNil ifTrue:[ |
|
8702 |
wiconViewId := wiconView id |
|
8703 |
]. |
|
8704 |
wlabel := aView label. |
|
295 | 8705 |
]. |
8706 |
%{ |
|
8707 |
||
8708 |
XWMHints wmhints; |
|
8709 |
XSizeHints szhints; |
|
8710 |
Window win; |
|
8711 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8712 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8713 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8714 |
Display *dpy = myDpy; |
8715 |
||
8716 |
win = _WindowVal(aWindowId); |
|
8717 |
||
8718 |
szhints.flags = 0; |
|
8719 |
if (__bothSmallInteger(xPos, yPos)) { |
|
8720 |
szhints.x = __intVal(xPos); |
|
8721 |
szhints.y = __intVal(yPos); |
|
8722 |
szhints.flags |= USPosition; |
|
8723 |
} |
|
8724 |
if (__bothSmallInteger(w, h)) { |
|
8725 |
szhints.width = __intVal(w); |
|
8726 |
szhints.height = __intVal(h); |
|
8727 |
szhints.flags |= USSize; |
|
8728 |
} |
|
8729 |
||
8730 |
if (aBoolean == true) { |
|
8731 |
char *windowName; |
|
8732 |
Pixmap iconBitmap = (Pixmap)0; |
|
8733 |
Window iconWindow; |
|
8734 |
||
8735 |
if (__isExternalAddress(wiconId)) |
|
8736 |
iconBitmap = _PixmapVal(wiconId); |
|
8737 |
else |
|
8738 |
iconBitmap = (Pixmap)0; |
|
8739 |
||
8740 |
if (__isExternalAddress(wiconViewId)) |
|
8741 |
iconWindow = _WindowVal(wiconViewId); |
|
8742 |
else |
|
8743 |
iconWindow = (Window)0; |
|
8744 |
||
8745 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
8746 |
windowName = (char *)_stringVal(wlabel); |
|
8747 |
else |
|
8748 |
windowName = ""; |
|
8749 |
||
8750 |
if (iconBitmap || windowName) { |
|
8751 |
XSetStandardProperties(dpy, win, |
|
8752 |
windowName, windowName, |
|
8753 |
iconBitmap, |
|
8754 |
0, 0, &szhints); |
|
8755 |
} |
|
8756 |
||
8757 |
wmhints.flags = 0; |
|
8758 |
if (iconBitmap) { |
|
8759 |
wmhints.flags |= IconPixmapHint; |
|
8760 |
wmhints.icon_pixmap = iconBitmap; |
|
8761 |
} |
|
8762 |
if (iconWindow) { |
|
8763 |
wmhints.flags |= IconWindowHint; |
|
8764 |
wmhints.icon_window = iconWindow; |
|
8765 |
} |
|
8766 |
||
8767 |
wmhints.initial_state = IconicState; |
|
8768 |
wmhints.flags |= StateHint; |
|
8769 |
XSetWMHints(dpy, win, &wmhints); |
|
8770 |
} |
|
8771 |
||
8772 |
if (szhints.flags) { |
|
8773 |
XSetNormalHints(dpy, win, &szhints); |
|
8774 |
} |
|
8775 |
||
8776 |
XMapWindow(dpy, win); |
|
8777 |
RETURN ( self ); |
|
295 | 8778 |
} |
8779 |
%} |
|
8780 |
. |
|
8781 |
self primitiveFailed |
|
8782 |
! |
|
8783 |
||
1344 | 8784 |
mapWindow:aWindowId |
295 | 8785 |
"make a window visible" |
8786 |
||
8787 |
%{ /* NOCONTEXT */ |
|
8788 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8789 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8790 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8791 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
8792 |
RETURN ( self ); |
|
295 | 8793 |
} |
8794 |
%} |
|
8795 |
. |
|
8796 |
self primitiveFailed |
|
8797 |
! |
|
8798 |
||
1344 | 8799 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 8800 |
"move and resize a window" |
8801 |
||
8802 |
%{ /* NOCONTEXT */ |
|
8803 |
||
8804 |
int newWidth, newHeight; |
|
8805 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8806 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8807 |
&& __isExternalAddress(aWindowId) |
295 | 8808 |
&& __bothSmallInteger(w, h) |
8809 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 8810 |
newWidth = __intVal(w); |
8811 |
newHeight = __intVal(h); |
|
8812 |
if (newWidth < 1) newWidth = 1; |
|
8813 |
if (newHeight < 1) newHeight = 1; |
|
8814 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
8815 |
__intVal(x), __intVal(y), |
|
8816 |
newWidth, newHeight); |
|
8817 |
RETURN ( self ); |
|
295 | 8818 |
} |
8819 |
%} |
|
8820 |
. |
|
8821 |
self primitiveFailed |
|
8822 |
! |
|
8823 |
||
1344 | 8824 |
moveWindow:aWindowId x:x y:y |
295 | 8825 |
"move a window" |
8826 |
||
8827 |
%{ /* NOCONTEXT */ |
|
8828 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8829 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8830 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1344 | 8831 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
8832 |
RETURN ( self ); |
|
295 | 8833 |
} |
8834 |
%} |
|
8835 |
. |
|
8836 |
self primitiveFailed |
|
8837 |
! |
|
8838 |
||
1344 | 8839 |
raiseWindow:aWindowId |
295 | 8840 |
"bring a window to front" |
8841 |
||
8842 |
%{ /* NOCONTEXT */ |
|
8843 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8844 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8845 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8846 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
8847 |
RETURN ( self ); |
|
295 | 8848 |
} |
8849 |
%} |
|
8850 |
. |
|
8851 |
self primitiveFailed |
|
8852 |
! |
|
8853 |
||
1344 | 8854 |
resizeWindow:aWindowId width:w height:h |
295 | 8855 |
"resize a window" |
8856 |
||
8857 |
%{ /* NOCONTEXT */ |
|
8858 |
||
8859 |
int newWidth, newHeight; |
|
8860 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8861 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8862 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 8863 |
newWidth = __intVal(w); |
8864 |
newHeight = __intVal(h); |
|
8865 |
if (newWidth < 1) newWidth = 1; |
|
8866 |
if (newHeight < 1) newHeight = 1; |
|
8867 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
8868 |
RETURN ( self ); |
|
295 | 8869 |
} |
8870 |
%} |
|
8871 |
. |
|
8872 |
self primitiveFailed |
|
8873 |
! |
|
8874 |
||
1344 | 8875 |
setBackingStore:how in:aWindowId |
295 | 8876 |
"turn on/off backing-store for a window" |
8877 |
||
8878 |
%{ /* NOCONTEXT */ |
|
8879 |
||
8880 |
XSetWindowAttributes wa; |
|
8881 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8882 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8883 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8884 |
if (__INST(ignoreBackingStore) != true) { |
8885 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
8886 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
8887 |
else if (how == true) wa.backing_store = Always; |
|
8888 |
else wa.backing_store = 0; |
|
8889 |
BEGIN_INTERRUPTSBLOCKED |
|
8890 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
8891 |
END_INTERRUPTSBLOCKED |
|
8892 |
} |
|
8893 |
RETURN ( self ); |
|
295 | 8894 |
} |
8895 |
%}. |
|
8896 |
self primitiveFailed |
|
8897 |
! |
|
8898 |
||
1344 | 8899 |
setBitGravity:how in:aWindowId |
295 | 8900 |
"set bit gravity for a window" |
8901 |
||
8902 |
%{ /* NOCONTEXT */ |
|
8903 |
||
8904 |
XSetWindowAttributes wa; |
|
8905 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8906 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8907 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8908 |
if (how == @symbol(NorthWest)) { |
8909 |
wa.bit_gravity = NorthWestGravity; |
|
8910 |
} else if (how == @symbol(NorthEast)) { |
|
8911 |
wa.bit_gravity = NorthEastGravity; |
|
8912 |
} else if (how == @symbol(SouthWest)) { |
|
8913 |
wa.bit_gravity = SouthWestGravity; |
|
8914 |
} else if (how == @symbol(SouthEast)) { |
|
8915 |
wa.bit_gravity = SouthEastGravity; |
|
8916 |
} else if (how == @symbol(Center)) { |
|
8917 |
wa.bit_gravity = CenterGravity; |
|
8918 |
} else if (how == @symbol(North)) { |
|
8919 |
wa.bit_gravity = NorthGravity; |
|
8920 |
} else if (how == @symbol(South)) { |
|
8921 |
wa.bit_gravity = SouthGravity; |
|
8922 |
} else if (how == @symbol(West)) { |
|
8923 |
wa.bit_gravity = WestGravity; |
|
8924 |
} else if (how == @symbol(East)) { |
|
8925 |
wa.bit_gravity = EastGravity; |
|
8926 |
} else { |
|
8927 |
wa.bit_gravity = NorthWestGravity; |
|
8928 |
} |
|
8929 |
||
8930 |
BEGIN_INTERRUPTSBLOCKED |
|
8931 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
8932 |
END_INTERRUPTSBLOCKED |
|
8933 |
RETURN ( self ); |
|
295 | 8934 |
} |
8935 |
%}. |
|
8936 |
self primitiveFailed |
|
8937 |
! |
|
8938 |
||
1344 | 8939 |
setCursor:aCursorId in:aWindowId |
295 | 8940 |
"define a windows cursor" |
8941 |
||
8942 |
%{ /* NOCONTEXT */ |
|
8943 |
||
8944 |
Display *dpy = myDpy; |
|
8945 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8946 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8947 |
&& __isExternalAddress(aWindowId) |
295 | 8948 |
&& __isExternalAddress(aCursorId)) { |
1344 | 8949 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
8950 |
RETURN ( self ); |
|
295 | 8951 |
} |
8952 |
%}. |
|
8953 |
self primitiveFailed |
|
8954 |
! |
|
8955 |
||
1344 | 8956 |
setIconName:aString in:aWindowId |
295 | 8957 |
"define a windows iconname" |
8958 |
||
8959 |
%{ /* NOCONTEXT */ |
|
8960 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8961 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8962 |
&& __isExternalAddress(aWindowId) |
295 | 8963 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8964 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8965 |
RETURN ( self ); |
|
295 | 8966 |
} |
8967 |
%}. |
|
8968 |
self primitiveFailed |
|
8969 |
! |
|
8970 |
||
1344 | 8971 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 8972 |
"turn on/off save-under for a window" |
8973 |
||
8974 |
%{ /* NOCONTEXT */ |
|
8975 |
||
8976 |
XSetWindowAttributes wa; |
|
8977 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8978 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8979 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8980 |
if (__INST(hasSaveUnder) == true) { |
8981 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
8982 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
8983 |
} |
|
8984 |
RETURN ( self ); |
|
295 | 8985 |
} |
8986 |
%}. |
|
8987 |
self primitiveFailed |
|
8988 |
! |
|
8989 |
||
1344 | 8990 |
setTransient:aWindowId for:aMainWindowId |
295 | 8991 |
"set aWindowId to be a transient of aMainWindow" |
8992 |
||
8993 |
%{ /* NOCONTEXT */ |
|
8994 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8995 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8996 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8997 |
Window w; |
8998 |
||
8999 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
9000 |
w = (Window) 0; |
|
9001 |
} else { |
|
9002 |
if (__isExternalAddress(aMainWindowId)) { |
|
9003 |
w = _WindowVal(aMainWindowId); |
|
9004 |
} else { |
|
9005 |
goto getOutOfHere; |
|
9006 |
} |
|
9007 |
} |
|
9008 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
|
9009 |
RETURN ( self ); |
|
295 | 9010 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
9011 |
getOutOfHere: ; |
295 | 9012 |
%}. |
9013 |
self primitiveFailed |
|
9014 |
! |
|
9015 |
||
1344 | 9016 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 9017 |
"set the windows background color. This is the color with which |
9018 |
the view is filled whenever exposed. Do not confuse this with |
|
9019 |
the background drawing color, which is used with opaque drawing." |
|
9020 |
||
9021 |
%{ /* NOCONTEXT */ |
|
9022 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9023 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9024 |
&& __isExternalAddress(aWindowId) |
295 | 9025 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 9026 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
9027 |
RETURN ( self ); |
|
295 | 9028 |
} |
9029 |
%}. |
|
9030 |
self primitiveFailed |
|
9031 |
! |
|
9032 |
||
1344 | 9033 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 9034 |
"set the windows background pattern to be a form. |
9035 |
This is the pattern with which the view is filled whenever exposed. |
|
9036 |
Do not confuse this with the background drawing color, which is used |
|
9037 |
with opaque drawing." |
|
9038 |
||
9039 |
%{ /* NOCONTEXT */ |
|
9040 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9041 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9042 |
&& __isExternalAddress(aWindowId) |
295 | 9043 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9044 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
9045 |
RETURN ( self ); |
|
295 | 9046 |
} |
9047 |
%}. |
|
9048 |
self primitiveFailed |
|
9049 |
! |
|
9050 |
||
1344 | 9051 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 9052 |
"set the windows border color" |
9053 |
||
9054 |
%{ /* NOCONTEXT */ |
|
9055 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9056 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9057 |
&& __isExternalAddress(aWindowId) |
295 | 9058 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 9059 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
9060 |
RETURN ( self ); |
|
295 | 9061 |
} |
9062 |
%}. |
|
9063 |
self primitiveFailed |
|
9064 |
! |
|
9065 |
||
1344 | 9066 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 9067 |
"set the windows border pattern" |
9068 |
||
9069 |
%{ /* NOCONTEXT */ |
|
9070 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9071 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9072 |
&& __isExternalAddress(aWindowId) |
295 | 9073 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9074 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
9075 |
RETURN ( self ); |
|
295 | 9076 |
} |
9077 |
%} |
|
9078 |
. |
|
9079 |
self primitiveFailed |
|
9080 |
! |
|
9081 |
||
1344 | 9082 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 9083 |
"set the windows border shape" |
9084 |
||
9085 |
hasShapeExtension ifFalse:[^ self]. |
|
9086 |
||
9087 |
%{ /* NOCONTEXT */ |
|
9088 |
||
9089 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9090 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9091 |
&& __isExternalAddress(aWindowId) |
295 | 9092 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9093 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
9094 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
9095 |
RETURN ( self ); |
|
295 | 9096 |
} |
9097 |
#endif |
|
9098 |
%}. |
|
9099 |
self primitiveFailed |
|
9100 |
! |
|
9101 |
||
1344 | 9102 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 9103 |
"set the windows border width" |
9104 |
||
9105 |
%{ /* NOCONTEXT */ |
|
9106 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9107 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9108 |
&& __isExternalAddress(aWindowId) |
295 | 9109 |
&& __isSmallInteger(aNumber)) { |
1344 | 9110 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
9111 |
RETURN ( self ); |
|
295 | 9112 |
} |
9113 |
%}. |
|
9114 |
self primitiveFailed |
|
9115 |
! |
|
9116 |
||
1344 | 9117 |
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
|
9118 |
"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
|
9119 |
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
|
9120 |
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
|
9121 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9122 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9123 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9124 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9125 |
XClassHint classhint; |
9126 |
||
9127 |
classhint.res_class = classhint.res_name = 0; |
|
9128 |
||
9129 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
9130 |
classhint.res_class = (char *)_stringVal(wClass); |
|
9131 |
} else if (wClass != nil) |
|
9132 |
goto error; |
|
9133 |
||
9134 |
if (__isString(wName) || __isSymbol(wName)) { |
|
9135 |
classhint.res_name = (char *)_stringVal(wName); |
|
9136 |
} else if (wName != nil) |
|
9137 |
goto error; |
|
9138 |
||
9139 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
|
9140 |
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
|
9141 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9142 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9143 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9144 |
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
|
9145 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9146 |
|
1344 | 9147 |
setWindowGravity:how in:aWindowId |
295 | 9148 |
"set window gravity for a window" |
9149 |
||
9150 |
%{ /* NOCONTEXT */ |
|
9151 |
||
9152 |
XSetWindowAttributes wa; |
|
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)) { |
1344 | 9156 |
if (how == @symbol(NorthWest)) { |
9157 |
wa.win_gravity = NorthWestGravity; |
|
9158 |
} else if (how == @symbol(NorthEast)) { |
|
9159 |
wa.win_gravity = NorthEastGravity; |
|
9160 |
} else if (how == @symbol(SouthWest)) { |
|
9161 |
wa.win_gravity = SouthWestGravity; |
|
9162 |
} else if (how == @symbol(SouthEast)) { |
|
9163 |
wa.win_gravity = SouthEastGravity; |
|
9164 |
} else if (how == @symbol(Center)) { |
|
9165 |
wa.win_gravity = CenterGravity; |
|
9166 |
} else if (how == @symbol(North)) { |
|
9167 |
wa.win_gravity = NorthGravity; |
|
9168 |
} else if (how == @symbol(South)) { |
|
9169 |
wa.win_gravity = SouthGravity; |
|
9170 |
} else if (how == @symbol(West)) { |
|
9171 |
wa.win_gravity = WestGravity; |
|
9172 |
} else if (how == @symbol(East)) { |
|
9173 |
wa.win_gravity = EastGravity; |
|
9174 |
} else { |
|
9175 |
wa.win_gravity = NorthWestGravity; |
|
9176 |
} |
|
9177 |
||
9178 |
BEGIN_INTERRUPTSBLOCKED |
|
9179 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
9180 |
END_INTERRUPTSBLOCKED |
|
9181 |
RETURN ( self ); |
|
295 | 9182 |
} |
9183 |
%}. |
|
9184 |
self primitiveFailed |
|
9185 |
! |
|
9186 |
||
1344 | 9187 |
setWindowIcon:aForm in:aWindowId |
295 | 9188 |
"define a bitmap to be used as icon" |
9189 |
||
9190 |
|iconId| |
|
9191 |
||
9192 |
aForm notNil ifTrue:[ |
|
1344 | 9193 |
iconId := aForm id |
295 | 9194 |
]. |
9195 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9196 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9197 |
&& __isExternalAddress(iconId) |
295 | 9198 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9199 |
XWMHints hints; |
9200 |
||
9201 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
9202 |
hints.flags = IconPixmapHint; |
|
9203 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
9204 |
RETURN ( self ); |
|
295 | 9205 |
} |
9206 |
%}. |
|
9207 |
self primitiveFailed |
|
9208 |
! |
|
9209 |
||
1376 | 9210 |
setWindowIcon:aForm mask:aMaskForm in:aWindowId |
1535 | 9211 |
"define a windows icon and (optional) iconMask." |
9212 |
||
9213 |
|iconId maskId| |
|
9214 |
||
9215 |
aForm notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9216 |
iconId := aForm id |
1535 | 9217 |
]. |
9218 |
aMaskForm notNil ifTrue:[ |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9219 |
maskId := aMaskForm id. |
1535 | 9220 |
]. |
9221 |
%{ |
|
9222 |
if (ISCONNECTED |
|
9223 |
&& __isExternalAddress(iconId) |
|
9224 |
&& __isExternalAddress(aWindowId)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9225 |
XWMHints hints; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9226 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9227 |
hints.icon_pixmap = _PixmapVal(iconId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9228 |
hints.flags = IconPixmapHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9229 |
if ((maskId != nil) |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9230 |
&& __isExternalAddress(maskId)) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9231 |
hints.icon_mask = _PixmapVal(maskId); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9232 |
hints.flags |= IconMaskHint; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9233 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9234 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9235 |
RETURN ( self ); |
1535 | 9236 |
} |
9237 |
%}. |
|
9238 |
self primitiveFailed |
|
9239 |
||
1376 | 9240 |
! |
9241 |
||
1344 | 9242 |
setWindowIconWindow:aView in:aWindowId |
295 | 9243 |
"define a window to be used as icon" |
9244 |
||
9245 |
|iconWindowId| |
|
9246 |
||
9247 |
aView notNil ifTrue:[ |
|
1344 | 9248 |
iconWindowId := aView id |
295 | 9249 |
]. |
9250 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9251 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9252 |
&& __isExternalAddress(iconWindowId) |
295 | 9253 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9254 |
XWMHints wmhints; |
9255 |
||
9256 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
9257 |
wmhints.flags = IconWindowHint; |
|
9258 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
9259 |
RETURN ( self ); |
|
295 | 9260 |
} |
9261 |
%}. |
|
9262 |
self primitiveFailed |
|
9263 |
! |
|
9264 |
||
1344 | 9265 |
setWindowName:aString in:aWindowId |
295 | 9266 |
"define a windows name" |
9267 |
||
9268 |
%{ /* NOCONTEXT */ |
|
9269 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9270 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9271 |
&& __isExternalAddress(aWindowId) |
295 | 9272 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 9273 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
9274 |
RETURN ( self ); |
|
295 | 9275 |
} |
9276 |
%}. |
|
9277 |
self primitiveFailed |
|
9278 |
! |
|
9279 |
||
1344 | 9280 |
setWindowShape:aPixmapId in:aWindowId |
295 | 9281 |
"set the windows shape" |
9282 |
||
9283 |
hasShapeExtension ifFalse:[^ self]. |
|
9284 |
||
9285 |
%{ /* NOCONTEXT */ |
|
9286 |
||
9287 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9288 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9289 |
&& __isExternalAddress(aWindowId) |
295 | 9290 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9291 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
9292 |
0, 0, |
|
9293 |
_PixmapVal(aPixmapId), ShapeSet); |
|
9294 |
RETURN ( self ); |
|
295 | 9295 |
} |
9296 |
#endif |
|
9297 |
%}. |
|
9298 |
self primitiveFailed |
|
9299 |
! |
|
9300 |
||
1344 | 9301 |
unmapWindow:aWindowId |
295 | 9302 |
"make a window invisible" |
9303 |
||
9304 |
%{ /* NOCONTEXT */ |
|
9305 |
||
1214 | 9306 |
if (!ISCONNECTED) { |
1344 | 9307 |
RETURN ( self ); |
1214 | 9308 |
} |
9309 |
||
9310 |
if (__isExternalAddress(aWindowId)) { |
|
1344 | 9311 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
9312 |
RETURN ( self ); |
|
9313 |
} |
|
9314 |
%}. |
|
295 | 9315 |
self primitiveFailed |
1535 | 9316 |
! |
9317 |
||
9318 |
windowIsIconified:aWindowId |
|
9319 |
"return true, if some window is iconified. |
|
9320 |
The passed windowID may be an alien windows id." |
|
9321 |
||
9322 |
%{ /* NOCONTEXT */ |
|
9323 |
||
9324 |
if (ISCONNECTED |
|
9325 |
&& __isExternalAddress(aWindowId)) { |
|
1579
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9326 |
Atom JunkAtom; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9327 |
int JunkInt; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9328 |
unsigned long WinState,JunkLong; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9329 |
unsigned char *Property; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9330 |
Atom WM_STATE_Atom; |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9331 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9332 |
if (__INST(wmStateAtom) != nil) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9333 |
WM_STATE_Atom = _AtomVal(__INST(wmStateAtom)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9334 |
|
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9335 |
XGetWindowProperty(myDpy, _WindowVal(aWindowId), |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9336 |
WM_STATE_Atom, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9337 |
0L, 2L, False, AnyPropertyType, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9338 |
&JunkAtom,&JunkInt,&WinState,&JunkLong, |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9339 |
&Property); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9340 |
WinState=(unsigned long)(*((long*)Property)); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9341 |
if (WinState==3) { |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9342 |
RETURN (true); |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9343 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9344 |
} |
692c2f62d94e
handle broken X-connection smoothly
Claus Gittinger <cg@exept.de>
parents:
1576
diff
changeset
|
9345 |
RETURN (false); |
1535 | 9346 |
} |
9347 |
%}. |
|
9348 |
self primitiveFailed |
|
9349 |
||
9350 |
||
9351 |
||
295 | 9352 |
! ! |
9353 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9354 |
!XWorkstation class methodsFor:'documentation'! |
295 | 9355 |
|
9356 |
version |
|
1813 | 9357 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.252 1997-07-21 09:30:29 cg Exp $' |
295 | 9358 |
! ! |
9359 |
XWorkstation initialize! |