author | Claus Gittinger <cg@exept.de> |
Fri, 24 Nov 1995 15:50:45 +0100 | |
changeset 254 | d6f12ecd7767 |
parent 250 | eaa532ebcad7 |
child 257 | bf4d8121d960 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
70 | 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 |
|
14 |
instanceVariableNames:'screen |
|
70 | 15 |
hasShapeExtension hasFaxExtension hasShmExtension |
150 | 16 |
hasDPSExtension hasMbufExtension hasXVideoExtension |
186 | 17 |
hasSaveUnder hasPEXExtension hasImageExtension |
18 |
hasInputExtension ignoreBackingStore |
|
193 | 19 |
blackpixel whitepixel |
70 | 20 |
protocolsAtom deleteWindowAtom saveYourselfAtom |
21 |
quitAppAtom |
|
132 | 22 |
primaryAtom secondaryAtom cutBuffer0Atom |
23 |
stringAtom lengthAtom |
|
133 | 24 |
listOfXFonts buttonsPressed |
25 |
eventRootX eventRootY |
|
70 | 26 |
displayName eventTrace |
27 |
dispatchingExpose |
|
150 | 28 |
rgbVisual virtualRootId rootId |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
29 |
eventBuffer |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
30 |
altModifierMask metaModifierMask' |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
31 |
classVariableNames: 'RawKeysymTranslation' |
0 | 32 |
poolDictionaries:'' |
33 |
category:'Interface-Graphics' |
|
34 |
! |
|
35 |
||
46 | 36 |
!XWorkstation class methodsFor:'documentation'! |
37 |
||
38 |
copyright |
|
39 |
" |
|
6 | 40 |
COPYRIGHT (c) 1989 by Claus Gittinger |
70 | 41 |
All Rights Reserved |
0 | 42 |
|
46 | 43 |
This software is furnished under a license and may be used |
44 |
only in accordance with the terms of that license and with the |
|
45 |
inclusion of the above copyright notice. This software may not |
|
46 |
be provided or otherwise made available to, or used by, any |
|
47 |
other person. No title to or ownership of the software is |
|
48 |
hereby transferred. |
|
49 |
" |
|
50 |
! |
|
51 |
||
52 |
version |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
53 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.80 1995-11-24 14:50:45 cg Exp $' |
46 | 54 |
! |
55 |
||
56 |
documentation |
|
57 |
" |
|
90 | 58 |
this class provides the interface to X11. It redefines all required methods |
59 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
60 |
limited to one display - in theory, you can create Views on many displays |
|
61 |
simultanously. However, the default setup is for one display only. |
|
62 |
To support multiple displays, you will have to start another event dispatcher |
|
63 |
process for the other display(s) and create the other views with a slightly |
|
64 |
different protocol. However, 'normal' applications do not have to care for |
|
65 |
all of this ... |
|
150 | 66 |
|
67 |
See more documentation in my superclass, DeviceWorkstation. |
|
46 | 68 |
" |
69 |
! ! |
|
0 | 70 |
|
78 | 71 |
!XWorkstation primitiveDefinitions! |
72 |
||
0 | 73 |
%{ |
46 | 74 |
/* |
75 |
* x does a typedef Time - I need Object Time ... |
|
76 |
*/ |
|
0 | 77 |
#define Time XTime |
78 |
||
37 | 79 |
#ifdef memset |
80 |
# undef memset |
|
81 |
#endif |
|
82 |
||
0 | 83 |
#include <stdio.h> |
84 |
#include <X11/Xlib.h> |
|
85 |
#include <X11/Xutil.h> |
|
86 |
#include <X11/Xatom.h> |
|
87 |
||
150 | 88 |
#define XK_MISCELLANY |
89 |
#include <X11/keysymdef.h> |
|
90 |
||
90 | 91 |
/* |
92 |
* this define adds support for two-byte-strings. |
|
93 |
* leaving it undefined does not really save you much |
|
94 |
* (the define will vanish) |
|
95 |
*/ |
|
36 | 96 |
#define TWOBYTESTRINGS |
97 |
||
0 | 98 |
/* |
99 |
* shape support works; enabled by -DSHAPE in makefile |
|
100 |
* see RoundClock and RoundGlobe examples |
|
101 |
*/ |
|
102 |
#ifdef SHAPE |
|
103 |
# include <X11/extensions/shape.h> |
|
104 |
#endif |
|
105 |
||
106 |
/* |
|
150 | 107 |
* shared memory extension access is currently not supported |
0 | 108 |
* (only query is implemented) |
109 |
*/ |
|
110 |
#ifdef SHM |
|
111 |
# include <X11/extensions/XShm.h> |
|
112 |
#endif |
|
113 |
||
114 |
/* |
|
150 | 115 |
* multiBuffer extension access is currently not supported |
116 |
* (only query is implemented) |
|
117 |
*/ |
|
118 |
#ifdef MBUF |
|
119 |
# include <X11/extensions/multibuf.h> |
|
120 |
#endif |
|
121 |
||
122 |
/* |
|
123 |
* XVideo extension access is currently not supported |
|
124 |
* (only query is implemented) |
|
125 |
*/ |
|
126 |
#ifdef XVIDEO |
|
127 |
# include <X11/extensions/Xv.h> |
|
128 |
#endif |
|
129 |
||
130 |
/* |
|
0 | 131 |
* this is a non-standard fax-image decompression extension |
132 |
* (only found in megascan servers ported by myself) |
|
133 |
*/ |
|
134 |
#ifdef FAX |
|
135 |
# include <X11/extensions/XFAXImage.h> |
|
136 |
#endif |
|
137 |
||
138 |
/* |
|
186 | 139 |
* PEX extension - if available |
140 |
*/ |
|
141 |
#ifdef PEX5 |
|
142 |
# include <PEX5/PEX.h> |
|
143 |
#endif |
|
144 |
||
145 |
/* |
|
146 |
* XImage extension - if available |
|
147 |
*/ |
|
148 |
#ifdef XIE |
|
149 |
# include <X11/extensions/XIE.h> |
|
150 |
#endif |
|
151 |
||
152 |
/* |
|
90 | 153 |
* when I have more time to check it out, I will support display-PS |
0 | 154 |
*/ |
155 |
#ifdef DPS |
|
156 |
# ifdef sgi |
|
157 |
# include <X11/extensions/XDPS.h> |
|
158 |
# include <X11/extensions/XDPSlib.h> |
|
159 |
# include <X11/extensions/dpsXclient.h> |
|
160 |
# else |
|
161 |
# include <DPS/XDPS.h> |
|
162 |
# include <DPS/XDPSlib.h> |
|
163 |
# include <DPS/dpsXclient.h> |
|
164 |
# endif |
|
165 |
#endif |
|
166 |
||
90 | 167 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
168 |
/* |
|
169 |
* accessing private data in Display ... sorry |
|
170 |
*/ |
|
171 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
172 |
#else |
|
173 |
# define DISPLAYACCESS(d) d |
|
174 |
#endif |
|
175 |
||
78 | 176 |
/* |
177 |
* some defines - tired of typing ... |
|
178 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
179 |
#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
|
180 |
#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
|
181 |
#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
|
182 |
#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
|
183 |
#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
|
184 |
#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
|
185 |
#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
|
186 |
|
211 | 187 |
#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
|
188 |
#define _AtomVal(o) __intVal(o) |
211 | 189 |
#define __isAtomID(o) __isSmallInteger(o) |
190 |
||
191 |
#define myDpy _DisplayVal(_INST(displayId)) |
|
192 |
#define ISCONNECTED (_INST(displayId) != nil) |
|
78 | 193 |
|
194 |
#ifndef THISCONTEXT_IN_REGISTER |
|
195 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
196 |
# define END_INTERRUPTSBLOCKED /* */ |
|
197 |
#else |
|
198 |
extern int __interruptsBlocked; |
|
199 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
200 |
{ \ |
|
201 |
int needUnblock = 0; \ |
|
202 |
extern OBJ __thisContext__; \ |
|
203 |
\ |
|
204 |
__thisContext__ = __thisContext;\ |
|
205 |
if (!__interruptsBlocked) { \ |
|
150 | 206 |
__BLOCKINTERRUPTS(); \ |
78 | 207 |
needUnblock = 1; \ |
208 |
} |
|
209 |
||
210 |
# define END_INTERRUPTSBLOCKED \ |
|
158 | 211 |
__thisContext = __thisContext; \ |
212 |
__thisContext__ = 0; \ |
|
78 | 213 |
if (needUnblock) { \ |
150 | 214 |
__UNBLOCKINTERRUPTS(); \ |
78 | 215 |
} \ |
216 |
} |
|
217 |
||
218 |
#endif |
|
219 |
%} |
|
220 |
! ! |
|
221 |
||
222 |
!XWorkstation primitiveVariables! |
|
223 |
||
224 |
%{ |
|
0 | 225 |
/* |
146 | 226 |
* remembered info from private error handler |
0 | 227 |
*/ |
2 | 228 |
static char lastErrorMsg[80] = ""; |
229 |
static unsigned lastRequestCode = 0; |
|
230 |
static unsigned lastMinorCode = 0; |
|
231 |
static unsigned lastResource = 0; |
|
129 | 232 |
|
233 |
static int __debug__ = 0; |
|
234 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 235 |
%} |
236 |
! ! |
|
237 |
||
238 |
!XWorkstation primitiveFunctions! |
|
239 |
||
240 |
%{ |
|
18 | 241 |
/* |
144 | 242 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
243 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 244 |
* the implementation below is somewhat wrong: it will |
78 | 245 |
* report all errors for Display, even though there could be |
162 | 246 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
247 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 248 |
*/ |
168 | 249 |
static |
12 | 250 |
__XErrorHandler__(dpy, event) |
0 | 251 |
Display *dpy; |
252 |
XErrorEvent *event; |
|
253 |
{ |
|
163 | 254 |
#ifdef _AIX |
255 |
printf("XError\n"); fflush(stdout); |
|
256 |
#endif |
|
0 | 257 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
258 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 259 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 260 |
} |
2 | 261 |
lastRequestCode = event->request_code; |
262 |
lastMinorCode = event->minor_code; |
|
263 |
lastResource = event->resourceid; |
|
264 |
||
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
265 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
266 |
fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
267 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
268 |
event->minor_code, event->minor_code, event->resourceid); |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
269 |
fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg); |
218
10072d9beba5
can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
270 |
} |
43 | 271 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
272 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 273 |
return 0; |
274 |
} |
|
275 |
||
90 | 276 |
#ifdef VIRTUAL_ROOT |
0 | 277 |
/* |
18 | 278 |
* added since RootWindow-macro is not suficient |
279 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
280 |
*/ |
|
281 |
static Window |
|
282 |
getRootWindow(dpy, screen) |
|
283 |
Display *dpy; |
|
284 |
{ |
|
285 |
Window root; |
|
286 |
Atom vRootAtom = None; |
|
287 |
int i; |
|
288 |
Window rootReturn, parentReturn; |
|
289 |
Window* children; |
|
290 |
unsigned int numChildren; |
|
291 |
||
292 |
root = RootWindow(dpy, screen); |
|
293 |
/* |
|
294 |
* on IRIS, this creates a badwindow error - why ? |
|
295 |
* children contains a funny window (000034) |
|
296 |
*/ |
|
90 | 297 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 298 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 299 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
300 |
if (vRootAtom != None) { |
|
301 |
for (i=0; i < numChildren; i++) { |
|
302 |
Atom actual_type; |
|
303 |
int actual_format; |
|
304 |
unsigned long nitems, bytesafter; |
|
305 |
Window* newRoot = (Window*) 0; |
|
306 |
||
307 |
if (children[i]) { |
|
308 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
309 |
0L, 1L, False, XA_WINDOW, |
|
310 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
311 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
312 |
root = *newRoot; |
|
313 |
break; |
|
314 |
} |
|
315 |
} |
|
316 |
} |
|
317 |
if (children) XFree( children ); |
|
318 |
} |
|
18 | 319 |
} |
90 | 320 |
# endif |
18 | 321 |
return root; |
322 |
} |
|
90 | 323 |
#endif |
0 | 324 |
%} |
78 | 325 |
! ! |
0 | 326 |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
327 |
!XWorkstation class methodsFor:'initialization'! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
328 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
329 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
330 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
331 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
332 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
333 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
334 |
"/ the following table maps X-keyevents to ST/X |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
335 |
"/ device independed events. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
336 |
"/ It is NOT meant as a keyboardMap replacement. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
337 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
338 |
RawKeysymTranslation := d := Dictionary new. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
339 |
d at:'Delete_line' put:#DeleteLine. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
340 |
d at:'Delete_word' put:#DeleteWord. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
341 |
d at:'Down' put:#CursorDown. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
342 |
d at:'Up' put:#CursorUp. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
343 |
d at:'Left' put:#CursorLeft. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
344 |
d at:'Right' put:#CursorRight. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
345 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
346 |
|
2 | 347 |
!XWorkstation class methodsFor:'error handling'! |
348 |
||
129 | 349 |
debug:aBoolean |
350 |
%{ /* NOCONTEXT */ |
|
351 |
||
352 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
353 |
%} |
|
354 |
! |
|
355 |
||
2 | 356 |
requestCodeOfLastError |
357 |
%{ /* NOCONTEXT */ |
|
358 |
||
359 |
RETURN ( _MKSMALLINT(lastRequestCode) ); |
|
360 |
%} |
|
361 |
! |
|
362 |
||
363 |
minorCodeOfLastError |
|
364 |
%{ /* NOCONTEXT */ |
|
365 |
||
366 |
RETURN ( _MKSMALLINT(lastMinorCode) ); |
|
367 |
%} |
|
368 |
! |
|
369 |
||
370 |
resourceIdOfLastError |
|
371 |
%{ /* NOCONTEXT */ |
|
372 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
373 |
RETURN ( __MKOBJ(lastResource) ); |
2 | 374 |
%} |
375 |
! |
|
376 |
||
78 | 377 |
errorStringOfLastError |
378 |
%{ |
|
216 | 379 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 380 |
%} |
381 |
! |
|
382 |
||
135 | 383 |
lastErrorString |
2 | 384 |
"return the last X-error string - |
385 |
when buffering is on, this may be |
|
386 |
an error for a long-ago operation" |
|
78 | 387 |
|
388 |
|string requestCode s match line| |
|
389 |
||
390 |
string := self errorStringOfLastError. |
|
391 |
requestCode := self requestCodeOfLastError. |
|
392 |
" |
|
393 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
394 |
and append the name of the corresponding X-request |
|
395 |
" |
|
396 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
397 |
s notNil ifTrue:[ |
|
398 |
match := 'XRequest.' , requestCode printString. |
|
399 |
line := s peekForLineStartingWith:match. |
|
400 |
line notNil ifTrue:[ |
|
401 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
402 |
]. |
|
403 |
s close. |
|
404 |
]. |
|
405 |
^ string |
|
2 | 406 |
! ! |
407 |
||
0 | 408 |
!XWorkstation methodsFor:'initialize / release'! |
409 |
||
410 |
initializeFor:aDisplayName |
|
411 |
"initialize the receiver for a connection to an X-Server; |
|
412 |
the argument, aDisplayName may be nil (for the default server from |
|
90 | 413 |
DISPLAY-variable or command line argument) or the name of the server |
414 |
as hostname:number" |
|
415 |
||
208 | 416 |
|dpyName index| |
90 | 417 |
|
418 |
dpyName := aDisplayName. |
|
419 |
dpyName isNil ifTrue:[ |
|
420 |
"look for a '-display xxx' argument" |
|
135 | 421 |
Arguments notNil ifTrue:[ |
422 |
index := Arguments indexOf:'-display'. |
|
423 |
(index between:1 and:(Arguments size - 1)) ifTrue:[ |
|
144 | 424 |
dpyName := Arguments at:index+1 |
135 | 425 |
] |
90 | 426 |
] |
427 |
]. |
|
0 | 428 |
%{ |
23 | 429 |
int scr; |
0 | 430 |
Display *dpy; |
431 |
Visual *visual; |
|
23 | 432 |
XVisualInfo viproto; |
433 |
XVisualInfo *vip; /* retured info */ |
|
434 |
int maxRGBDepth; |
|
435 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
436 |
int rgbVisualID; |
|
437 |
int nvi, i; |
|
0 | 438 |
int shapeEventBase, shapeErrorBase; |
439 |
int shmEventBase, shmErrorBase; |
|
440 |
int faxEventBase, faxErrorBase; |
|
90 | 441 |
char *type, *nm; |
0 | 442 |
int dummy; |
208 | 443 |
OBJ dpyID; |
0 | 444 |
|
445 |
if (_INST(displayId) != nil) { |
|
152 | 446 |
/* |
447 |
* already connected - you bad guy try to |
|
448 |
* trick me manually ? |
|
449 |
*/ |
|
70 | 450 |
RETURN ( self ); |
0 | 451 |
} |
452 |
||
54 | 453 |
BEGIN_INTERRUPTSBLOCKED |
454 |
||
90 | 455 |
if (__isString(dpyName)) |
456 |
nm = (char *)_stringVal(dpyName); |
|
212
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
457 |
else { |
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
458 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
90 | 459 |
nm = NULL; |
212
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
460 |
} |
90 | 461 |
dpy = XOpenDisplay(nm); |
0 | 462 |
|
463 |
if (dpy) { |
|
208 | 464 |
_INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
152 | 465 |
|
0 | 466 |
#ifdef SUPERDEBUG |
70 | 467 |
XSynchronize(dpy, 1); |
0 | 468 |
#endif |
152 | 469 |
|
470 |
XSetErrorHandler(__XErrorHandler__); |
|
471 |
} |
|
472 |
||
473 |
END_INTERRUPTSBLOCKED |
|
186 | 474 |
%}. |
208 | 475 |
displayId isNil ifTrue:[ |
152 | 476 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
477 |
^ nil |
|
478 |
]. |
|
479 |
||
480 |
self initializeScreenProperties. |
|
481 |
||
482 |
dispatching := false. |
|
483 |
dispatchingExpose := false. |
|
484 |
isSlow := false. |
|
485 |
shiftDown := false. |
|
486 |
ctrlDown := false. |
|
487 |
metaDown := false. |
|
488 |
altDown := false. |
|
489 |
motionEventCompression := true. |
|
490 |
buttonsPressed := 0. |
|
491 |
displayName := dpyName. |
|
492 |
||
493 |
protocolsAtom := nil. |
|
494 |
deleteWindowAtom := nil. |
|
495 |
saveYourselfAtom := nil. |
|
496 |
quitAppAtom := nil. |
|
497 |
||
498 |
self initializeDefaultValues. |
|
499 |
self initializeEventBuffer. |
|
500 |
self initializeSpecialFlags. |
|
501 |
self initializeKeyboardMap. |
|
502 |
||
503 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
504 |
! |
|
505 |
||
506 |
initializeDefaultValues |
|
507 |
buttonTranslation := ButtonTranslation. |
|
508 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
509 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
510 |
"/ these should be queried from the server |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
511 |
"/ (this will soon be done) - for now, take standard values |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
512 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
513 |
altModifiers := #(Alt_L Alt_R). |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
514 |
metaModifiers := #(Meta_L Meta_R). |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
515 |
ctrlModifiers := #(Control_L Control_R). |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
516 |
shiftModifiers := #(Shift_L Shift_R). |
152 | 517 |
! |
518 |
||
519 |
initializeEventBuffer |
|
520 |
|sz| |
|
521 |
||
522 |
%{ |
|
523 |
sz = _MKSMALLINT(sizeof(XEvent) + 100); |
|
524 |
%}. |
|
525 |
eventBuffer isNil ifTrue:[ |
|
526 |
eventBuffer := ByteArray new:sz. |
|
527 |
]. |
|
528 |
! |
|
529 |
||
530 |
initializeScreenProperties |
|
531 |
%{ /* NOCONTEXT */ |
|
532 |
||
533 |
Display *dpy = myDpy; |
|
534 |
int scr; |
|
535 |
Visual *visual; |
|
536 |
XVisualInfo viproto; |
|
537 |
XVisualInfo *vip; /* retured info */ |
|
538 |
int maxRGBDepth; |
|
539 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
540 |
int rgbVisualID; |
|
541 |
int nvi, i; |
|
542 |
int shapeEventBase, shapeErrorBase; |
|
543 |
int shmEventBase, shmErrorBase; |
|
544 |
int faxEventBase, faxErrorBase; |
|
545 |
char *type, *nm; |
|
546 |
int dummy; |
|
193 | 547 |
int mask, shift, nBits; |
152 | 548 |
|
549 |
if (ISCONNECTED) { |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
550 |
_INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
551 |
_INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
552 |
|
152 | 553 |
BEGIN_INTERRUPTSBLOCKED |
554 |
||
70 | 555 |
_INST(screen) = _MKSMALLINT(scr = DefaultScreen(dpy)); |
556 |
_INST(depth) = _MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
557 |
_INST(ncells) = _MKSMALLINT(DisplayCells(dpy, scr)); |
|
558 |
_INST(width) = _MKSMALLINT(DisplayWidth(dpy, scr)); |
|
559 |
_INST(height) = _MKSMALLINT(DisplayHeight(dpy, scr)); |
|
560 |
_INST(widthMM) = _MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
561 |
_INST(heightMM) = _MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
562 |
_INST(blackpixel) = _MKSMALLINT(BlackPixel(dpy, scr)); |
|
563 |
_INST(whitepixel) = _MKSMALLINT(WhitePixel(dpy, scr)); |
|
135 | 564 |
|
0 | 565 |
#ifdef SHAPE |
70 | 566 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
567 |
_INST(hasShapeExtension) = true; |
|
568 |
else |
|
135 | 569 |
#endif |
150 | 570 |
_INST(hasShapeExtension) = false; |
135 | 571 |
|
0 | 572 |
#ifdef SHM |
70 | 573 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
574 |
_INST(hasShmExtension) = true; |
|
575 |
else |
|
135 | 576 |
#endif |
150 | 577 |
_INST(hasShmExtension) = false; |
135 | 578 |
|
0 | 579 |
#ifdef FAX |
70 | 580 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
581 |
_INST(hasFaxExtension) = true; |
|
582 |
else |
|
135 | 583 |
#endif |
150 | 584 |
_INST(hasFaxExtension) = false; |
135 | 585 |
|
0 | 586 |
#ifdef DPS |
70 | 587 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
588 |
_INST(hasDPSExtension) = true; |
|
589 |
else |
|
135 | 590 |
#endif |
150 | 591 |
_INST(hasDPSExtension) = false; |
592 |
||
593 |
#ifdef XVIDEO |
|
594 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
|
595 |
_INST(hasXVideoExtension) = true; |
|
596 |
else |
|
597 |
#endif |
|
598 |
_INST(hasXVideoExtension) = false; |
|
599 |
||
600 |
#ifdef MBUF |
|
601 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
|
602 |
_INST(hasMbufExtension) = true; |
|
603 |
else |
|
604 |
#endif |
|
605 |
_INST(hasMbufExtension) = false; |
|
70 | 606 |
|
186 | 607 |
#ifdef PEX5 |
608 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
|
609 |
_INST(hasPEXExtension) = true; |
|
610 |
else |
|
611 |
#endif |
|
612 |
_INST(hasPEXExtension) = false; |
|
613 |
||
614 |
#ifdef XIE |
|
615 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
|
616 |
_INST(hasImageExtension) = true; |
|
617 |
else |
|
618 |
#endif |
|
619 |
_INST(hasImageExtension) = false; |
|
620 |
||
621 |
#ifdef XI |
|
622 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
|
623 |
_INST(hasInputExtension) = true; |
|
624 |
else |
|
625 |
#endif |
|
626 |
_INST(hasInputExtension) = false; |
|
627 |
||
70 | 628 |
/* |
629 |
* look for RGB visual |
|
630 |
*/ |
|
631 |
nvi = 0; |
|
632 |
viproto.screen = scr; |
|
633 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
634 |
maxRGBDepth = 0; |
|
635 |
for (i = 0; i < nvi; i++) { |
|
636 |
switch (vip[i].class) { |
|
637 |
case TrueColor: |
|
638 |
if (vip[i].depth > maxRGBDepth) { |
|
639 |
maxRGBDepth = vip[i].depth; |
|
640 |
rgbRedMask = vip[i].red_mask; |
|
641 |
rgbGreenMask = vip[i].green_mask; |
|
642 |
rgbBlueMask = vip[i].blue_mask; |
|
643 |
rgbVisualID = vip[i].visualid; |
|
644 |
} |
|
645 |
break; |
|
646 |
} |
|
647 |
} |
|
648 |
if (vip) XFree ((char *) vip); |
|
649 |
||
650 |
if (maxRGBDepth) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
651 |
_INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
70 | 652 |
} |
653 |
||
654 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
152 | 655 |
_INST(monitorType) = @symbol(unknown); |
656 |
_INST(hasColors) = true; |
|
657 |
_INST(hasGreyscales) = true; |
|
70 | 658 |
switch (visual->class) { |
659 |
case StaticGray: |
|
660 |
_INST(visualType) = @symbol(StaticGray); |
|
661 |
_INST(hasColors) = false; |
|
662 |
_INST(monitorType) = @symbol(monochrome); |
|
663 |
break; |
|
664 |
case GrayScale: |
|
665 |
_INST(visualType) = @symbol(GrayScale); |
|
666 |
_INST(hasColors) = false; |
|
667 |
_INST(monitorType) = @symbol(monochrome); |
|
668 |
break; |
|
669 |
case StaticColor: |
|
670 |
_INST(visualType) = @symbol(StaticColor); |
|
671 |
break; |
|
672 |
case PseudoColor: |
|
673 |
_INST(visualType) = @symbol(PseudoColor); |
|
674 |
break; |
|
675 |
case TrueColor: |
|
676 |
_INST(visualType) = @symbol(TrueColor); |
|
677 |
break; |
|
678 |
case DirectColor: |
|
679 |
_INST(visualType) = @symbol(DirectColor); |
|
680 |
break; |
|
681 |
} |
|
682 |
if (DisplayCells(dpy, scr) == 2) { |
|
683 |
_INST(hasColors) = false; |
|
684 |
_INST(hasGreyscales) = false; |
|
685 |
_INST(monitorType) = @symbol(monochrome); |
|
686 |
} |
|
687 |
_INST(bitsPerRGB) = _MKSMALLINT(visual->bits_per_rgb); |
|
688 |
_INST(redMask) = _MKSMALLINT(visual->red_mask); |
|
689 |
_INST(greenMask) = _MKSMALLINT(visual->green_mask); |
|
690 |
_INST(blueMask) = _MKSMALLINT(visual->blue_mask); |
|
193 | 691 |
switch (visual->class) { |
692 |
case TrueColor: |
|
693 |
/* extract number of bits and shift counts */ |
|
694 |
mask = visual->red_mask; |
|
695 |
shift = 0; |
|
696 |
while (mask && ((mask & 1) == 0)) { |
|
697 |
mask >>= 1; |
|
698 |
shift++; |
|
699 |
} |
|
700 |
_INST(redShift) = __MKSMALLINT(shift); |
|
701 |
nBits = 0; |
|
702 |
while (mask) { |
|
703 |
mask >>= 1; |
|
704 |
nBits++; |
|
705 |
} |
|
706 |
_INST(bitsRed) = __MKSMALLINT(nBits); |
|
707 |
||
708 |
mask = visual->green_mask; |
|
709 |
shift = 0; |
|
710 |
while (mask && ((mask & 1) == 0)) { |
|
711 |
mask >>= 1; |
|
712 |
shift++; |
|
713 |
} |
|
714 |
_INST(greenShift) = __MKSMALLINT(shift); |
|
715 |
nBits = 0; |
|
716 |
while (mask) { |
|
717 |
mask >>= 1; |
|
718 |
nBits++; |
|
719 |
} |
|
720 |
_INST(bitsGreen) = __MKSMALLINT(nBits); |
|
721 |
||
722 |
mask = visual->blue_mask; |
|
723 |
shift = 0; |
|
724 |
while (mask && ((mask & 1) == 0)) { |
|
725 |
mask >>= 1; |
|
726 |
shift++; |
|
727 |
} |
|
728 |
_INST(blueShift) = __MKSMALLINT(shift); |
|
729 |
nBits = 0; |
|
730 |
while (mask) { |
|
731 |
mask >>= 1; |
|
732 |
nBits++; |
|
733 |
} |
|
734 |
_INST(bitsBlue) = __MKSMALLINT(nBits); |
|
735 |
break; |
|
736 |
} |
|
70 | 737 |
|
132 | 738 |
#ifndef XA_PRIMARY |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
739 |
_INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
132 | 740 |
#else |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
741 |
_INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
132 | 742 |
#endif |
743 |
#ifndef XA_SECONDARY |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
744 |
_INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
132 | 745 |
#else |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
746 |
_INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
132 | 747 |
#endif |
748 |
#ifndef XA_CUT_BUFFER0 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
749 |
_INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
132 | 750 |
#else |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
751 |
_INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
132 | 752 |
#endif |
753 |
#ifndef XA_STRING |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
754 |
_INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
132 | 755 |
#else |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
756 |
_INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
132 | 757 |
#endif |
758 |
#ifndef XA_LENGTH |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
759 |
_INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
132 | 760 |
#else |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
761 |
_INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
132 | 762 |
#endif |
152 | 763 |
|
764 |
END_INTERRUPTSBLOCKED |
|
765 |
} |
|
0 | 766 |
%} |
135 | 767 |
! |
768 |
||
769 |
initializeSpecialFlags |
|
770 |
"perform additional special server implementation flags" |
|
771 |
||
772 |
"/ |
|
773 |
"/ assume we have it ... (should check) |
|
774 |
"/ |
|
775 |
hasSaveUnder := true. |
|
776 |
ignoreBackingStore := false. |
|
777 |
||
778 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
779 |
"/ |
|
780 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
781 |
"/ which does not correctly handle saveUnder |
|
782 |
"/ |
|
783 |
hasSaveUnder := false. |
|
784 |
]. |
|
785 |
! |
|
786 |
||
0 | 787 |
close |
788 |
"close down the connection to the X-server" |
|
789 |
||
790 |
%{ /* NOCONTEXT */ |
|
791 |
||
150 | 792 |
if (ISCONNECTED) { |
70 | 793 |
BEGIN_INTERRUPTSBLOCKED |
794 |
XCloseDisplay(myDpy); |
|
795 |
_INST(displayId) = nil; |
|
796 |
END_INTERRUPTSBLOCKED |
|
0 | 797 |
} |
798 |
%} |
|
12 | 799 |
! |
800 |
||
801 |
reinitialize |
|
150 | 802 |
virtualRootId := rootId := nil. |
12 | 803 |
super reinitialize. |
804 |
dispatchingExpose := nil |
|
0 | 805 |
! ! |
806 |
||
807 |
!XWorkstation methodsFor:'misc'! |
|
808 |
||
809 |
setInputFocusTo:aWindowId |
|
90 | 810 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
811 |
self setInputFocusTo:aWindowId revertTo:#root |
|
812 |
! |
|
813 |
||
814 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
0 | 815 |
|
816 |
%{ /* NOCONTEXT */ |
|
90 | 817 |
int arg; |
0 | 818 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
819 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
90 | 820 |
if (revertSymbol == @symbol(parent)) |
821 |
arg = RevertToParent; |
|
822 |
else if (revertSymbol == @symbol(root)) |
|
823 |
arg = RevertToPointerRoot; |
|
824 |
else |
|
825 |
arg = None; |
|
826 |
||
70 | 827 |
BEGIN_INTERRUPTSBLOCKED |
90 | 828 |
XSetInputFocus(myDpy, _WindowVal(aWindowId), arg, CurrentTime); |
70 | 829 |
END_INTERRUPTSBLOCKED |
830 |
RETURN ( self ); |
|
0 | 831 |
} |
70 | 832 |
%}. |
0 | 833 |
self primitiveFailed |
834 |
! |
|
835 |
||
836 |
unBuffered |
|
837 |
"make all drawing be sent immediately to the display" |
|
838 |
||
839 |
%{ /* NOCONTEXT */ |
|
840 |
||
150 | 841 |
if (ISCONNECTED) { |
842 |
BEGIN_INTERRUPTSBLOCKED |
|
843 |
XSynchronize(myDpy, 1); |
|
844 |
END_INTERRUPTSBLOCKED |
|
845 |
} |
|
0 | 846 |
%} |
847 |
"Display unbuffered" |
|
848 |
! |
|
849 |
||
850 |
buffered |
|
180 | 851 |
"buffer drawing - do not send it immediately to the display. |
852 |
This is the default anyway." |
|
0 | 853 |
|
854 |
%{ /* NOCONTEXT */ |
|
855 |
||
150 | 856 |
if (ISCONNECTED) { |
857 |
BEGIN_INTERRUPTSBLOCKED |
|
858 |
XSynchronize(myDpy, 0); |
|
859 |
END_INTERRUPTSBLOCKED |
|
860 |
} |
|
0 | 861 |
%} |
862 |
"Display buffered" |
|
863 |
! |
|
864 |
||
180 | 865 |
flush |
866 |
"send all buffered drawing to the display. |
|
867 |
This may be required to make certain, that all previous operations |
|
868 |
are really sent to the display before continuing. For example, |
|
869 |
after a cursor-change with a followup long computation. |
|
870 |
(otherwise, the cursor change request may still be in the output |
|
871 |
buffer)" |
|
0 | 872 |
|
873 |
%{ /* NOCONTEXT */ |
|
874 |
||
150 | 875 |
if (ISCONNECTED) { |
876 |
BEGIN_INTERRUPTSBLOCKED |
|
877 |
XSync(myDpy, 0); |
|
878 |
END_INTERRUPTSBLOCKED |
|
879 |
} |
|
0 | 880 |
%} |
881 |
! |
|
882 |
||
883 |
flushDpsContext:aDPSContext |
|
884 |
||
885 |
%{ /* NOCONTEXT */ |
|
886 |
#ifdef DPS |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
887 |
if (__isExternalAddress(aDPSContext)) { |
70 | 888 |
BEGIN_INTERRUPTSBLOCKED |
889 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
890 |
END_INTERRUPTSBLOCKED |
|
891 |
RETURN ( self ); |
|
0 | 892 |
} |
893 |
#endif |
|
894 |
%} |
|
895 |
. |
|
896 |
self primitiveFailed |
|
897 |
! |
|
898 |
||
2 | 899 |
beep:volumeInPercent |
900 |
"output an audible beep" |
|
0 | 901 |
%{ |
2 | 902 |
int volume; |
903 |
||
150 | 904 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
70 | 905 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
906 |
volume = _intVal(volumeInPercent) * 2 - 100; |
|
907 |
if (volume < -100) volume = -100; |
|
908 |
else if (volume > 100) volume = 100; |
|
909 |
BEGIN_INTERRUPTSBLOCKED |
|
910 |
XBell(myDpy, volume); |
|
911 |
END_INTERRUPTSBLOCKED |
|
2 | 912 |
} |
0 | 913 |
%} |
2 | 914 |
! |
915 |
||
916 |
beep |
|
917 |
"output an audible beep or bell" |
|
918 |
||
919 |
self beep:50 |
|
12 | 920 |
! |
921 |
||
922 |
ignoreBackingStore:aBoolean |
|
923 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
924 |
no backing store used - this can be used on servers where backing store is |
|
925 |
very slow or is broken (can be put into display-rc-file)" |
|
926 |
||
927 |
ignoreBackingStore := aBoolean |
|
0 | 928 |
! ! |
929 |
||
104 | 930 |
!XWorkstation class methodsFor:'queries'! |
931 |
||
932 |
platformName |
|
133 | 933 |
"ST-80 compatibility. |
934 |
Return a string describing the display systems platform." |
|
935 |
||
936 |
^ 'X' "I don't know what ST-80 returns for X ..." |
|
104 | 937 |
! ! |
938 |
||
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
939 |
!XWorkstation methodsFor:'keyboard mapping'! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
940 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
941 |
translateKey:untranslatedKey |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
942 |
"Return the key translated via the translation table. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
943 |
Here, we preTranslate the key first into a common ST/X |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
944 |
name, which gets further processed in the superclasses translation |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
945 |
method." |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
946 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
947 |
|key| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
948 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
949 |
(key := untranslatedKey) isString ifTrue:[ |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
950 |
key := RawKeysymTranslation at:key ifAbsent:key. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
951 |
key := key asSymbol. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
952 |
]. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
953 |
^ super translateKey:key |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
954 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
955 |
|
0 | 956 |
!XWorkstation methodsFor:'accessing & queries'! |
957 |
||
958 |
displayFileDescriptor |
|
959 |
"return the displays fileNumber - for select" |
|
960 |
||
961 |
%{ /* NOCONTEXT */ |
|
962 |
||
150 | 963 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
964 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 965 |
} |
966 |
RETURN (nil); |
|
0 | 967 |
%} |
968 |
! |
|
969 |
||
133 | 970 |
displayName |
971 |
"return the X-connections display name. |
|
972 |
This is (currently) nil for the default display, |
|
973 |
something like foo:0 for any other remote display. |
|
974 |
Future versions may return non-nil strings for the default display as well." |
|
975 |
||
976 |
^ displayName |
|
977 |
! |
|
978 |
||
0 | 979 |
serverVendor |
980 |
"return the X-server vendor string - this should normally not be of |
|
981 |
any interrest, but can be for special cases |
|
982 |
(to avoid bugs in certain implementations)" |
|
983 |
%{ |
|
150 | 984 |
if (ISCONNECTED) { |
216 | 985 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
150 | 986 |
} |
987 |
RETURN (nil); |
|
0 | 988 |
%} |
43 | 989 |
|
990 |
" |
|
991 |
Display serverVendor |
|
992 |
" |
|
0 | 993 |
! |
994 |
||
995 |
vendorRelease |
|
996 |
"return the X-servers vendor release - should normally not be of |
|
997 |
any interrest, but can be for special cases. |
|
998 |
(to avoid bugs in certain implementations)" |
|
81 | 999 |
|
1000 |
%{ /* NOCONTEXT */ |
|
150 | 1001 |
if (ISCONNECTED) { |
1002 |
RETURN ( _MKSMALLINT(XVendorRelease(myDpy)) ); |
|
1003 |
} |
|
1004 |
RETURN (nil); |
|
0 | 1005 |
%} |
43 | 1006 |
|
1007 |
" |
|
1008 |
Display vendorRelease |
|
1009 |
" |
|
0 | 1010 |
! |
1011 |
||
1012 |
protocolVersion |
|
1013 |
"return the X-servers protocol version - should normally not be of |
|
1014 |
any interrest" |
|
81 | 1015 |
|
1016 |
%{ /* NOCONTEXT */ |
|
150 | 1017 |
if (ISCONNECTED) { |
1018 |
RETURN ( _MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
1019 |
} |
|
1020 |
RETURN (nil); |
|
0 | 1021 |
%} |
43 | 1022 |
|
1023 |
" |
|
1024 |
Display protocolVersion |
|
1025 |
" |
|
0 | 1026 |
! |
1027 |
||
1028 |
hasShape |
|
186 | 1029 |
"return true, if this workstation supports non-rectangular windows. |
1030 |
Both the server must support it, and the feature must have been |
|
1031 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 1032 |
|
1033 |
^ hasShapeExtension |
|
43 | 1034 |
|
1035 |
" |
|
186 | 1036 |
Display hasShape |
43 | 1037 |
" |
0 | 1038 |
! |
1039 |
||
1040 |
hasShm |
|
186 | 1041 |
"return true, if this workstation supports the shared pixmap extension. |
1042 |
Both the server must support it, and the feature must have been |
|
1043 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 1044 |
|
1045 |
^ hasShmExtension |
|
186 | 1046 |
|
1047 |
" |
|
1048 |
Display hasShm |
|
1049 |
" |
|
0 | 1050 |
! |
1051 |
||
1052 |
hasFax |
|
186 | 1053 |
"return true, if this workstation supports decompression of fax images. |
1054 |
Both the server must support it, and the feature must have been |
|
1055 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 1056 |
|
1057 |
^ hasFaxExtension |
|
186 | 1058 |
|
1059 |
" |
|
1060 |
Display hasFaxExtension |
|
1061 |
" |
|
0 | 1062 |
! |
1063 |
||
1064 |
hasDPS |
|
186 | 1065 |
"return true, if this workstation supports display postscript. |
1066 |
Both the server must support it, and the feature must have been |
|
1067 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 1068 |
|
1069 |
^ hasDPSExtension |
|
186 | 1070 |
|
1071 |
" |
|
1072 |
Display hasDPS |
|
1073 |
" |
|
1074 |
! |
|
1075 |
||
1076 |
hasPEX |
|
1077 |
"return true, if this workstation supports PEX 3D graphics. |
|
1078 |
Both the server must support it, and the feature must have been |
|
1079 |
enabled in the smalltalk system, for true to be returned." |
|
1080 |
||
1081 |
^ hasPEXExtension |
|
1082 |
||
1083 |
" |
|
1084 |
Display hasPEX |
|
1085 |
" |
|
0 | 1086 |
! |
1087 |
||
150 | 1088 |
hasMultibuffer |
186 | 1089 |
"return true, if this workstation supports the multibuffer extension. |
1090 |
Both the server must support it, and the feature must have been |
|
1091 |
enabled in the smalltalk system, for true to be returned." |
|
150 | 1092 |
|
1093 |
^ hasMbufExtension |
|
186 | 1094 |
|
1095 |
" |
|
1096 |
Display hasMultibuffer |
|
1097 |
" |
|
1098 |
! |
|
1099 |
||
1100 |
hasInputExtension |
|
1101 |
"return true, if this workstation supports the X input extension. |
|
1102 |
Both the server must support it, and the feature must have been |
|
1103 |
enabled in the smalltalk system, for true to be returned." |
|
1104 |
||
1105 |
^ hasInputExtension |
|
1106 |
||
1107 |
" |
|
1108 |
Display hasInputExtension |
|
1109 |
" |
|
1110 |
! |
|
1111 |
||
1112 |
hasImageExtension |
|
1113 |
"return true, if this workstation supports the X image extension. |
|
1114 |
Both the server must support it, and the feature must have been |
|
1115 |
enabled in the smalltalk system, for true to be returned." |
|
1116 |
||
1117 |
^ hasImageExtension |
|
1118 |
||
1119 |
" |
|
1120 |
Display hasImageExtension |
|
1121 |
" |
|
150 | 1122 |
! |
1123 |
||
1124 |
hasXVideo |
|
186 | 1125 |
"return true, if this workstation supports the XVideo extension. |
1126 |
Both the server must support it, and the feature must have been |
|
1127 |
enabled in the smalltalk system, for true to be returned." |
|
150 | 1128 |
|
1129 |
^ hasXVideoExtension |
|
186 | 1130 |
|
1131 |
" |
|
1132 |
Display hasXVideo |
|
1133 |
" |
|
150 | 1134 |
! |
1135 |
||
1136 |
hasExtension:extensionString |
|
1137 |
"query for an X extension. The argument, extensionString |
|
1138 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 1139 |
Return true, if that extension is available in the server. |
1140 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 1141 |
|
1142 |
%{ |
|
1143 |
int dummy; |
|
1144 |
||
1145 |
if (__isString(extensionString) && ISCONNECTED) { |
|
1146 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
1147 |
RETURN ( true ); |
|
1148 |
} |
|
1149 |
} |
|
1150 |
%}. |
|
1151 |
^ false |
|
186 | 1152 |
|
1153 |
" |
|
1154 |
Display hasExtension:'XVideo' |
|
1155 |
Display hasExtension:'Input' |
|
1156 |
Display hasExtension:'GLX' |
|
1157 |
Display hasExtension:'X3D-PEX' |
|
1158 |
Display hasExtension:'XInputExtension' |
|
1159 |
Display hasExtension:'SHAPE' |
|
1160 |
Display hasExtension:'MIT-SHM' |
|
1161 |
Display hasExtension:'SGIFullScreenStereo' |
|
1162 |
" |
|
150 | 1163 |
! |
1164 |
||
43 | 1165 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1166 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1167 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1168 |
depth, bitsPerPixel and padding values." |
43 | 1169 |
|
150 | 1170 |
|nFormats "{ Class: SmallInteger }" |
1171 |
formatArray| |
|
43 | 1172 |
%{ |
1173 |
Display *dpy = myDpy; |
|
150 | 1174 |
|
1175 |
if (! ISCONNECTED) { |
|
1176 |
RETURN (nil); |
|
1177 |
} |
|
90 | 1178 |
nFormats = _MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 1179 |
%}. |
1180 |
formatArray := Array new:nFormats. |
|
150 | 1181 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1182 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 1183 |
|
1184 |
i := index. |
|
43 | 1185 |
%{ |
70 | 1186 |
ScreenFormat *format; |
1187 |
Display *dpy = myDpy; |
|
1188 |
||
90 | 1189 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
70 | 1190 |
format += (_intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1191 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1192 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1193 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 1194 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1195 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1196 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1197 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1198 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1199 |
formatArray at:index put:info. |
43 | 1200 |
]. |
1201 |
^ formatArray |
|
1202 |
||
1203 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1204 |
Display supportedImageFormats |
43 | 1205 |
" |
1206 |
! |
|
1207 |
||
81 | 1208 |
supportsDeepIcons |
1209 |
"return true, if this device supports non b&w (i.e. greyScale |
|
1210 |
or colored icons). Many Xservers (and/or windowManagers) crash, |
|
186 | 1211 |
if you pass them a deep form as icon; therefore, we return false. |
1212 |
It may be a good idea to check for the server vendor/release and |
|
1213 |
return trie sometimes." |
|
81 | 1214 |
|
1215 |
^ false |
|
1216 |
! |
|
1217 |
||
1218 |
supportsViewGravity |
|
1219 |
"return true, if this device supports gravity attributes. |
|
82 | 1220 |
We do not depend on it being implemented, but some resizing operations |
81 | 1221 |
are faster, it is is." |
1222 |
||
1223 |
^ true |
|
1224 |
! |
|
1225 |
||
0 | 1226 |
blackpixel |
1227 |
"return the colornumber of black" |
|
1228 |
||
1229 |
^ blackpixel |
|
1230 |
! |
|
1231 |
||
1232 |
whitepixel |
|
1233 |
"return the colornumber of white" |
|
1234 |
||
1235 |
^ whitepixel |
|
1236 |
! |
|
1237 |
||
81 | 1238 |
buttonMotionMask:aButton |
1239 |
"return the state-mask for button1 in motion events state-field. |
|
1240 |
This is the devices mask." |
|
1241 |
||
1242 |
%{ /* NOCONTEXT */ |
|
1243 |
if (aButton == _MKSMALLINT(1)) { |
|
1244 |
RETURN (_MKSMALLINT(Button1MotionMask)); |
|
1245 |
} |
|
1246 |
if (aButton == _MKSMALLINT(2)) { |
|
1247 |
RETURN (_MKSMALLINT(Button2MotionMask)); |
|
1248 |
} |
|
1249 |
if (aButton == _MKSMALLINT(3)) { |
|
1250 |
RETURN (_MKSMALLINT(Button3MotionMask)); |
|
1251 |
} |
|
1252 |
%}. |
|
1253 |
^ nil |
|
1254 |
! |
|
1255 |
||
66 | 1256 |
button1MotionMask |
81 | 1257 |
"return the state-mask for button1 in motion events state-field. |
1258 |
For backward compatibility." |
|
1259 |
||
1260 |
%{ /* NOCONTEXT */ |
|
66 | 1261 |
RETURN (_MKSMALLINT(Button1MotionMask)); |
1262 |
%} |
|
1263 |
! |
|
1264 |
||
1265 |
button2MotionMask |
|
81 | 1266 |
"return the state-mask for button2 in motion events state-field |
1267 |
For backward compatibility." |
|
1268 |
||
1269 |
%{ /* NOCONTEXT */ |
|
66 | 1270 |
RETURN (_MKSMALLINT(Button2MotionMask)); |
1271 |
%} |
|
1272 |
! |
|
1273 |
||
1274 |
button3MotionMask |
|
81 | 1275 |
"return the state-mask for button3 in motion events state-field |
1276 |
For backward compatibility." |
|
1277 |
||
1278 |
%{ /* NOCONTEXT */ |
|
66 | 1279 |
RETURN (_MKSMALLINT(Button3MotionMask)); |
1280 |
%} |
|
1281 |
! |
|
1282 |
||
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1283 |
modifier1Mask |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1284 |
"return the Xlib mask bit for the 1st modifier key. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1285 |
See comment in altModifierMask: / metaModifierMask: for what |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1286 |
this could be used." |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1287 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1288 |
%{ /* NOCONTEXT */ |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1289 |
RETURN (_MKSMALLINT(Mod1Mask)); |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1290 |
%} |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1291 |
! |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1292 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1293 |
modifier2Mask |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1294 |
"return the Xlib mask bit for the 2nd modifier key. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1295 |
See comment in altModifierMask: / metaModifierMask: for what |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1296 |
this could be used." |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1297 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1298 |
%{ /* NOCONTEXT */ |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1299 |
RETURN (_MKSMALLINT(Mod2Mask)); |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1300 |
%} |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1301 |
! |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1302 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1303 |
altModifierMask:aSmallInteger |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1304 |
"define which key takes the role of an alt-key. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1305 |
By default, this is X's modifier1, which is the ALT key on |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1306 |
most keyboards. However, there may be exceptions to this, |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1307 |
and the setting can be changed with: |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1308 |
Display altModifierMask:(Display modifier2Mask) |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1309 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1310 |
" |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1311 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1312 |
altModifierMask := aSmallInteger |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1313 |
! |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1314 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1315 |
metaModifierMask:aSmallInteger |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1316 |
"define which key takes the role of a meta key. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1317 |
By default, this is X's modifier2, which is the 2nd ALT key on |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1318 |
most keyboards (if present at all). |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1319 |
However, there may be exceptions to this, and the setting can |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1320 |
be changed with: |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1321 |
Display metaModifierMask:(Display modifier1Mask) |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1322 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1323 |
As reported, some Xservers place the Meta-key onto NumLock, |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1324 |
and having NumLock enabled makes ST/X think, that meta is pressed |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1325 |
all the time. On those, you should disable the meta key by setting |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1326 |
the mask to 0. |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1327 |
" |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1328 |
|
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1329 |
metaModifierMask := aSmallInteger |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1330 |
! |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
1331 |
|
109 | 1332 |
defaultEventMask |
1333 |
"return a mask to enable some events by default." |
|
1334 |
||
1335 |
%{ /* NOCONTEXT */ |
|
1336 |
RETURN (_MKSMALLINT( ExposureMask | StructureNotifyMask | |
|
144 | 1337 |
KeyPressMask | KeyReleaseMask | |
150 | 1338 |
EnterWindowMask | LeaveWindowMask | |
115 | 1339 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
109 | 1340 |
%} |
1341 |
! |
|
1342 |
||
0 | 1343 |
viewIdFromPoint:aPoint in:windowId |
1344 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
96 | 1345 |
hit by this coordinate. Return nil if no view was hit. |
1346 |
The returned id may be the id of a non ST view. |
|
1347 |
- used to find the window to drop objects after a cross-view drag." |
|
0 | 1348 |
|
1349 |
%{ /* NOCONTEXT */ |
|
1350 |
||
1351 |
Display *dpy = myDpy; |
|
1352 |
int screen = _intVal(_INST(screen)); |
|
1353 |
OBJ xp, yp; |
|
1354 |
int xpos, ypos; |
|
1355 |
Window child_return; |
|
1356 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1357 |
if (__isExternalAddress(windowId) |
36 | 1358 |
&& __isPoint(aPoint)) { |
70 | 1359 |
xp = _point_X(aPoint); |
1360 |
yp = _point_Y(aPoint); |
|
97 | 1361 |
if (__bothSmallInteger(xp, yp)) { |
70 | 1362 |
BEGIN_INTERRUPTSBLOCKED |
1363 |
XTranslateCoordinates(dpy, |
|
1364 |
RootWindow(dpy, screen), |
|
1365 |
_WindowVal(windowId), |
|
1366 |
_intVal(xp), _intVal(yp), |
|
1367 |
&xpos, &ypos, &child_return); |
|
1368 |
END_INTERRUPTSBLOCKED |
|
1369 |
if (child_return) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1370 |
RETURN ( __MKOBJ(child_return) ); |
70 | 1371 |
} |
96 | 1372 |
RETURN ( nil ); |
70 | 1373 |
} |
0 | 1374 |
} |
96 | 1375 |
%}. |
225
de92f38623f6
viewIdFromPoint was broken with non-integer points
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
1376 |
windowId notNil ifTrue:[ |
de92f38623f6
viewIdFromPoint was broken with non-integer points
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
1377 |
aPoint isPoint ifTrue:[ |
de92f38623f6
viewIdFromPoint was broken with non-integer points
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
1378 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
de92f38623f6
viewIdFromPoint was broken with non-integer points
Claus Gittinger <cg@exept.de>
parents:
219
diff
changeset
|
1379 |
] |
96 | 1380 |
]. |
1381 |
||
0 | 1382 |
^ nil |
1383 |
! |
|
1384 |
||
1385 |
translatePoint:aPoint from:windowId1 to:windowId2 |
|
96 | 1386 |
"given a point in window1, return the coordinate in window2. |
1387 |
This expects a device coordinate (relative to the first views origin) |
|
1388 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
0 | 1389 |
- use to xlate points from a window to rootwindow" |
1390 |
||
1391 |
|x1 y1 x2 y2| |
|
1392 |
||
96 | 1393 |
x1 := x2 := aPoint x truncated. |
1394 |
y1 := y2 := aPoint y truncated. |
|
0 | 1395 |
%{ |
1396 |
int xpos, ypos; |
|
18 | 1397 |
Window w1, w2, child_return; |
1398 |
int screen = _intVal(_INST(screen)); |
|
1399 |
Display *dpy = myDpy; |
|
0 | 1400 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1401 |
if (__isExternalAddress(windowId1) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1402 |
&& __isExternalAddress(windowId2) |
97 | 1403 |
&& __bothSmallInteger(x1, y1)) { |
70 | 1404 |
w1 = _WindowVal(windowId1); |
1405 |
w2 = _WindowVal(windowId2); |
|
90 | 1406 |
#ifdef VIRTUAL_ROOT |
70 | 1407 |
if ((w1 == RootWindow(dpy, screen)) |
1408 |
|| (w2 == RootWindow(dpy, screen))) { |
|
1409 |
if (w1 == RootWindow(dpy, screen)) { |
|
1410 |
w1 = getRootWindow(dpy, screen); |
|
1411 |
} |
|
1412 |
if (w2 == RootWindow(dpy, screen)) { |
|
1413 |
w2 = getRootWindow(dpy, screen); |
|
1414 |
} |
|
1415 |
} |
|
18 | 1416 |
#endif |
70 | 1417 |
BEGIN_INTERRUPTSBLOCKED |
1418 |
XTranslateCoordinates(dpy, w1, w2, |
|
1419 |
_intVal(x1), _intVal(y1), |
|
1420 |
&xpos, &ypos, &child_return); |
|
1421 |
END_INTERRUPTSBLOCKED |
|
1422 |
x2 = _MKSMALLINT(xpos); |
|
1423 |
y2 = _MKSMALLINT(ypos); |
|
0 | 1424 |
} |
96 | 1425 |
%}. |
1426 |
||
0 | 1427 |
^ (x2 @ y2) |
135 | 1428 |
! |
1429 |
||
1430 |
rootView |
|
1431 |
rootView isNil ifTrue:[ |
|
1432 |
rootView := DisplayRootView on:self |
|
1433 |
]. |
|
1434 |
^ rootView |
|
1435 |
||
1436 |
" |
|
1437 |
|v| |
|
1438 |
v := Display rootView. |
|
1439 |
v paint:Color red. |
|
1440 |
v noClipByChildren. |
|
1441 |
v fillRectangleX:10 y:10 width:100 height:100. |
|
1442 |
" |
|
188 | 1443 |
! |
1444 |
||
1445 |
virtualExtent |
|
1446 |
"return the virtual extent of the display (in pixels). |
|
1447 |
On most systems, this is the same as the physical width; |
|
1448 |
except, if a window manager with a virtual desktop like olvwm |
|
1449 |
(simulating a bigger screen) is running." |
|
1450 |
||
1451 |
%{ |
|
1452 |
if ((_INST(rootId) != _INST(virtualRootId)) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1453 |
&& __isExternalAddress(_INST(virtualRootId))) { |
188 | 1454 |
Window vRootWin; |
1455 |
Window root; |
|
1456 |
int x, y; |
|
1457 |
unsigned int width, height; |
|
1458 |
unsigned int dummy; |
|
1459 |
extern OBJ __MKPOINT_INT(); |
|
1460 |
||
1461 |
vRootWin = _WindowVal(_INST(virtualRootId)); |
|
1462 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
1463 |
&dummy, &dummy)) { |
|
1464 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
1465 |
} |
|
1466 |
} |
|
1467 |
%}. |
|
1468 |
^ width @ height |
|
0 | 1469 |
! ! |
1470 |
||
1471 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1472 |
||
1473 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
|
1474 |
"create a new faxImage in the workstation |
|
1475 |
type: 0 -> uncompressed |
|
70 | 1476 |
1 -> group3 1D (k is void) |
1477 |
2 -> group3 2D |
|
1478 |
3 -> group4 2D (k is void)" |
|
0 | 1479 |
|
1480 |
|nBytes| |
|
1481 |
||
1482 |
hasFaxExtension ifFalse:[^ nil]. |
|
1483 |
nBytes := data size. |
|
1484 |
%{ |
|
1485 |
#ifdef FAX |
|
1486 |
Display *dpy = myDpy; |
|
1487 |
int screen = _intVal(_INST(screen)); |
|
1488 |
FAXImage newImage; |
|
1489 |
int _type, _msb, _k = 0; |
|
1490 |
unsigned char *bits; |
|
1491 |
||
97 | 1492 |
if (__bothSmallInteger(w, h) |
1493 |
&& __bothSmallInteger(type, k) |
|
1494 |
&& __isSmallInteger(nBytes) |
|
44 | 1495 |
&& __isByteArray(data)) { |
70 | 1496 |
if (msbFirst == true) |
1497 |
_msb = 1; |
|
1498 |
else |
|
1499 |
_msb = 0; |
|
1500 |
_type = _intVal(type); |
|
1501 |
if ((_type < 0) || (_type > 3)) { |
|
1502 |
RETURN ( nil ); |
|
1503 |
} |
|
1504 |
if (_type == 2) { |
|
97 | 1505 |
if (! __isSmallInteger(k)) { |
70 | 1506 |
RETURN ( nil ); |
1507 |
} |
|
1508 |
_k = _intVal(k); |
|
1509 |
} |
|
1510 |
bits = _ByteArrayInstPtr(data)->ba_element; |
|
1511 |
BEGIN_INTERRUPTSBLOCKED |
|
1512 |
newImage = XFAXImageCreateImage(dpy, _intVal(w), _intVal(h), |
|
1513 |
_type, _k, _msb, |
|
1514 |
_intVal(nBytes), bits); |
|
1515 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1516 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1517 |
} |
1518 |
#else |
|
1519 |
RETURN ( nil ); |
|
1520 |
#endif |
|
1521 |
%} |
|
1522 |
. |
|
43 | 1523 |
self primitiveFailed. |
1524 |
^ nil |
|
0 | 1525 |
! |
1526 |
||
1527 |
createBitmapWidth:w height:h |
|
1528 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1529 |
(i.e. random). Return a bitmap id or nil" |
|
1530 |
||
1531 |
%{ /* NOCONTEXT */ |
|
1532 |
||
1533 |
Display *dpy = myDpy; |
|
1534 |
int screen = _intVal(_INST(screen)); |
|
1535 |
Pixmap newBitmap; |
|
1536 |
||
150 | 1537 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1538 |
BEGIN_INTERRUPTSBLOCKED |
1539 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1540 |
_intVal(w), _intVal(h), 1); |
|
1541 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1542 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1543 |
} |
1544 |
%} |
|
1545 |
. |
|
43 | 1546 |
self primitiveFailed. |
1547 |
^ nil |
|
0 | 1548 |
! |
1549 |
||
1550 |
createPixmapWidth:w height:h depth:d |
|
1551 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1552 |
(i.e. random). Return a bitmap id or nil" |
|
1553 |
||
1554 |
%{ /* NOCONTEXT */ |
|
1555 |
||
1556 |
Display *dpy = myDpy; |
|
1557 |
int screen = _intVal(_INST(screen)); |
|
1558 |
Pixmap newBitmap; |
|
1559 |
||
150 | 1560 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1561 |
BEGIN_INTERRUPTSBLOCKED |
1562 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1563 |
_intVal(w), _intVal(h), _intVal(d)); |
|
1564 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1565 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1566 |
} |
1567 |
%} |
|
1568 |
. |
|
43 | 1569 |
self primitiveFailed. |
1570 |
^ nil |
|
0 | 1571 |
! |
1572 |
||
1573 |
createBitmapFromFile:aString for:aForm |
|
1574 |
|id w h| |
|
1575 |
||
1576 |
%{ |
|
1577 |
Display *dpy = myDpy; |
|
1578 |
int screen = _intVal(_INST(screen)); |
|
1579 |
Pixmap newBitmap; |
|
1580 |
char *filename; |
|
1581 |
unsigned b_width, b_height; |
|
1582 |
int b_x_hot, b_y_hot; |
|
1583 |
int status; |
|
1584 |
||
150 | 1585 |
if (ISCONNECTED) { |
1586 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1587 |
filename = (char *)_stringVal(aString); |
|
1588 |
||
1589 |
BEGIN_INTERRUPTSBLOCKED |
|
1590 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1591 |
filename, &b_width, &b_height, &newBitmap, |
|
1592 |
&b_x_hot, &b_y_hot); |
|
1593 |
END_INTERRUPTSBLOCKED |
|
1594 |
||
1595 |
if (status == BitmapSuccess) { |
|
1596 |
w = _MKSMALLINT(b_width); |
|
1597 |
h = _MKSMALLINT(b_height); |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1598 |
id = __MKOBJ(newBitmap); |
150 | 1599 |
} |
70 | 1600 |
} |
0 | 1601 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1602 |
%}. |
0 | 1603 |
id notNil ifTrue:[ |
90 | 1604 |
aForm setWidth:w height:h |
0 | 1605 |
]. |
1606 |
^ id |
|
1607 |
! |
|
1608 |
||
43 | 1609 |
primCreateBitmapFromArray:anArray width:w height:h |
1610 |
||
1611 |
%{ /* UNLIMITEDSTACK */ |
|
1612 |
||
0 | 1613 |
Display *dpy = myDpy; |
1614 |
int screen = _intVal(_INST(screen)); |
|
1615 |
Pixmap newBitmap; |
|
1616 |
unsigned int b_width, b_height; |
|
1617 |
REGISTER unsigned char *cp; |
|
1618 |
REGISTER unsigned char *pBits; |
|
43 | 1619 |
unsigned char *b_bits, *allocatedBits; |
0 | 1620 |
int index, row; |
1621 |
REGISTER int col; |
|
1622 |
unsigned bits; |
|
1623 |
static char reverseBitTable[256]; |
|
1624 |
static firstCall = 1; |
|
43 | 1625 |
int nBytes; |
1626 |
unsigned char fastBits[10000]; |
|
0 | 1627 |
OBJ num, *op; |
1628 |
int bytesPerRow; |
|
1629 |
||
1630 |
if (firstCall) { |
|
70 | 1631 |
for (index=0; index < 256; index++) { |
1632 |
reverseBitTable[index] = 0; |
|
1633 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1634 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1635 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1636 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1637 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1638 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1639 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1640 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1641 |
} |
|
1642 |
firstCall = 0; |
|
0 | 1643 |
} |
1644 |
||
97 | 1645 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
70 | 1646 |
b_width = _intVal(w); |
1647 |
b_height = _intVal(h); |
|
1648 |
bytesPerRow = (b_width + 7) / 8; |
|
1649 |
nBytes = b_height * bytesPerRow; |
|
1650 |
if (nBytes < sizeof(fastBits)) { |
|
1651 |
cp = b_bits = fastBits; |
|
1652 |
allocatedBits = 0; |
|
1653 |
} else { |
|
1654 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
96 | 1655 |
if (! cp) goto fail; |
70 | 1656 |
} |
200 | 1657 |
|
135 | 1658 |
if (__qClass(anArray) == Array) { |
70 | 1659 |
index = 1; |
1660 |
op = &(_ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1661 |
for (row = b_height; row; row--) { |
|
1662 |
for (col = bytesPerRow; col; col--) { |
|
1663 |
num = *op++; |
|
97 | 1664 |
if (! __isSmallInteger(num)) goto fail; |
70 | 1665 |
bits = _intVal(num); |
1666 |
*cp++ = reverseBitTable[bits]; |
|
1667 |
} |
|
1668 |
} |
|
1669 |
} else { |
|
135 | 1670 |
if (__qClass(anArray) == ByteArray) { |
70 | 1671 |
pBits = _ByteArrayInstPtr(anArray)->ba_element; |
1672 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1673 |
*cp++ = reverseBitTable[*pBits++]; |
|
1674 |
} |
|
1675 |
} else { |
|
1676 |
goto fail; |
|
1677 |
} |
|
1678 |
} |
|
1679 |
||
1680 |
BEGIN_INTERRUPTSBLOCKED |
|
1681 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1682 |
(char *)b_bits, |
|
1683 |
b_width, b_height); |
|
1684 |
END_INTERRUPTSBLOCKED |
|
43 | 1685 |
fail: ; |
70 | 1686 |
if (allocatedBits) |
1687 |
free(allocatedBits); |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1688 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
0 | 1689 |
} |
1690 |
%} |
|
43 | 1691 |
! |
1692 |
||
1693 |
createBitmapFromArray:anArray width:w height:h |
|
1694 |
|bitmapId| |
|
1695 |
||
1696 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1697 |
bitmapId isNil ifTrue:[ |
|
70 | 1698 |
self primitiveFailed |
43 | 1699 |
]. |
1700 |
^ bitmapId |
|
0 | 1701 |
! |
1702 |
||
1703 |
destroyPixmap:aDrawableId |
|
1704 |
||
1705 |
%{ /* NOCONTEXT */ |
|
1706 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1707 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 1708 |
BEGIN_INTERRUPTSBLOCKED |
1709 |
XFreePixmap(myDpy, _PixmapVal(aDrawableId)); |
|
1710 |
END_INTERRUPTSBLOCKED |
|
1711 |
RETURN ( self ); |
|
0 | 1712 |
} |
150 | 1713 |
%}. |
0 | 1714 |
self primitiveFailed |
1715 |
! |
|
1716 |
||
1717 |
destroyFaxImage:aFaxImageId |
|
1718 |
||
1719 |
%{ /* NOCONTEXT */ |
|
1720 |
||
1721 |
#ifdef FAX |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1722 |
if (__isExternalAddress(aFaxImageId)) { |
70 | 1723 |
BEGIN_INTERRUPTSBLOCKED |
1724 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
|
1725 |
END_INTERRUPTSBLOCKED |
|
1726 |
RETURN ( self ); |
|
0 | 1727 |
} |
1728 |
#endif |
|
150 | 1729 |
%}. |
0 | 1730 |
self primitiveFailed |
1731 |
! |
|
1732 |
||
150 | 1733 |
realRootWindowId |
1734 |
"return the id of the real root window. |
|
1735 |
This may not be the window you see as background, |
|
1736 |
since some window managers install a virtual root window on top |
|
1737 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1738 |
care of any virtual root." |
|
1739 |
||
132 | 1740 |
%{ /* NOCONTEXT */ |
150 | 1741 |
|
90 | 1742 |
int screen = _intVal(_INST(screen)); |
1743 |
Window root; |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1744 |
OBJ id; |
90 | 1745 |
|
150 | 1746 |
if (_INST(rootId) != nil) { |
1747 |
RETURN (_INST(rootId)); |
|
1748 |
} |
|
1749 |
||
1750 |
if (ISCONNECTED) { |
|
1751 |
root = RootWindow(myDpy, screen); |
|
1752 |
if (! root) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1753 |
id = nil; |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1754 |
} else { |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1755 |
_INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
150 | 1756 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1757 |
RETURN (id); |
150 | 1758 |
} |
1759 |
%}. |
|
1760 |
self primitiveFailed |
|
1761 |
! |
|
1762 |
||
1763 |
rootWindowId |
|
1764 |
"return the id of the root window. |
|
1765 |
This is the window you see as background, |
|
1766 |
however, it may or may not be the real physical root window, |
|
1767 |
since some window managers install a virtual root window on top |
|
1768 |
of the real one. If this is the case, that views id is returned here." |
|
1769 |
||
1770 |
%{ /* NOCONTEXT */ |
|
0 | 1771 |
int screen = _intVal(_INST(screen)); |
150 | 1772 |
Window rootWin, vRootWin; |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1773 |
OBJ id; |
150 | 1774 |
|
1775 |
if (_INST(virtualRootId) != nil) { |
|
1776 |
RETURN (_INST(virtualRootId)); |
|
1777 |
} |
|
1778 |
||
1779 |
if (ISCONNECTED) { |
|
1780 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
|
1781 |
#ifndef IRIS |
|
70 | 1782 |
BEGIN_INTERRUPTSBLOCKED |
1783 |
/* |
|
1784 |
* on IRIS, this creates a badwindow error - why ? |
|
1785 |
* children contains a funny window (000034) |
|
1786 |
*/ |
|
1787 |
||
1788 |
/* |
|
1789 |
* care for virtual root windows (tvtwm & friends) |
|
1790 |
*/ |
|
1791 |
{ |
|
1792 |
Atom vRootAtom = None; |
|
1793 |
int i; |
|
1794 |
Window rootReturn, parentReturn; |
|
1795 |
Window* children; |
|
1796 |
unsigned int numChildren; |
|
1797 |
||
150 | 1798 |
if (XQueryTree(myDpy, rootWin, |
70 | 1799 |
&rootReturn, &parentReturn, |
1800 |
&children, &numChildren)) { |
|
1801 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1802 |
if (vRootAtom != None) { |
|
1803 |
for (i=0; i < numChildren; i++) { |
|
1804 |
Atom actual_type; |
|
1805 |
int actual_format; |
|
1806 |
unsigned long nitems, bytesafter; |
|
1807 |
Window* newRoot = (Window*) 0; |
|
1808 |
||
1809 |
if (children[i]) { |
|
1810 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1811 |
0L, 1L, False, XA_WINDOW, |
|
1812 |
&actual_type, &actual_format, |
|
1813 |
&nitems, &bytesafter, |
|
1814 |
(unsigned char**) &newRoot |
|
1815 |
) == Success && newRoot) { |
|
150 | 1816 |
vRootWin = *newRoot; |
70 | 1817 |
break; |
1818 |
} |
|
1819 |
} |
|
1820 |
} |
|
1821 |
if (children) XFree( children ); |
|
1822 |
} |
|
1823 |
} |
|
1824 |
} |
|
150 | 1825 |
END_INTERRUPTSBLOCKED |
70 | 1826 |
#endif |
150 | 1827 |
} |
1828 |
||
1829 |
/* cannot happen */ |
|
1830 |
if (! vRootWin) { |
|
1831 |
vRootWin = rootWin; |
|
1832 |
if (! rootWin) { |
|
1833 |
RETURN ( nil ); |
|
1834 |
} |
|
1835 |
} |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1836 |
_INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1837 |
_INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1838 |
RETURN ( id ); |
0 | 1839 |
%} |
150 | 1840 |
! |
1841 |
||
1842 |
realRootWindowFor:aView |
|
1843 |
"the name of this method is historic; |
|
1844 |
- it will vanish" |
|
1845 |
||
1846 |
|id| |
|
1847 |
||
1848 |
id := self realRootWindowId. |
|
1849 |
self addKnownView:aView withId:id. |
|
1850 |
^ id |
|
1851 |
! |
|
1852 |
||
1853 |
rootWindowFor:aView |
|
1854 |
|id| |
|
1855 |
||
1856 |
id := self rootWindowId. |
|
0 | 1857 |
self addKnownView:aView withId:id. |
1858 |
^ id |
|
1859 |
! |
|
1860 |
||
1861 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1862 |
"will vanish - for compatibility with previous versions" |
1863 |
||
1864 |
^ self |
|
70 | 1865 |
createWindowFor:aView |
1866 |
origin:(xpos @ ypos) |
|
1867 |
extent:(wwidth @ wheight) |
|
1868 |
minExtent:(aView minExtent) |
|
1869 |
maxExtent:(aView maxExtent) |
|
1870 |
borderWidth:(aView borderWidth) |
|
1871 |
subViewOf:(aView superView) |
|
157 | 1872 |
onTop:(aView isPopUpView) |
70 | 1873 |
inputOnly:(aView inputOnly) |
1874 |
label:(aView label) |
|
1875 |
cursor:(aView cursor) |
|
1876 |
icon:(aView icon) |
|
1877 |
iconView:(aView iconView) |
|
46 | 1878 |
! |
1879 |
||
1880 |
createWindowFor:aView |
|
70 | 1881 |
origin:origin |
1882 |
extent:extent |
|
1883 |
minExtent:minExt |
|
1884 |
maxExtent:maxExt |
|
1885 |
borderWidth:bWidth |
|
1886 |
subViewOf:wsuperView |
|
157 | 1887 |
onTop:wisPopUpView |
70 | 1888 |
inputOnly:winputOnly |
1889 |
label:wlabel |
|
1890 |
cursor:wcursor |
|
1891 |
icon:wicon |
|
1892 |
iconView:wiconView |
|
46 | 1893 |
|
1894 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1895 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1896 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1897 |
vBgForm deepForm preferredVisual preferredDepth| |
1898 |
||
1899 |
displayId isNil ifTrue:[ |
|
1900 |
self primitiveFailed. |
|
1901 |
^ nil |
|
1902 |
]. |
|
0 | 1903 |
|
46 | 1904 |
origin notNil ifTrue:[ |
70 | 1905 |
xpos := origin x. |
1906 |
ypos := origin y. |
|
46 | 1907 |
] ifFalse:[ |
70 | 1908 |
xpos := ypos := 0. |
0 | 1909 |
]. |
46 | 1910 |
extent notNil ifTrue:[ |
70 | 1911 |
wwidth := extent x. |
1912 |
wheight := extent y. |
|
46 | 1913 |
] ifFalse:[ |
70 | 1914 |
wwidth := wheight := 100. |
46 | 1915 |
]. |
1916 |
minExt notNil ifTrue:[ |
|
70 | 1917 |
minWidth := minExt x. |
1918 |
minHeight := minExt y |
|
0 | 1919 |
]. |
46 | 1920 |
maxExt notNil ifTrue:[ |
70 | 1921 |
maxWidth := maxExt x. |
1922 |
maxHeight := maxExt y |
|
46 | 1923 |
]. |
1924 |
||
0 | 1925 |
wsuperView notNil ifTrue:[ |
70 | 1926 |
wsuperViewId := wsuperView id |
0 | 1927 |
]. |
1928 |
wcursor isNil ifTrue:[ |
|
145 | 1929 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1930 |
] ifFalse:[ |
70 | 1931 |
wcursorId := wcursor id |
0 | 1932 |
]. |
1933 |
||
1934 |
wicon notNil ifTrue:[ |
|
70 | 1935 |
wiconId := wicon id |
0 | 1936 |
]. |
1937 |
wiconView notNil ifTrue:[ |
|
70 | 1938 |
wiconViewId := wiconView id |
0 | 1939 |
]. |
1940 |
weventMask := aView eventMask. |
|
1941 |
||
150 | 1942 |
preferredVisual := aView preferredVisual. |
1943 |
preferredDepth := aView preferredDepth. |
|
23 | 1944 |
|
72 | 1945 |
%{ /* STACK:16000 */ |
0 | 1946 |
Display *dpy = myDpy; |
1947 |
int screen = _intVal(_INST(screen)); |
|
1948 |
Visual visual; |
|
1949 |
XGCValues xgcv; |
|
1950 |
XSetWindowAttributes xswa; |
|
1951 |
XSizeHints sizehints; |
|
1952 |
XWMHints wmhints; |
|
46 | 1953 |
int bw, bd, bg; |
0 | 1954 |
Window newWindow, parentWindow; |
1955 |
char *windowName; |
|
1956 |
XFontStruct *f; |
|
1957 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1958 |
int flags = 0, depth, ioClass; |
|
1959 |
extern OBJ Rectangle, Form; |
|
1960 |
Window iconWindow; |
|
1961 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1962 |
Atom WmQuitAppAtom; |
|
1963 |
Atom atoms[3]; |
|
1964 |
int atomCount = 0, isTopWindow = 0; |
|
1965 |
||
1966 |
sizehints.flags = 0; |
|
1967 |
sizehints.width = 100; |
|
1968 |
sizehints.height = 100; |
|
1969 |
sizehints.x = 0; |
|
1970 |
sizehints.y = 0; |
|
1971 |
||
97 | 1972 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1973 |
sizehints.flags |= PSize; |
1974 |
sizehints.width = _intVal(wwidth); |
|
1975 |
sizehints.height = _intVal(wheight); |
|
0 | 1976 |
} |
97 | 1977 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1978 |
sizehints.flags |= PPosition; |
1979 |
sizehints.x = _intVal(xpos); |
|
1980 |
sizehints.y = _intVal(ypos); |
|
0 | 1981 |
} |
97 | 1982 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1983 |
sizehints.flags |= PMinSize; |
1984 |
sizehints.min_width = _intVal(minWidth); |
|
1985 |
sizehints.min_height = _intVal(minHeight); |
|
0 | 1986 |
} |
97 | 1987 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1988 |
sizehints.flags |= PMaxSize; |
1989 |
sizehints.max_width = _intVal(maxWidth); |
|
1990 |
sizehints.max_height = _intVal(maxHeight); |
|
0 | 1991 |
} |
1992 |
||
37 | 1993 |
bg = WhitePixel(dpy, screen); |
0 | 1994 |
|
97 | 1995 |
if (__isSmallInteger(bWidth)) { |
70 | 1996 |
bw = _intVal(bWidth); |
46 | 1997 |
} else { |
70 | 1998 |
bw = 0; |
0 | 1999 |
} |
2000 |
||
72 | 2001 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2002 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2003 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 2004 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 2005 |
} else { |
70 | 2006 |
parentWindow = RootWindow(dpy, screen); |
2007 |
isTopWindow = 1; |
|
0 | 2008 |
} |
2009 |
||
157 | 2010 |
if (wisPopUpView == true) |
70 | 2011 |
xswa.override_redirect = 1; |
0 | 2012 |
else |
70 | 2013 |
xswa.override_redirect = 0; |
0 | 2014 |
|
2015 |
if (winputOnly == true) |
|
70 | 2016 |
ioClass = InputOnly; |
0 | 2017 |
else |
70 | 2018 |
ioClass = InputOutput; |
0 | 2019 |
|
97 | 2020 |
if (__isSmallInteger(weventMask)) { |
70 | 2021 |
xswa.event_mask = _intVal(weventMask); |
0 | 2022 |
} else { |
70 | 2023 |
xswa.event_mask = 0; |
0 | 2024 |
} |
2025 |
||
2026 |
if (ioClass == InputOnly) { |
|
70 | 2027 |
bw = 0; |
2028 |
depth = 0; |
|
2029 |
flags |= CWEventMask; |
|
0 | 2030 |
} else { |
70 | 2031 |
depth = DefaultDepth(dpy,screen); |
2032 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
2033 |
||
2034 |
if (backPixmap != (Pixmap)0) { |
|
2035 |
xswa.background_pixmap = backPixmap; |
|
2036 |
flags |= CWBackPixmap; |
|
2037 |
} else { |
|
2038 |
xswa.background_pixel = bg; |
|
2039 |
flags |= CWBackPixel; |
|
2040 |
} |
|
2041 |
xswa.border_pixel = bd; |
|
0 | 2042 |
} |
23 | 2043 |
|
0 | 2044 |
visual.visualid = CopyFromParent; |
150 | 2045 |
if (__isSmallInteger(preferredDepth)) { |
2046 |
depth = _intVal(preferredDepth); |
|
23 | 2047 |
} |
54 | 2048 |
|
2049 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 2050 |
if (preferredVisual != nil) { |
70 | 2051 |
XVisualInfo vi; |
2052 |
int cls; |
|
2053 |
||
150 | 2054 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 2055 |
cls = StaticGray; |
150 | 2056 |
else if (preferredVisual == @symbol(GrayScale)) |
70 | 2057 |
cls = StaticGray; |
150 | 2058 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 2059 |
cls = StaticColor; |
150 | 2060 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 2061 |
cls = PseudoColor; |
150 | 2062 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 2063 |
cls = TrueColor; |
150 | 2064 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 2065 |
cls = DirectColor; |
2066 |
else |
|
2067 |
cls = PseudoColor; |
|
200 | 2068 |
|
70 | 2069 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
2070 |
visual.visualid = vi.visualid; |
|
163 | 2071 |
/* |
2072 |
printf("visualId=%x\n", vi.visualid); |
|
2073 |
*/ |
|
70 | 2074 |
} |
23 | 2075 |
} |
0 | 2076 |
|
2077 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 2078 |
sizehints.x, sizehints.y, |
2079 |
sizehints.width, sizehints.height, |
|
2080 |
bw, depth, ioClass, &visual, |
|
2081 |
flags, &xswa); |
|
54 | 2082 |
END_INTERRUPTSBLOCKED |
0 | 2083 |
|
2084 |
if (! newWindow) { |
|
70 | 2085 |
RETURN ( nil ); |
0 | 2086 |
} |
2087 |
||
54 | 2088 |
BEGIN_INTERRUPTSBLOCKED |
0 | 2089 |
/* |
2090 |
* define its cursor |
|
2091 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2092 |
if (__isExternalAddress(wcursorId)) { |
70 | 2093 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 2094 |
} |
2095 |
||
2096 |
/* |
|
2097 |
* define its icon and name |
|
2098 |
* (only makes sense for topWindows) |
|
2099 |
*/ |
|
2100 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2101 |
if (__isExternalAddress(wiconId)) |
70 | 2102 |
iconBitmap = _PixmapVal(wiconId); |
2103 |
else |
|
2104 |
iconBitmap = (Pixmap)0; |
|
2105 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2106 |
if (__isExternalAddress(wiconViewId)) |
70 | 2107 |
iconWindow = _WindowVal(wiconViewId); |
2108 |
else |
|
2109 |
iconWindow = (Window)0; |
|
2110 |
||
2111 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
2112 |
windowName = (char *)_stringVal(wlabel); |
|
2113 |
else |
|
2114 |
windowName = ""; |
|
2115 |
||
2116 |
if (iconBitmap || windowName) { |
|
2117 |
XSetStandardProperties(dpy, newWindow, |
|
2118 |
windowName, windowName, |
|
2119 |
iconBitmap, |
|
2120 |
0, 0, &sizehints); |
|
2121 |
||
2122 |
} |
|
2123 |
||
2124 |
wmhints.flags = 0; |
|
2125 |
if (iconBitmap) { |
|
2126 |
wmhints.flags |= IconPixmapHint; |
|
2127 |
wmhints.icon_pixmap = iconBitmap; |
|
2128 |
} |
|
2129 |
if (iconWindow) { |
|
2130 |
wmhints.flags |= IconWindowHint; |
|
2131 |
wmhints.icon_window = iconWindow; |
|
2132 |
} |
|
0 | 2133 |
/* |
70 | 2134 |
wmhints.flags |= InputHint; |
2135 |
wmhints.input = True; |
|
0 | 2136 |
*/ |
70 | 2137 |
XSetWMHints(dpy, newWindow, &wmhints); |
2138 |
||
2139 |
/* |
|
2140 |
* tell window manager to not kill us but send an event instead |
|
2141 |
*/ |
|
2142 |
/* |
|
2143 |
* get atoms first (if not already known) |
|
2144 |
*/ |
|
2145 |
if (_INST(protocolsAtom) == nil) { |
|
2146 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2147 |
_INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 2148 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 2149 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2150 |
_INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 2151 |
#endif |
2152 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 2153 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2154 |
_INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 2155 |
#endif |
70 | 2156 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2157 |
_INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 2158 |
} else { |
0 | 2159 |
#ifdef USE_QUIT_APP_ATOM |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2160 |
WmQuitAppAtom = _AtomVal(_INST(quitAppAtom)); |
0 | 2161 |
#else |
70 | 2162 |
WmQuitAppAtom = 0; |
0 | 2163 |
#endif |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2164 |
WmProtocolsAtom = _AtomVal(_INST(protocolsAtom)); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2165 |
WmDeleteWindowAtom = _AtomVal(_INST(deleteWindowAtom)); |
0 | 2166 |
#ifdef USE_SAVEYOURSELF_ATOM |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2167 |
WmSaveYourselfAtom = _AtomVal(_INST(saveYourselfAtom)); |
0 | 2168 |
#else |
70 | 2169 |
WmSaveYourselfAtom = 0; |
0 | 2170 |
#endif |
70 | 2171 |
} |
2172 |
||
2173 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 2174 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 2175 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 2176 |
#endif |
2177 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 2178 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 2179 |
#endif |
70 | 2180 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
2181 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 2182 |
} |
2183 |
||
54 | 2184 |
END_INTERRUPTSBLOCKED |
2185 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2186 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2187 |
%}. |
0 | 2188 |
self addKnownView:aView withId:windowId. |
2189 |
^ windowId |
|
2190 |
! |
|
2191 |
||
2192 |
destroyView:aView withId:aWindowId |
|
2193 |
%{ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2194 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
70 | 2195 |
BEGIN_INTERRUPTSBLOCKED |
2196 |
XDestroyWindow(myDpy, _WindowVal(aWindowId)); |
|
2197 |
END_INTERRUPTSBLOCKED |
|
0 | 2198 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2199 |
%}. |
0 | 2200 |
self removeKnownView:aView |
2201 |
! |
|
2202 |
||
2203 |
destroyGC:aGCId |
|
2204 |
||
2205 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2206 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
70 | 2207 |
BEGIN_INTERRUPTSBLOCKED |
2208 |
XFreeGC(myDpy, _GCVal(aGCId)); |
|
2209 |
END_INTERRUPTSBLOCKED |
|
2210 |
RETURN ( self ); |
|
0 | 2211 |
} |
118 | 2212 |
%}. |
0 | 2213 |
self primitiveFailed |
2214 |
! |
|
2215 |
||
2216 |
gcFor:aDrawableId |
|
2217 |
||
2218 |
%{ /* NOCONTEXT */ |
|
2219 |
int screen = _intVal(_INST(screen)); |
|
2220 |
GC gc; |
|
2221 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2222 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 2223 |
BEGIN_INTERRUPTSBLOCKED |
2224 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
2225 |
0L, (XGCValues *)0); |
|
2226 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2227 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
0 | 2228 |
} |
118 | 2229 |
%}. |
43 | 2230 |
self primitiveFailed. |
2231 |
^ nil |
|
0 | 2232 |
! |
2233 |
||
2234 |
dpsContextFor:aDrawableId and:aGCId |
|
2235 |
||
2236 |
%{ /* NOCONTEXT */ |
|
2237 |
#ifdef XXDPS |
|
2238 |
int screen = _intVal(_INST(screen)); |
|
2239 |
DPSContext dps; |
|
2240 |
int height; |
|
2241 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2242 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2243 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2244 |
&& ISCONNECTED) { |
70 | 2245 |
BEGIN_INTERRUPTSBLOCKED |
2246 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
2247 |
_GCVal(aGCId), |
|
2248 |
0, height, 0, colormap, NULL, 0, |
|
2249 |
XDPSDefaultTextBackstop, |
|
2250 |
XDPSDefaultErrorProc, |
|
2251 |
NULL); |
|
2252 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2253 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 2254 |
} |
2255 |
#endif |
|
2256 |
%} |
|
2257 |
. |
|
43 | 2258 |
self primitiveFailed. |
2259 |
^ nil |
|
0 | 2260 |
! ! |
2261 |
||
2262 |
!XWorkstation methodsFor:'resources'! |
|
2263 |
||
2264 |
getResource:name class:cls |
|
2265 |
%{ |
|
2266 |
char *rslt; |
|
2267 |
||
36 | 2268 |
if ((__isString(name) || __isSymbol(name)) |
150 | 2269 |
&& (__isString(cls) || __isSymbol(cls)) |
2270 |
&& ISCONNECTED) { |
|
70 | 2271 |
BEGIN_INTERRUPTSBLOCKED |
2272 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
2273 |
(char *)_stringVal(name)); |
|
2274 |
END_INTERRUPTSBLOCKED |
|
216 | 2275 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
0 | 2276 |
} |
2277 |
%} |
|
2278 |
. |
|
43 | 2279 |
self primitiveFailed. |
2280 |
^ nil |
|
0 | 2281 |
! ! |
2282 |
||
90 | 2283 |
!XWorkstation methodsFor:'selections'! |
2284 |
||
2285 |
setTextProperty:propertyID value:aString for:aWindowID |
|
132 | 2286 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
2287 |
! |
|
2288 |
||
2289 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
2290 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
90 | 2291 |
! |
2292 |
||
2293 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
2294 |
|s| |
|
2295 |
||
2296 |
(anObject isMemberOf:String) ifTrue:[ |
|
2297 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
2298 |
]. |
|
2299 |
s := WriteStream on:(ByteArray new:200). |
|
2300 |
anObject storeBinaryOn:s. |
|
129 | 2301 |
^ self |
2302 |
setProperty:propertyID |
|
2303 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
2304 |
value:(s contents) |
|
2305 |
for:aWindowID |
|
90 | 2306 |
! |
2307 |
||
2308 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
132 | 2309 |
|
215
4b9bebf59812
oops - XSetProperty may need huge amounts of stack (contains alloca);
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
2310 |
%{ /* UNLIMITEDSTACK */ |
4b9bebf59812
oops - XSetProperty may need huge amounts of stack (contains alloca);
Claus Gittinger <cg@exept.de>
parents:
212
diff
changeset
|
2311 |
|
90 | 2312 |
Display *dpy = myDpy; |
2313 |
Atom prop, type; |
|
2314 |
Window window; |
|
132 | 2315 |
unsigned int value; |
90 | 2316 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2317 |
if (__isAtomID(propertyID) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2318 |
&& __isAtomID(typeID) |
150 | 2319 |
&& ISCONNECTED |
90 | 2320 |
&& (__isString(anObject) |
132 | 2321 |
|| __isSmallInteger(anObject) |
90 | 2322 |
|| __isSymbol(anObject) |
2323 |
|| __isByteArray(anObject))) { |
|
2324 |
||
2325 |
prop = _AtomVal(propertyID); |
|
2326 |
type = _AtomVal(typeID); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2327 |
if (__isExternalAddress(aWindowID)) { |
90 | 2328 |
window = _WindowVal(aWindowID); |
2329 |
} else { |
|
2330 |
window = DefaultRootWindow(dpy); |
|
2331 |
} |
|
132 | 2332 |
if (__isSmallInteger(anObject)) { |
2333 |
value = _intVal(anObject); |
|
2334 |
XChangeProperty(dpy, window, prop, type, 32, |
|
90 | 2335 |
PropModeReplace, |
132 | 2336 |
(unsigned char *)(&value), sizeof(unsigned int)); |
90 | 2337 |
} else { |
132 | 2338 |
if (__isByteArray(anObject)) { |
133 | 2339 |
XChangeProperty(dpy, window, prop, type, 8, |
2340 |
PropModeReplace, |
|
2341 |
_ByteArrayInstPtr(anObject)->ba_element, |
|
2342 |
_byteArraySize(anObject)); |
|
132 | 2343 |
} else { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2344 |
/* string or symbol */ |
133 | 2345 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
2346 |
PropModeReplace, |
|
2347 |
_stringVal(anObject), |
|
2348 |
strlen(_stringVal(anObject))); |
|
132 | 2349 |
} |
90 | 2350 |
} |
2351 |
RETURN (true); |
|
2352 |
} |
|
2353 |
%}. |
|
2354 |
^ false |
|
2355 |
! |
|
2356 |
||
2357 |
getTextProperty:propertyID from:aWindowID |
|
129 | 2358 |
"get a text property; return string or nil" |
2359 |
||
90 | 2360 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
129 | 2361 |
type == stringAtom ifTrue:[ |
90 | 2362 |
^ value |
2363 |
] |
|
2364 |
]. |
|
2365 |
^ nil |
|
2366 |
! |
|
2367 |
||
2368 |
getObjectProperty:propertyID from:aWindowID |
|
129 | 2369 |
"get an object property; return object or nil" |
200 | 2370 |
|
90 | 2371 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
129 | 2372 |
type == stringAtom ifTrue:[ |
90 | 2373 |
^ value |
2374 |
]. |
|
2375 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
2376 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
2377 |
] |
|
2378 |
]. |
|
2379 |
^ nil |
|
2380 |
! |
|
2381 |
||
2382 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
129 | 2383 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
2384 |
||
90 | 2385 |
|val typeID cls| |
2386 |
||
2387 |
cls := ByteArray. |
|
2388 |
%{ |
|
2389 |
Display *dpy = myDpy; |
|
2390 |
Window window; |
|
2391 |
Atom property; |
|
2392 |
char *cp, *cp2; |
|
2393 |
Atom actual_type; |
|
2394 |
int actual_format,i; |
|
2395 |
unsigned long nitems, bytes_after, nread; |
|
2396 |
unsigned char *data; |
|
2397 |
int ok = 1; |
|
217 | 2398 |
OBJ __new(), __MKSTRING_L(); |
90 | 2399 |
# define PROP_SIZE 2048 |
200 | 2400 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2401 |
if (__isAtomID(propertyID)) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2402 |
property = _AtomVal(propertyID); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2403 |
if (__isExternalAddress(aWindowID)) { |
90 | 2404 |
window = _WindowVal(aWindowID); |
2405 |
} else { |
|
2406 |
window = DefaultRootWindow(dpy); |
|
2407 |
} |
|
2408 |
||
2409 |
nread = 0; |
|
2410 |
cp = 0; |
|
2411 |
/* |
|
2412 |
fprintf(stderr, "getProperty: "); |
|
2413 |
*/ |
|
2414 |
do { |
|
2415 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
2416 |
AnyPropertyType,&actual_type,&actual_format, |
|
2417 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
2418 |
!= Success) { |
|
2419 |
ok = 0; |
|
2420 |
break; |
|
2421 |
} |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2422 |
typeID = __MKATOMOBJ(actual_type); |
90 | 2423 |
if (! cp) { |
2424 |
cp = cp2 = (char *)malloc(nitems+1); |
|
2425 |
} else { |
|
2426 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
2427 |
cp2 = cp + nread; |
|
2428 |
} |
|
96 | 2429 |
if (! cp) goto fail; |
2430 |
||
90 | 2431 |
nread += nitems; |
2432 |
bcopy(data, cp2, nitems); |
|
2433 |
XFree(data); |
|
2434 |
/* |
|
2435 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
2436 |
*/ |
|
2437 |
} while (bytes_after > 0); |
|
2438 |
/* |
|
2439 |
fprintf(stderr, "\n"); |
|
2440 |
*/ |
|
2441 |
||
2442 |
if (ok) { |
|
2443 |
if (actual_type == XA_STRING) { |
|
2444 |
cp[nread] = '\0'; |
|
216 | 2445 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
90 | 2446 |
} else { |
158 | 2447 |
val = __new(nread + OHDR_SIZE); |
90 | 2448 |
val->o_class = cls; |
2449 |
bcopy(cp, _ByteArrayInstPtr(val)->ba_element, nread); |
|
2450 |
} |
|
2451 |
} |
|
2452 |
if (cp) |
|
2453 |
free(cp); |
|
2454 |
} |
|
96 | 2455 |
fail: ; |
90 | 2456 |
%}. |
2457 |
typeID isNil ifTrue:[ |
|
2458 |
^ false |
|
2459 |
]. |
|
2460 |
aTwoArgBlock value:typeID value:val. |
|
2461 |
^ true |
|
2462 |
! |
|
2463 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2464 |
getSelectionOwnerOf:selectionAtomID |
129 | 2465 |
"get the owner of a selection" |
132 | 2466 |
|
2467 |
%{ /* NOCONTEXT */ |
|
90 | 2468 |
Display *dpy = myDpy; |
2469 |
Atom selection; |
|
2470 |
Window window; |
|
2471 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2472 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2473 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2474 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
90 | 2475 |
} |
2476 |
%}. |
|
2477 |
self primitiveFailed. |
|
2478 |
^ nil |
|
2479 |
! |
|
2480 |
||
2481 |
setSelectionOwner:aWindowId of:selectionID |
|
129 | 2482 |
"set the owner of a selection; return false if failed" |
132 | 2483 |
|
2484 |
%{ /* NOCONTEXT */ |
|
90 | 2485 |
Display *dpy = myDpy; |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2486 |
Window win; |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2487 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2488 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2489 |
&& __isAtomID(selectionID) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2490 |
&& ISCONNECTED) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2491 |
win = _WindowVal(aWindowId); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2492 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2493 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
90 | 2494 |
RETURN (false); |
2495 |
} |
|
2496 |
RETURN (true); |
|
2497 |
} |
|
2498 |
%} |
|
2499 |
. |
|
2500 |
self primitiveFailed. |
|
2501 |
^ nil |
|
2502 |
! |
|
2503 |
||
2504 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
2505 |
"ask the server to send us the selection - the view with ID aWindowID |
|
2506 |
will later receive a SelectionNotify event for it." |
|
2507 |
||
2508 |
^ self requestSelection:selectionID |
|
2509 |
property:propertyID |
|
129 | 2510 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
90 | 2511 |
for:aWindowId |
2512 |
! |
|
2513 |
||
2514 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
2515 |
"ask the server to send us the selection - the view with ID aWindowID |
|
2516 |
will later receive a SelectionNotify event for it." |
|
2517 |
||
2518 |
^ self requestSelection:selectionID |
|
2519 |
property:propertyID |
|
129 | 2520 |
type:stringAtom |
90 | 2521 |
for:aWindowId |
2522 |
! |
|
2523 |
||
2524 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2525 |
"ask the server to send us the selection - the view with id aWindowID |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2526 |
will later receive a SelectionNotify event for it (once the Xserver replies |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2527 |
with the selections value)." |
132 | 2528 |
|
2529 |
%{ /* NOCONTEXT */ |
|
90 | 2530 |
Display *dpy = myDpy; |
2531 |
Atom sel_prop; |
|
2532 |
char *cp; |
|
2533 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2534 |
if (__isExternalAddress(aWindowId) |
150 | 2535 |
&& ISCONNECTED |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2536 |
&& __isSmallInteger(typeID) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2537 |
&& __isAtomID(selectionID)) { |
90 | 2538 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
2539 |
/* |
|
2540 |
* no owner of primary selection |
|
2541 |
*/ |
|
2542 |
RETURN (false); |
|
2543 |
} |
|
2544 |
/* |
|
2545 |
* PRIMARY selection |
|
2546 |
*/ |
|
2547 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
2548 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
2549 |
RETURN (true); |
|
2550 |
} |
|
2551 |
%}. |
|
2552 |
self primitiveFailed. |
|
2553 |
^ false |
|
2554 |
||
2555 |
" |
|
2556 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
2557 |
property:(Display atomIDOf:'VT_SELECTION') |
|
2558 |
for:0 |
|
2559 |
" |
|
2560 |
! |
|
2561 |
||
129 | 2562 |
atomIDOfPRIMARY |
2563 |
^ primaryAtom |
|
2564 |
! |
|
2565 |
||
2566 |
atomIDOfSECONDARY |
|
2567 |
^ secondaryAtom |
|
2568 |
! |
|
2569 |
||
2570 |
atomIDOfSTRING |
|
2571 |
^ stringAtom |
|
2572 |
! |
|
2573 |
||
132 | 2574 |
atomIDOfLENGTH |
2575 |
^ lengthAtom |
|
2576 |
! |
|
2577 |
||
2578 |
atomIDOfCUTBUFFER0 |
|
2579 |
^ cutBuffer0Atom |
|
2580 |
! |
|
2581 |
||
90 | 2582 |
atomIDOf:aStringOrSymbol |
129 | 2583 |
"return an Atoms ID; dont create if not already present" |
2584 |
||
90 | 2585 |
^ self atomIDOf:aStringOrSymbol create:false |
2586 |
! |
|
2587 |
||
2588 |
atomIDOf:aStringOrSymbol create:create |
|
129 | 2589 |
"return an Atoms ID; if create is true, create it if not already present" |
2590 |
||
90 | 2591 |
%{ /* NOCONTEXT */ |
2592 |
Atom prop; |
|
2593 |
||
150 | 2594 |
if (ISCONNECTED) { |
2595 |
if (__isString(aStringOrSymbol) |
|
2596 |
|| __isSymbol(aStringOrSymbol)) { |
|
2597 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
2598 |
(create == true) ? False : True); |
|
2599 |
if (prop == None) { |
|
2600 |
RETURN (nil); |
|
2601 |
} |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
2602 |
RETURN ( __MKATOMOBJ(prop) ); |
90 | 2603 |
} |
2604 |
} |
|
2605 |
%}. |
|
2606 |
self primitiveFailed. |
|
2607 |
^ nil |
|
2608 |
||
2609 |
" |
|
2610 |
Display atomIDOf:'VT_SELECTION' create:false |
|
2611 |
Display atomIDOf:'CUT_BUFFER0' create:false |
|
2612 |
Display atomIDOf:'STRING' create:false |
|
2613 |
Display atomIDOf:'PRIMARY' create:false |
|
132 | 2614 |
Display atomIDOfPRIMARY |
90 | 2615 |
" |
2616 |
! |
|
2617 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2618 |
atomName:anAtomID |
200 | 2619 |
%{ /* NOCONTEXT */ |
2620 |
OBJ str; |
|
2621 |
char *name; |
|
2622 |
||
2623 |
if (ISCONNECTED) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2624 |
if (__isAtomID(anAtomID)) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2625 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
200 | 2626 |
if (name == 0) { |
2627 |
RETURN (nil); |
|
2628 |
} |
|
216 | 2629 |
str = __MKSTRING(name COMMA_CON); |
200 | 2630 |
XFree(name); |
2631 |
RETURN ( str ); |
|
2632 |
} |
|
2633 |
} |
|
2634 |
%}. |
|
2635 |
self primitiveFailed. |
|
2636 |
^ nil |
|
2637 |
||
2638 |
" |
|
2639 |
Display atomName:1 |
|
2640 |
" |
|
2641 |
! |
|
2642 |
||
129 | 2643 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
2644 |
"send aString back from a SelectionRequest" |
|
2645 |
||
2646 |
self |
|
2647 |
sendSelection:something |
|
2648 |
selection:primaryAtom |
|
2649 |
property:propertyID |
|
2650 |
target:targetID |
|
2651 |
from:windowID |
|
2652 |
to:requestorID |
|
2653 |
! |
|
2654 |
||
2655 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
90 | 2656 |
"send aString back from a SelectionRequest" |
129 | 2657 |
|
2658 |
self |
|
2659 |
setProperty:propertyID |
|
2660 |
type:targetID |
|
2661 |
value:something |
|
2662 |
for:requestorID. |
|
2663 |
self |
|
2664 |
sendSelectionNotifySelection:selectionID |
|
2665 |
property:propertyID |
|
2666 |
target:targetID |
|
132 | 2667 |
from:requestorID |
129 | 2668 |
to:requestorID. |
2669 |
! |
|
2670 |
||
2671 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
2672 |
"send a selectionNotify back from a SelectionRequest" |
|
132 | 2673 |
|
2674 |
%{ /* NOCONTEXT */ |
|
90 | 2675 |
Display *dpy = myDpy; |
2676 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2677 |
if (__isAtomID(propertyID) |
208 | 2678 |
&& __isExternalAddress(requestorID) |
150 | 2679 |
&& ISCONNECTED |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2680 |
&& __isAtomID(targetID) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2681 |
&& __isAtomID(selectionID)) { |
90 | 2682 |
XEvent ev; |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2683 |
Window requestor = _WindowVal(requestorID); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2684 |
Atom property = _AtomVal(propertyID); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2685 |
Atom target = _AtomVal(targetID); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2686 |
Atom selection = _AtomVal(selectionID); |
129 | 2687 |
Status result; |
90 | 2688 |
|
2689 |
ev.xselection.type = SelectionNotify; |
|
129 | 2690 |
ev.xselection.selection = selection; |
2691 |
ev.xselection.target = target; |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2692 |
if (__isExternalAddress(windowID)) |
129 | 2693 |
ev.xselection.requestor = _WindowVal(windowID); |
2694 |
else |
|
2695 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
90 | 2696 |
ev.xselection.time = CurrentTime; |
132 | 2697 |
if (property == None) |
2698 |
ev.xselection.property = target; |
|
2699 |
else |
|
2700 |
ev.xselection.property = property; |
|
129 | 2701 |
|
2702 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
2703 |
ev.xselection.selection, |
|
90 | 2704 |
ev.xselection.property, |
2705 |
ev.xselection.target, |
|
129 | 2706 |
ev.xselection.requestor, |
2707 |
requestor)); |
|
2708 |
||
2709 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
2710 |
if ((result == BadValue) || (result == BadWindow)) { |
|
2711 |
DPRINTF(("bad status\n")); |
|
2712 |
} |
|
90 | 2713 |
RETURN (self ) |
2714 |
} |
|
2715 |
%} |
|
2716 |
. |
|
2717 |
self primitiveFailed |
|
2718 |
! |
|
2719 |
||
2720 |
getTextSelectionFor:drawableId |
|
2721 |
"get the text selection - either immediate, or asynchronous. |
|
2722 |
Returns nil, if async request is on its way" |
|
2723 |
||
129 | 2724 |
|selProp sel| |
2725 |
||
2726 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
90 | 2727 |
"no primary selection - use cut buffer" |
129 | 2728 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
90 | 2729 |
^ sel |
2730 |
]. |
|
129 | 2731 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
2732 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
90 | 2733 |
^ nil |
2734 |
! |
|
2735 |
||
2736 |
getSelectionFor:drawableId |
|
2737 |
"get the object selection - either immediate, or asynchronous. |
|
2738 |
Returns nil, if async request is on its way" |
|
2739 |
||
129 | 2740 |
|selProp sel| |
2741 |
||
2742 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
90 | 2743 |
"no primary selection - use cut buffer" |
129 | 2744 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
90 | 2745 |
^ sel |
2746 |
]. |
|
2747 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
129 | 2748 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
90 | 2749 |
^ nil |
2750 |
! |
|
2751 |
||
2752 |
setTextSelection:aString owner:aWindowId |
|
2753 |
"set the text selection, and make aWindowId be the owner. |
|
2754 |
This can be used by any other X application." |
|
2755 |
||
129 | 2756 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
90 | 2757 |
'ownerchange failed' errorPrintNL. |
2758 |
]. |
|
129 | 2759 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
90 | 2760 |
! |
2761 |
||
2762 |
setSelection:anObject owner:aWindowId |
|
2763 |
"set the object selection, and make aWindowId be the owner. |
|
2764 |
This can be used by other Smalltalk(X) applications only." |
|
2765 |
||
129 | 2766 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
90 | 2767 |
^ false |
2768 |
]. |
|
129 | 2769 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
90 | 2770 |
^ true |
2771 |
! ! |
|
2772 |
||
0 | 2773 |
!XWorkstation methodsFor:'font stuff'! |
2774 |
||
2775 |
decomposeXFontName:aString into:aBlock |
|
2776 |
"extract family, face, style and size from an |
|
2777 |
X-font name |
|
54 | 2778 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
2779 |
evaluate aBlock with these" |
|
2780 |
||
2781 |
|origin family face style moreStyle skip fheight size |
|
12 | 2782 |
resX resY x1 x2 coding start end | |
0 | 2783 |
|
2784 |
aString isNil ifTrue:[^ false]. |
|
90 | 2785 |
(aString startsWith:'-') ifFalse:[ |
2786 |
" |
|
2787 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
2788 |
" |
|
2789 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
2790 |
end := aString indexOf:$- startingAt:1. |
|
2791 |
family := aString copyFrom:1 to:(end - 1). |
|
2792 |
start := end + 1. |
|
2793 |
end := aString indexOf:$- startingAt:start. |
|
2794 |
style := aString copyFrom:start to:(end - 1). |
|
2795 |
start := end + 1. |
|
2796 |
size := aString copyFrom:start. |
|
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2797 |
size := (Number readFromString:size onError:[^false]). |
90 | 2798 |
aBlock value:family value:nil value:style value:size value:nil. |
2799 |
^ true. |
|
2800 |
]. |
|
2801 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
2802 |
" |
|
2803 |
something like lucidasans-24 |
|
2804 |
" |
|
2805 |
end := aString indexOf:$- startingAt:1. |
|
2806 |
||
2807 |
family := aString copyFrom:1 to:(end - 1). |
|
2808 |
start := end + 1. |
|
2809 |
size := aString copyFrom:start. |
|
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2810 |
size := (Number readFromString:size onError:[^false]). |
90 | 2811 |
aBlock value:family value:nil value:nil value:size value:nil. |
2812 |
^ true. |
|
2813 |
]. |
|
2814 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
2815 |
^ true. |
|
2816 |
]. |
|
0 | 2817 |
|
2818 |
end := aString indexOf:$- startingAt:2. |
|
2819 |
(end == 0) ifTrue:[^ false]. |
|
2820 |
origin := aString copyFrom:2 to:(end - 1). |
|
2821 |
||
2822 |
start := end + 1. |
|
2823 |
end := aString indexOf:$- startingAt:start. |
|
2824 |
(end == 0) ifTrue:[^ false]. |
|
2825 |
family := aString copyFrom:start to:(end - 1). |
|
2826 |
||
2827 |
start := end + 1. |
|
2828 |
end := aString indexOf:$- startingAt:start. |
|
2829 |
(end == 0) ifTrue:[^ false]. |
|
2830 |
face := aString copyFrom:start to:(end - 1). |
|
2831 |
||
2832 |
start := end + 1. |
|
2833 |
end := aString indexOf:$- startingAt:start. |
|
2834 |
(end == 0) ifTrue:[^ false]. |
|
2835 |
style := aString copyFrom:start to:(end - 1). |
|
2836 |
(style = 'o') ifTrue:[ |
|
70 | 2837 |
style := 'oblique' |
0 | 2838 |
] ifFalse:[ |
70 | 2839 |
(style = 'i') ifTrue:[ |
2840 |
style := 'italic' |
|
2841 |
] ifFalse:[ |
|
2842 |
(style = 'r') ifTrue:[ |
|
2843 |
style := 'roman' |
|
2844 |
] |
|
2845 |
] |
|
0 | 2846 |
]. |
2847 |
||
2848 |
start := end + 1. |
|
2849 |
end := aString indexOf:$- startingAt:start. |
|
2850 |
(end == 0) ifTrue:[^ false]. |
|
2851 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
2852 |
||
2853 |
start := end + 1. |
|
2854 |
end := aString indexOf:$- startingAt:start. |
|
2855 |
(end == 0) ifTrue:[^ false]. |
|
2856 |
skip := aString copyFrom:start to:(end - 1). |
|
2857 |
||
2858 |
start := end + 1. |
|
2859 |
end := aString indexOf:$- startingAt:start. |
|
2860 |
(end == 0) ifTrue:[^ false]. |
|
54 | 2861 |
fheight := aString copyFrom:start to:(end - 1). |
0 | 2862 |
|
2863 |
start := end + 1. |
|
2864 |
end := aString indexOf:$- startingAt:start. |
|
2865 |
(end == 0) ifTrue:[^ false]. |
|
2866 |
size := aString copyFrom:start to:(end - 1). |
|
2867 |
size := (Number readFromString:size) / 10. |
|
2868 |
||
2869 |
start := end + 1. |
|
2870 |
end := aString indexOf:$- startingAt:start. |
|
2871 |
(end == 0) ifTrue:[^ false]. |
|
2872 |
resX := aString copyFrom:start to:(end - 1). |
|
2873 |
||
2874 |
start := end + 1. |
|
2875 |
end := aString indexOf:$- startingAt:start. |
|
2876 |
(end == 0) ifTrue:[^ false]. |
|
2877 |
resY := aString copyFrom:start to:(end - 1). |
|
2878 |
||
2879 |
start := end + 1. |
|
2880 |
end := aString indexOf:$- startingAt:start. |
|
2881 |
(end == 0) ifTrue:[^ false]. |
|
2882 |
x1 := aString copyFrom:start to:(end - 1). |
|
2883 |
||
2884 |
start := end + 1. |
|
2885 |
end := aString indexOf:$- startingAt:start. |
|
2886 |
(end == 0) ifTrue:[^ false]. |
|
2887 |
x2 := aString copyFrom:start to:(end - 1). |
|
2888 |
||
2889 |
start := end + 1. |
|
2890 |
end := aString indexOf:$- startingAt:start. |
|
2891 |
(end == 0) ifTrue:[^ false]. |
|
2892 |
coding := aString copyFrom:start to:(end - 1). |
|
2893 |
||
90 | 2894 |
aBlock value:family value:face value:style value:size value:coding. |
2895 |
^ true |
|
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2896 |
|
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2897 |
"Modified: 27.9.1995 / 10:46:52 / stefan" |
0 | 2898 |
! |
2899 |
||
2900 |
listOfAvailableFonts |
|
90 | 2901 |
"return a list with all available fonts on this display. |
12 | 2902 |
Since this takes a long time, keep the result of the query for the |
90 | 2903 |
next time. The elements of the returned collection are instances of |
2904 |
FontDescription." |
|
0 | 2905 |
|
154 | 2906 |
|stream names aName fntDescr| |
0 | 2907 |
|
2908 |
listOfXFonts isNil ifTrue:[ |
|
154 | 2909 |
"/ |
2910 |
"/ old code; using a pipe to xlsfonts |
|
2911 |
"/ |
|
2912 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
2913 |
"/ stream isNil ifTrue:[^ nil]. |
|
2914 |
"/ listOfXFonts := OrderedCollection new. |
|
2915 |
"/ [stream atEnd] whileFalse:[ |
|
2916 |
"/ aName := stream nextLine. |
|
2917 |
"/ aName notNil ifTrue:[ |
|
2918 |
"/ self decomposeXFontName:aName into: |
|
2919 |
"/ [:family :face :style :size :coding | |
|
2920 |
"/ family notNil ifTrue:[ |
|
2921 |
"/ fntDescr := FontDescription |
|
2922 |
"/ family:family |
|
2923 |
"/ face:face |
|
2924 |
"/ style:style |
|
2925 |
"/ size:size |
|
2926 |
"/ encoding:coding. |
|
2927 |
"/ listOfXFonts add:fntDescr |
|
2928 |
"/ ] |
|
2929 |
"/ ] |
|
2930 |
"/ ] |
|
2931 |
"/ ]. |
|
2932 |
"/ stream close. |
|
2933 |
"/ "if xlsfont is broken ... (hey sco)" |
|
2934 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
2935 |
"/ listOfXFonts := nil |
|
2936 |
"/ ] ifFalse:[ |
|
2937 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
2938 |
"/ ]. |
|
2939 |
||
2940 |
"/ |
|
2941 |
"/ new code: |
|
2942 |
"/ use new primitive to get font names; |
|
2943 |
"/ this is much faster, and also works on systems where |
|
2944 |
"/ a) xlsfonts is broken (sco) |
|
2945 |
"/ b) xlsfonts is not available (aix) |
|
2946 |
"/ |
|
2947 |
names := self getAvailableFontsMatching:'*'. |
|
2948 |
names isNil ifTrue:[ |
|
2949 |
"no names returned ..." |
|
2950 |
^ nil |
|
70 | 2951 |
]. |
154 | 2952 |
listOfXFonts := names collect:[:aName | |
2953 |
|fntDescr| |
|
2954 |
||
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2955 |
(self decomposeXFontName:aName into: |
154 | 2956 |
[:family :face :style :size :coding | |
2957 |
family notNil ifTrue:[ |
|
2958 |
fntDescr := FontDescription |
|
2959 |
family:family |
|
2960 |
face:face |
|
2961 |
style:style |
|
2962 |
size:size |
|
2963 |
encoding:coding. |
|
2964 |
] ifFalse:[ |
|
2965 |
fntDescr := FontDescription |
|
2966 |
name:aName |
|
2967 |
] |
|
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2968 |
] |
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2969 |
) ifFalse:[ |
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2970 |
fntDescr := FontDescription name:aName. |
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2971 |
]. |
154 | 2972 |
fntDescr |
2973 |
]. |
|
2974 |
||
0 | 2975 |
]. |
2976 |
^ listOfXFonts |
|
2977 |
||
154 | 2978 |
" |
2979 |
Display listOfAvailableFonts |
|
2980 |
" |
|
202
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2981 |
|
a92556521455
Fail safe when fontname matches unexpected pattern.
Stefan Vogel <sv@exept.de>
parents:
200
diff
changeset
|
2982 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
154 | 2983 |
! |
2984 |
||
2985 |
getAvailableFontsMatching:pattern |
|
216 | 2986 |
"return an Array filled with font names matching aPattern" |
154 | 2987 |
|
2988 |
%{ /* UNLIMITEDSTACK */ |
|
2989 |
||
2990 |
int nnames = 1500; |
|
2991 |
int available = nnames + 1; |
|
2992 |
char **fonts; |
|
2993 |
OBJ arr, str; |
|
2994 |
int i; |
|
2995 |
||
2996 |
if (ISCONNECTED) { |
|
2997 |
if (__isString(pattern)) { |
|
2998 |
for (;;) { |
|
2999 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
3000 |
if ((fonts == NULL) || (available < nnames)) break; |
|
3001 |
XFreeFontNames(fonts); |
|
3002 |
nnames = available * 2; |
|
3003 |
} |
|
3004 |
if (fonts == NULL) { |
|
3005 |
RETURN ( nil ); |
|
3006 |
} |
|
216 | 3007 |
/* |
3008 |
* now, that we know the number of font names, |
|
3009 |
* create the array ... |
|
3010 |
*/ |
|
154 | 3011 |
arr = __ARRAY_NEW_INT(available); |
3012 |
if (! arr) { |
|
3013 |
RETURN (nil); |
|
3014 |
} |
|
216 | 3015 |
/* |
3016 |
* ... and fill it |
|
3017 |
*/ |
|
154 | 3018 |
for (i=0; i<available; i++) { |
3019 |
PROTECT(arr); |
|
216 | 3020 |
str = __MKSTRING(fonts[i] COMMA_CON); |
154 | 3021 |
UNPROTECT(arr); |
216 | 3022 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
154 | 3023 |
} |
3024 |
RETURN (arr); |
|
3025 |
} |
|
3026 |
} |
|
3027 |
%}. |
|
3028 |
^ nil |
|
0 | 3029 |
! |
3030 |
||
3031 |
getFontWithFamily:familyString face:faceString |
|
70 | 3032 |
style:styleString size:sizeArg encoding:encodingSym |
0 | 3033 |
|
3034 |
"try to get the specified font, if not available, try next smaller |
|
90 | 3035 |
font. Access to X-fonts by name is possible, by passing the X font name |
3036 |
as family and the other parameters as nil. For example, the cursor font |
|
3037 |
can be aquired that way." |
|
3038 |
||
3039 |
|theSize theName theId xlatedStyle enc| |
|
0 | 3040 |
|
3041 |
"special: if face is nil, allow access to X-fonts" |
|
3042 |
faceString isNil ifTrue:[ |
|
90 | 3043 |
sizeArg notNil ifTrue:[ |
3044 |
theName := familyString , '-' , sizeArg printString |
|
3045 |
] ifFalse:[ |
|
3046 |
theName := familyString |
|
3047 |
]. |
|
153 | 3048 |
theName isNil ifTrue:[ |
3049 |
" |
|
3050 |
mhmh - fall back to the default font |
|
3051 |
" |
|
3052 |
theName := 'fixed' |
|
3053 |
]. |
|
90 | 3054 |
theId := self createFontFor:theName. |
70 | 3055 |
theId isNil ifTrue:[ |
3056 |
theId := self getDefaultFont |
|
3057 |
]. |
|
3058 |
^ theId |
|
0 | 3059 |
]. |
3060 |
||
144 | 3061 |
"/ new: |
0 | 3062 |
xlatedStyle := styleString. |
144 | 3063 |
xlatedStyle notNil ifTrue:[ |
3064 |
xlatedStyle := xlatedStyle first asString |
|
0 | 3065 |
]. |
3066 |
||
144 | 3067 |
^ self |
3068 |
getFontWithFoundry:'*' |
|
3069 |
family:familyString asLowercase |
|
3070 |
weight:faceString |
|
3071 |
slant:xlatedStyle |
|
3072 |
spacing:'normal' |
|
3073 |
pixelSize:nil |
|
3074 |
size:sizeArg |
|
3075 |
registry:'*' |
|
3076 |
encoding:encodingSym. |
|
3077 |
||
3078 |
||
3079 |
"/ old: |
|
3080 |
"/ xlatedStyle := styleString. |
|
3081 |
"/ "oblique is named italic in times font" |
|
3082 |
"/ ((familyString = 'Times') or:[familyString = 'times']) ifTrue:[ |
|
3083 |
"/ ((styleString = 'Oblique') or:[styleString = 'oblique']) ifTrue:[ |
|
3084 |
"/ xlatedStyle := 'italic' |
|
3085 |
"/ ] |
|
3086 |
"/ ]. |
|
3087 |
"/ (xlatedStyle = 'italic') ifTrue:[ |
|
3088 |
"/ xlatedStyle := 'i' |
|
3089 |
"/ ] ifFalse:[ |
|
3090 |
"/ (xlatedStyle = 'roman') ifTrue:[ |
|
3091 |
"/ xlatedStyle := 'r' |
|
3092 |
"/ ] ifFalse:[ |
|
3093 |
"/ (xlatedStyle = 'oblique') ifTrue:[ |
|
3094 |
"/ xlatedStyle := 'o' |
|
3095 |
"/ ] |
|
3096 |
"/ ] |
|
3097 |
"/ ]. |
|
3098 |
"/ |
|
3099 |
"/ theId := nil. |
|
3100 |
"/ theSize := sizeArg. |
|
3101 |
"/ [theId isNil] whileTrue:[ |
|
3102 |
"/ "this works only on Release >= 3 - X-servers" |
|
3103 |
"/ enc := encodingSym. |
|
3104 |
"/ enc isNil ifTrue:[ |
|
3105 |
"/ enc := '*' |
|
3106 |
"/ ]. |
|
3107 |
"/ theName := ('-*-' , familyString , |
|
3108 |
"/ '-' , faceString , |
|
3109 |
"/ '-' , xlatedStyle , '-*-*-*-' |
|
3110 |
"/ , theSize printString , '0-*-*-*-*-' |
|
3111 |
"/ , enc , '-*'). |
|
3112 |
"/" |
|
3113 |
"/Transcript showCr:theName; endEntry. |
|
3114 |
"/" |
|
3115 |
"/ theId := self createFontFor:theName. |
|
3116 |
"/ theId isNil ifTrue:[ |
|
3117 |
"/ "could not get the font - try next smaller one" |
|
3118 |
"/ theSize := theSize - 1. |
|
3119 |
"/ (theSize < (sizeArg // 2)) ifTrue:[ |
|
3120 |
"/ "thats too much - give up" |
|
3121 |
"/ ^ self getDefaultFont |
|
3122 |
"/ "^ nil" |
|
3123 |
"/ ] |
|
3124 |
"/ ] |
|
3125 |
"/ ]. |
|
3126 |
"/ (theSize ~~ sizeArg) ifTrue:[ |
|
3127 |
"/ Transcript show:'next smaller font: '. |
|
3128 |
"/ Transcript showCr:theName |
|
3129 |
"/ ]. |
|
3130 |
"/ ^ theId |
|
0 | 3131 |
! |
3132 |
||
37 | 3133 |
getFontWithFoundry:foundry family:family weight:weight |
144 | 3134 |
slant:slant spacing:spc pixelSize:pSize size:size |
3135 |
registry:registry encoding:encoding |
|
37 | 3136 |
|
3137 |
"get the specified font, if not available, return nil. |
|
3138 |
This is the new font creation method - all others will be changed to |
|
144 | 3139 |
use this entry. |
3140 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
3141 |
||
3142 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
3143 |
family: 'helvetica' 'courier' 'times' ... |
|
3144 |
weight: 'bold' 'medium' 'demi' ... |
|
3145 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
3146 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
3147 |
pixelSize: 16,18 ... usually left empty |
|
3148 |
size: size in point (1/72th of an inch) |
|
3149 |
registry: iso8859, sgi ... '*' |
|
3150 |
" |
|
3151 |
||
3152 |
|theName sMatch| |
|
37 | 3153 |
|
3154 |
"this works only on 'Release >= 3' - X-servers" |
|
144 | 3155 |
"name is: |
3156 |
-foundry-family -weight -slant- |
|
3157 |
sony helvetica bold r |
|
3158 |
adobe courier medium i |
|
3159 |
msic fixed o |
|
3160 |
... ... |
|
3161 |
" |
|
3162 |
||
3163 |
size isNil ifTrue:[sMatch := '*'] ifFalse:[sMatch := size printString , '0']. |
|
3164 |
||
3165 |
theName := ('-' , (foundry isNil ifTrue:['*'] ifFalse:[foundry]), |
|
3166 |
'-' , (family isNil ifTrue:['*'] ifFalse:[family]), |
|
3167 |
'-' , (weight isNil ifTrue:['*'] ifFalse:[weight]) , |
|
3168 |
'-' , (slant isNil ifTrue:['*'] ifFalse:[slant]) , |
|
3169 |
'-' , (spc isNil ifTrue:['*'] ifFalse:[spc]) , |
|
3170 |
'-*' , |
|
3171 |
'-' , (pSize isNil ifTrue:['*'] ifFalse:[pSize printString]), |
|
3172 |
'-' , sMatch , |
|
70 | 3173 |
'-*-*-*-*' , |
144 | 3174 |
'-' , (registry isNil ifTrue:['*'] ifFalse:[registry]) , |
3175 |
'-' , (encoding isNil ifTrue:['*'] ifFalse:[encoding])). |
|
146 | 3176 |
"/ Transcript showCr:theName; endEntry. |
37 | 3177 |
|
3178 |
^ self createFontFor:theName. |
|
3179 |
||
3180 |
" |
|
3181 |
Display getFontWithFoundry:'*' |
|
70 | 3182 |
family:'courier' |
3183 |
weight:'medium' |
|
3184 |
slant:'r' |
|
211 | 3185 |
spacing:nil |
3186 |
pixelSize:nil |
|
70 | 3187 |
size:13 |
3188 |
registry:'iso8859' |
|
3189 |
encoding:'*' |
|
37 | 3190 |
" |
3191 |
! |
|
3192 |
||
0 | 3193 |
createFontFor:aFontName |
2 | 3194 |
"a basic method for X-font allocation; this method allows |
37 | 3195 |
any font to be aquired (even those not conforming to |
3196 |
standard naming conventions, such as cursor, fixed or k14)" |
|
0 | 3197 |
|
193 | 3198 |
%{ /* UNLIMITEDSTACK */ |
3199 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
0 | 3200 |
|
3201 |
XFontStruct *newFont; |
|
3202 |
||
150 | 3203 |
if (ISCONNECTED) { |
3204 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
3205 |
BEGIN_INTERRUPTSBLOCKED |
|
193 | 3206 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
150 | 3207 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3208 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
150 | 3209 |
} |
0 | 3210 |
} |
193 | 3211 |
%}. |
43 | 3212 |
^ nil |
0 | 3213 |
! |
3214 |
||
3215 |
getDefaultFont |
|
3216 |
"return a default font id - used when class Font cannot |
|
3217 |
find anything usable" |
|
3218 |
||
3219 |
^ self createFontFor:'fixed' |
|
3220 |
! |
|
3221 |
||
3222 |
releaseFont:aFontId |
|
3223 |
||
3224 |
%{ /* NOCONTEXT */ |
|
3225 |
||
3226 |
XFontStruct *f; |
|
3227 |
||
150 | 3228 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3229 |
if (__isExternalAddress(aFontId)) { |
150 | 3230 |
f = _FontVal(aFontId); |
3231 |
BEGIN_INTERRUPTSBLOCKED |
|
3232 |
XFreeFont(myDpy, f); |
|
3233 |
END_INTERRUPTSBLOCKED |
|
3234 |
RETURN ( self ); |
|
3235 |
} |
|
0 | 3236 |
} |
3237 |
%} |
|
3238 |
. |
|
3239 |
self primitiveFailed |
|
3240 |
! |
|
3241 |
||
3242 |
ascentOf:aFontId |
|
157 | 3243 |
"the normal ascent" |
0 | 3244 |
|
3245 |
%{ /* NOCONTEXT */ |
|
3246 |
||
3247 |
XFontStruct *f; |
|
3248 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3249 |
if (__isExternalAddress(aFontId)) { |
70 | 3250 |
f = _FontVal(aFontId); |
3251 |
RETURN ( _MKSMALLINT(f->ascent) ); |
|
0 | 3252 |
} |
3253 |
%} |
|
3254 |
. |
|
43 | 3255 |
self primitiveFailed. |
3256 |
^ nil |
|
0 | 3257 |
! |
3258 |
||
3259 |
descentOf:aFontId |
|
157 | 3260 |
"the normal descent" |
0 | 3261 |
|
3262 |
%{ /* NOCONTEXT */ |
|
3263 |
||
3264 |
XFontStruct *f; |
|
3265 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3266 |
if (__isExternalAddress(aFontId)) { |
70 | 3267 |
f = _FontVal(aFontId); |
3268 |
RETURN ( _MKSMALLINT(f->descent) ); |
|
0 | 3269 |
} |
3270 |
%} |
|
3271 |
. |
|
43 | 3272 |
self primitiveFailed. |
3273 |
^ nil |
|
0 | 3274 |
! |
3275 |
||
3276 |
minWidthOfFont:aFontId |
|
3277 |
||
3278 |
%{ /* NOCONTEXT */ |
|
3279 |
||
3280 |
XFontStruct *f; |
|
3281 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3282 |
if (__isExternalAddress(aFontId)) { |
70 | 3283 |
f = _FontVal(aFontId); |
3284 |
RETURN ( _MKSMALLINT(f->min_bounds.width) ); |
|
0 | 3285 |
} |
3286 |
%} |
|
3287 |
. |
|
43 | 3288 |
self primitiveFailed. |
3289 |
^ nil |
|
0 | 3290 |
! |
3291 |
||
157 | 3292 |
maxAscentOf:aFontId |
3293 |
"the max ascent" |
|
3294 |
||
3295 |
%{ /* NOCONTEXT */ |
|
3296 |
||
3297 |
XFontStruct *f; |
|
3298 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3299 |
if (__isExternalAddress(aFontId)) { |
157 | 3300 |
f = _FontVal(aFontId); |
3301 |
RETURN ( _MKSMALLINT(f->max_bounds.ascent) ); |
|
3302 |
} |
|
3303 |
%} |
|
3304 |
. |
|
3305 |
self primitiveFailed. |
|
3306 |
^ nil |
|
3307 |
! |
|
3308 |
||
3309 |
maxDescentOf:aFontId |
|
3310 |
"the max descent" |
|
3311 |
||
3312 |
%{ /* NOCONTEXT */ |
|
3313 |
||
3314 |
XFontStruct *f; |
|
3315 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3316 |
if (__isExternalAddress(aFontId)) { |
157 | 3317 |
f = _FontVal(aFontId); |
3318 |
RETURN ( _MKSMALLINT(f->max_bounds.descent) ); |
|
3319 |
} |
|
3320 |
%} |
|
3321 |
. |
|
3322 |
self primitiveFailed. |
|
3323 |
^ nil |
|
3324 |
! |
|
3325 |
||
0 | 3326 |
maxWidthOfFont:aFontId |
157 | 3327 |
"the width of the widest character" |
0 | 3328 |
|
3329 |
%{ /* NOCONTEXT */ |
|
3330 |
||
3331 |
XFontStruct *f; |
|
3332 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3333 |
if (__isExternalAddress(aFontId)) { |
70 | 3334 |
f = _FontVal(aFontId); |
3335 |
RETURN ( _MKSMALLINT(f->max_bounds.width) ); |
|
0 | 3336 |
} |
3337 |
%} |
|
3338 |
. |
|
43 | 3339 |
self primitiveFailed. |
3340 |
^ nil |
|
0 | 3341 |
! |
3342 |
||
3343 |
widthOf:aString inFont:aFontId |
|
3344 |
||
3345 |
%{ /* NOCONTEXT */ |
|
3346 |
||
3347 |
XFontStruct *f; |
|
3348 |
char *cp; |
|
3349 |
int len, n; |
|
37 | 3350 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3351 |
if (__isExternalAddress(aFontId)) { |
70 | 3352 |
f = _FontVal(aFontId); |
3353 |
if (__isString(aString) || __isSymbol(aString)) { |
|
3354 |
n = _stringSize(aString); |
|
3355 |
cp = (char *)_stringVal(aString); |
|
3356 |
BEGIN_INTERRUPTSBLOCKED |
|
3357 |
len = XTextWidth(f, cp, n); |
|
3358 |
END_INTERRUPTSBLOCKED |
|
3359 |
RETURN ( _MKSMALLINT(len) ); |
|
3360 |
} |
|
37 | 3361 |
#ifdef TWOBYTESTRINGS |
150 | 3362 |
if (__Class(aString) == @global(TwoByteString)) { |
70 | 3363 |
n = _byteArraySize(aString) / 2; |
3364 |
cp = (char *) _stringVal(aString); |
|
3365 |
BEGIN_INTERRUPTSBLOCKED |
|
3366 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
3367 |
END_INTERRUPTSBLOCKED |
|
3368 |
RETURN ( _MKSMALLINT(len) ); |
|
3369 |
} |
|
37 | 3370 |
#endif |
0 | 3371 |
} |
3372 |
%} |
|
3373 |
. |
|
43 | 3374 |
self primitiveFailed. |
3375 |
^ nil |
|
0 | 3376 |
! |
3377 |
||
3378 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
3379 |
||
3380 |
%{ /* NOCONTEXT */ |
|
3381 |
||
3382 |
XFontStruct *f; |
|
3383 |
char *cp; |
|
3384 |
int len, n, i1, i2; |
|
37 | 3385 |
|
97 | 3386 |
if (__bothSmallInteger(index1, index2) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3387 |
&& __isExternalAddress(aFontId)) { |
70 | 3388 |
f = _FontVal(aFontId); |
3389 |
i1 = _intVal(index1) - 1; |
|
3390 |
i2 = _intVal(index2) - 1; |
|
3391 |
if (__isString(aString) || __isSymbol(aString)) { |
|
3392 |
cp = (char *) _stringVal(aString); |
|
3393 |
n = _stringSize(aString); |
|
3394 |
if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) { |
|
3395 |
cp += i1; |
|
3396 |
BEGIN_INTERRUPTSBLOCKED |
|
3397 |
len = XTextWidth(f, cp, i2 - i1 + 1); |
|
3398 |
END_INTERRUPTSBLOCKED |
|
3399 |
RETURN ( _MKSMALLINT(len) ); |
|
3400 |
} |
|
3401 |
} |
|
37 | 3402 |
#ifdef TWOBYTESTRINGS |
150 | 3403 |
if (__Class(aString) == @global(TwoByteString)) { |
70 | 3404 |
cp = (char *) _stringVal(aString); |
3405 |
n = _byteArraySize(aString) / 2; |
|
3406 |
if ((i1 >= 0) && (i2 >= i1) && (i2 < n)) { |
|
3407 |
cp += (i1 * 2); |
|
3408 |
BEGIN_INTERRUPTSBLOCKED |
|
3409 |
len = XTextWidth16(f, (XChar2b *)cp, i2 - i1 + 1); |
|
3410 |
END_INTERRUPTSBLOCKED |
|
3411 |
RETURN ( _MKSMALLINT(len) ); |
|
3412 |
} |
|
3413 |
} |
|
37 | 3414 |
#endif |
0 | 3415 |
} |
3416 |
%} |
|
3417 |
. |
|
43 | 3418 |
self primitiveFailed. |
3419 |
^ nil |
|
37 | 3420 |
! |
3421 |
||
3422 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName |
|
3423 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
|
3424 |
on this display. |
|
3425 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
3426 |
||
3427 |
|sizes| |
|
3428 |
||
3429 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName. |
|
70 | 3430 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
3431 |
"special: in X11R5 and above, size 0 means: |
|
3432 |
there are scaled versions in all sizes available" |
|
3433 |
||
3434 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
37 | 3435 |
]. |
3436 |
^ sizes |
|
3437 |
||
3438 |
" |
|
3439 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
3440 |
" |
|
0 | 3441 |
! ! |
3442 |
||
3443 |
!XWorkstation methodsFor:'cursor stuff'! |
|
3444 |
||
3445 |
destroyCursor:aCursorId |
|
3446 |
||
3447 |
%{ /* NOCONTEXT */ |
|
3448 |
||
150 | 3449 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3450 |
if (__isExternalAddress(aCursorId)) { |
150 | 3451 |
BEGIN_INTERRUPTSBLOCKED |
3452 |
XFreeCursor(myDpy, _CursorVal(aCursorId)); |
|
3453 |
END_INTERRUPTSBLOCKED |
|
3454 |
RETURN ( self ); |
|
3455 |
} |
|
0 | 3456 |
} |
3457 |
%} |
|
3458 |
. |
|
3459 |
self primitiveFailed |
|
3460 |
! |
|
3461 |
||
3462 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
3463 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
3464 |
||
3465 |
|id sourceId maskId| |
|
3466 |
||
150 | 3467 |
displayId isNil ifTrue:[ |
3468 |
self primitiveFailed. |
|
3469 |
^ nil |
|
3470 |
]. |
|
0 | 3471 |
sourceId := sourceForm id. |
3472 |
maskId := maskForm id. |
|
3473 |
%{ |
|
3474 |
Cursor newCursor; |
|
3475 |
XColor fgColor, bgColor; |
|
3476 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3477 |
if (__isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3478 |
&& __isExternalAddress(maskId) |
97 | 3479 |
&& __bothSmallInteger(hx, hy)) { |
70 | 3480 |
fgColor.red = 0; /* fg is black */ |
3481 |
fgColor.green = 0; |
|
3482 |
fgColor.blue = 0; |
|
3483 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
3484 |
bgColor.green = 0xFFFF; |
|
3485 |
bgColor.blue = 0xFFFF; |
|
3486 |
||
3487 |
BEGIN_INTERRUPTSBLOCKED |
|
3488 |
newCursor = XCreatePixmapCursor(myDpy, |
|
3489 |
_PixmapVal(sourceId), |
|
3490 |
_PixmapVal(maskId), |
|
3491 |
&fgColor, &bgColor, _intVal(hx), _intVal(hy)); |
|
3492 |
END_INTERRUPTSBLOCKED |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3493 |
if (newCursor != (Cursor)0) { |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3494 |
id = __MKOBJ(newCursor); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3495 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3496 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3497 |
%}. |
0 | 3498 |
^ id |
3499 |
! |
|
3500 |
||
3501 |
shapeNumberFromSymbol:shape |
|
3502 |
"given a shape-symbol, return the corresponding cursor-number" |
|
3503 |
||
3504 |
"this is pure X-knowlegde - but you may easily add more" |
|
3505 |
||
3506 |
(shape == #upLeftArrow) ifTrue:[ ^ 132 ]. |
|
3507 |
(shape == #upRightHand) ifTrue:[ ^ 58 ]. |
|
3508 |
(shape == #upDownArrow) ifTrue:[ ^ 116 ]. |
|
3509 |
(shape == #leftRightArrow) ifTrue:[ ^ 108 ]. |
|
3510 |
(shape == #upLimitArrow) ifTrue:[ ^ 138 ]. |
|
3511 |
(shape == #downLimitArrow) ifTrue:[ ^ 16 ]. |
|
3512 |
(shape == #leftLimitArrow) ifTrue:[ ^ 70 ]. |
|
3513 |
(shape == #rightLimitArrow) ifTrue:[ ^ 96 ]. |
|
3514 |
(shape == #text) ifTrue:[ ^ 152 ]. |
|
3515 |
(shape == #upRightArrow) ifTrue:[ ^ 44 ]. |
|
3516 |
(shape == #leftHand) ifTrue:[ ^ 60 ]. |
|
3517 |
(shape == #questionMark) ifTrue:[ ^ 92 ]. |
|
3518 |
(shape == #cross) ifTrue:[ ^ 0 ]. |
|
3519 |
(shape == #wait) ifTrue:[ ^ 150 ]. |
|
3520 |
(shape == #crossHair) ifTrue:[ ^ 130 ]. |
|
81 | 3521 |
((shape == #origin) |
3522 |
or:[shape == #topLeft]) ifTrue:[ ^ 144 ]. |
|
3523 |
((shape == #corner) |
|
3524 |
or:[shape == #bottomRight]) ifTrue:[ ^ 78 ]. |
|
3525 |
(shape == #topRight) ifTrue:[ ^ 148 ]. |
|
3526 |
(shape == #bottomLeft) ifTrue:[ ^ 76 ]. |
|
0 | 3527 |
(shape == #square) ifTrue:[ ^ 40 ]. |
3528 |
(shape == #fourWay) ifTrue:[ ^ 52 ]. |
|
3529 |
(shape == #crossCursor) ifTrue:[ ^ 0 ]. |
|
145 | 3530 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
0 | 3531 |
^ 0 |
3532 |
! |
|
3533 |
||
3534 |
createCursorShape:aShape |
|
3535 |
"create a cursor given a shape-symbol" |
|
3536 |
||
3537 |
|number id| |
|
3538 |
||
150 | 3539 |
displayId isNil ifTrue:[ |
3540 |
self primitiveFailed. |
|
3541 |
^ nil |
|
3542 |
]. |
|
0 | 3543 |
number := self shapeNumberFromSymbol:aShape. |
3544 |
%{ |
|
3545 |
Cursor newCursor; |
|
3546 |
||
97 | 3547 |
if (__isSmallInteger(number)) { |
70 | 3548 |
BEGIN_INTERRUPTSBLOCKED |
3549 |
newCursor = XCreateFontCursor(myDpy, _intVal(number)); |
|
3550 |
END_INTERRUPTSBLOCKED |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3551 |
if (newCursor != (Cursor)0) { |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3552 |
id = __MKOBJ(newCursor); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3553 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3554 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3555 |
%}. |
0 | 3556 |
^ id |
3557 |
! |
|
3558 |
||
3559 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
3560 |
"change a cursors colors" |
|
3561 |
||
3562 |
|fgR fgG fgB bgR bgG bgB| |
|
3563 |
||
3564 |
fgR := fgColor red. |
|
3565 |
fgG := fgColor green. |
|
3566 |
fgB := fgColor blue. |
|
3567 |
bgR := bgColor red. |
|
3568 |
bgG := bgColor green. |
|
3569 |
bgB := bgColor blue. |
|
3570 |
||
3571 |
fgR := self percentToXColorValue:fgR. |
|
3572 |
fgG := self percentToXColorValue:fgG. |
|
3573 |
fgB := self percentToXColorValue:fgB. |
|
3574 |
bgR := self percentToXColorValue:bgR. |
|
3575 |
bgG := self percentToXColorValue:bgG. |
|
3576 |
bgB := self percentToXColorValue:bgB. |
|
3577 |
||
3578 |
%{ |
|
3579 |
XColor fgcolor, bgcolor; |
|
3580 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3581 |
if (__isExternalAddress(aCursorId) |
97 | 3582 |
&& __bothSmallInteger(fgG, fgB) |
3583 |
&& __bothSmallInteger(bgR, bgG) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3584 |
&& __bothSmallInteger(bgB, fgR)) { |
0 | 3585 |
|
70 | 3586 |
fgcolor.red = _intVal(fgR); |
3587 |
fgcolor.green= _intVal(fgG); |
|
3588 |
fgcolor.blue = _intVal(fgB); |
|
3589 |
bgcolor.red = _intVal(bgR); |
|
3590 |
bgcolor.green= _intVal(bgG); |
|
3591 |
bgcolor.blue = _intVal(bgB); |
|
3592 |
BEGIN_INTERRUPTSBLOCKED |
|
3593 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
3594 |
END_INTERRUPTSBLOCKED |
|
3595 |
RETURN ( self ); |
|
0 | 3596 |
} |
3597 |
%} |
|
3598 |
. |
|
3599 |
self primitiveFailed |
|
81 | 3600 |
! ! |
3601 |
||
3602 |
!XWorkstation methodsFor:'grabbing '! |
|
0 | 3603 |
|
3604 |
grabKeyboardIn:aWindowId |
|
3605 |
"grab the keyboard" |
|
3606 |
||
3607 |
%{ /* NOCONTEXT */ |
|
81 | 3608 |
int result, ok; |
0 | 3609 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3610 |
if (__isExternalAddress(aWindowId)) { |
70 | 3611 |
BEGIN_INTERRUPTSBLOCKED |
3612 |
result = XGrabKeyboard(myDpy, |
|
3613 |
_WindowVal(aWindowId), |
|
3614 |
True /* False */, |
|
3615 |
GrabModeAsync, |
|
3616 |
GrabModeAsync, |
|
3617 |
CurrentTime); |
|
3618 |
END_INTERRUPTSBLOCKED |
|
81 | 3619 |
ok = 0; |
70 | 3620 |
switch(result) { |
3621 |
case AlreadyGrabbed: |
|
81 | 3622 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
3623 |
break; |
|
70 | 3624 |
case GrabNotViewable: |
81 | 3625 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
3626 |
break; |
|
70 | 3627 |
case GrabInvalidTime: |
81 | 3628 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
3629 |
break; |
|
70 | 3630 |
case GrabFrozen: |
81 | 3631 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
3632 |
break; |
|
3633 |
default: |
|
3634 |
ok = 1; |
|
3635 |
break; |
|
3636 |
} |
|
3637 |
if (! ok) { |
|
3638 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
3639 |
RETURN (false); |
|
70 | 3640 |
} |
3641 |
||
3642 |
RETURN ( true ); |
|
0 | 3643 |
} |
3644 |
%} |
|
3645 |
. |
|
3646 |
self primitiveFailed |
|
3647 |
! |
|
3648 |
||
3649 |
ungrabKeyboard |
|
3650 |
"release the keyboard" |
|
3651 |
||
3652 |
%{ /* NOCONTEXT */ |
|
3653 |
||
169 | 3654 |
if (ISCONNECTED) { |
180 | 3655 |
BEGIN_INTERRUPTSBLOCKED |
3656 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
3657 |
XSync(myDpy, 0); |
|
3658 |
END_INTERRUPTSBLOCKED |
|
169 | 3659 |
} |
81 | 3660 |
%}. |
3661 |
activeKeyboardGrab := nil |
|
0 | 3662 |
! |
3663 |
||
23 | 3664 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
3665 |
"grap the pointer - return true if ok" |
|
3666 |
||
0 | 3667 |
%{ /* NOCONTEXT */ |
3668 |
||
78 | 3669 |
int result, ok; |
23 | 3670 |
Window confineWin; |
3671 |
Cursor curs; |
|
3672 |
int pointer_mode, keyboard_mode; |
|
0 | 3673 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3674 |
if (__isExternalAddress(aWindowId)) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3675 |
if (__isExternalAddress(confineId)) |
70 | 3676 |
confineWin = _WindowVal(confineId); |
3677 |
else |
|
3678 |
confineWin = (Window) None; |
|
3679 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3680 |
if (__isExternalAddress(aCursorId)) |
70 | 3681 |
curs = _CursorVal(aCursorId); |
3682 |
else |
|
3683 |
curs = (Cursor) None; |
|
3684 |
||
3685 |
if (pMode == @symbol(sync)) |
|
3686 |
pointer_mode = GrabModeSync; |
|
3687 |
else |
|
3688 |
pointer_mode = GrabModeAsync; |
|
3689 |
||
3690 |
if (kMode == @symbol(sync)) |
|
3691 |
keyboard_mode = GrabModeSync; |
|
3692 |
else |
|
3693 |
keyboard_mode = GrabModeAsync; |
|
3694 |
||
3695 |
BEGIN_INTERRUPTSBLOCKED |
|
3696 |
result = XGrabPointer(myDpy, |
|
3697 |
_WindowVal(aWindowId), |
|
3698 |
False, |
|
3699 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
3700 |
pointer_mode, keyboard_mode, |
|
3701 |
confineWin, |
|
3702 |
curs, |
|
3703 |
CurrentTime); |
|
3704 |
END_INTERRUPTSBLOCKED |
|
3705 |
||
78 | 3706 |
ok = 0; |
70 | 3707 |
switch (result) { |
3708 |
case AlreadyGrabbed: |
|
81 | 3709 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
78 | 3710 |
break; |
70 | 3711 |
case GrabNotViewable: |
81 | 3712 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
78 | 3713 |
break; |
70 | 3714 |
case GrabInvalidTime: |
81 | 3715 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
78 | 3716 |
break; |
70 | 3717 |
case GrabFrozen: |
81 | 3718 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
78 | 3719 |
break; |
3720 |
default: |
|
3721 |
ok = 1; |
|
3722 |
break; |
|
70 | 3723 |
} |
3724 |
||
78 | 3725 |
if (! ok) { |
81 | 3726 |
XUngrabPointer(myDpy, CurrentTime); |
78 | 3727 |
RETURN (false); |
3728 |
} |
|
70 | 3729 |
RETURN ( true ); |
0 | 3730 |
} |
3731 |
%} |
|
3732 |
. |
|
3733 |
self primitiveFailed |
|
3734 |
! |
|
3735 |
||
3736 |
ungrabPointer |
|
3737 |
"release the pointer" |
|
3738 |
||
3739 |
%{ /* NOCONTEXT */ |
|
3740 |
||
169 | 3741 |
if (ISCONNECTED) { |
180 | 3742 |
BEGIN_INTERRUPTSBLOCKED |
3743 |
XUngrabPointer(myDpy, CurrentTime); |
|
3744 |
XSync(myDpy, 0); |
|
3745 |
END_INTERRUPTSBLOCKED |
|
169 | 3746 |
} |
81 | 3747 |
%}. |
3748 |
activePointerGrab := nil |
|
0 | 3749 |
! |
3750 |
||
63 | 3751 |
allowEvents:mode |
3752 |
%{ /* NOCONTEXT */ |
|
3753 |
||
3754 |
int _mode, ok = 1; |
|
3755 |
||
3756 |
if (mode == @symbol(asyncPointer)) |
|
70 | 3757 |
_mode = AsyncPointer; |
63 | 3758 |
else if (mode == @symbol(syncPointer)) |
70 | 3759 |
_mode = SyncPointer; |
63 | 3760 |
else if (mode == @symbol(asyncKeyboard)) |
70 | 3761 |
_mode = AsyncKeyboard; |
63 | 3762 |
else if (mode == @symbol(syncKeyboard)) |
70 | 3763 |
_mode = SyncKeyboard; |
63 | 3764 |
else if (mode == @symbol(syncBoth)) |
70 | 3765 |
_mode = SyncBoth; |
63 | 3766 |
else if (mode == @symbol(asyncBoth)) |
70 | 3767 |
_mode = AsyncBoth; |
63 | 3768 |
else if (mode == @symbol(replayPointer)) |
70 | 3769 |
_mode = ReplayPointer; |
63 | 3770 |
else if (mode == @symbol(replayKeyboard)) |
70 | 3771 |
_mode = ReplayKeyboard; |
63 | 3772 |
else |
70 | 3773 |
ok = 0; |
63 | 3774 |
|
3775 |
if (ok) { |
|
70 | 3776 |
BEGIN_INTERRUPTSBLOCKED |
3777 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
3778 |
END_INTERRUPTSBLOCKED |
|
3779 |
RETURN (self); |
|
63 | 3780 |
} |
3781 |
%} |
|
3782 |
. |
|
3783 |
self primitiveFailed |
|
81 | 3784 |
! ! |
3785 |
||
3786 |
!XWorkstation methodsFor:'pointer queries '! |
|
63 | 3787 |
|
0 | 3788 |
rootPositionOfLastEvent |
3789 |
"return the position in root-window coordinates |
|
3790 |
of the last button, key or pointer event" |
|
3791 |
||
3792 |
^ eventRootX @ eventRootY |
|
3793 |
! |
|
3794 |
||
3795 |
pointerPosition |
|
3796 |
"return the current pointer position in root-window coordinates" |
|
3797 |
||
3798 |
|xpos ypos| |
|
150 | 3799 |
|
0 | 3800 |
%{ |
23 | 3801 |
Display *dpy = myDpy; |
3802 |
Window w; |
|
3803 |
int screen = _intVal(_INST(screen)); |
|
3804 |
Window rootRet, childRet; |
|
3805 |
int rootX, rootY, winX, winY; |
|
3806 |
unsigned int mask; |
|
0 | 3807 |
|
54 | 3808 |
BEGIN_INTERRUPTSBLOCKED |
90 | 3809 |
#ifdef VIRTUAL_ROOT |
23 | 3810 |
w = getRootWindow(myDpy, screen); |
54 | 3811 |
#else |
3812 |
w = RootWindow(dpy, screen); |
|
3813 |
#endif |
|
23 | 3814 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
70 | 3815 |
&rootX, &rootY, |
3816 |
&winX, &winY, |
|
3817 |
&mask); |
|
23 | 3818 |
xpos = _MKSMALLINT(rootX); |
3819 |
ypos = _MKSMALLINT(rootY); |
|
54 | 3820 |
END_INTERRUPTSBLOCKED |
0 | 3821 |
%} |
3822 |
. |
|
3823 |
^ xpos @ ypos |
|
23 | 3824 |
! |
3825 |
||
3826 |
buttonStates |
|
3827 |
"return an integer representing the state of the pointer buttons; |
|
3828 |
a one-bit in positions 0.. represent a pressed button" |
|
3829 |
||
3830 |
%{ /* NOCONTEXT*/ |
|
3831 |
Display *dpy = myDpy; |
|
3832 |
Window w; |
|
3833 |
int screen = _intVal(_INST(screen)); |
|
3834 |
Window rootRet, childRet; |
|
3835 |
int rootX, rootY, winX, winY; |
|
3836 |
unsigned int mask; |
|
3837 |
||
54 | 3838 |
BEGIN_INTERRUPTSBLOCKED |
90 | 3839 |
#ifdef VIRTUAL_ROOT |
23 | 3840 |
w = getRootWindow(myDpy, screen); |
54 | 3841 |
#else |
3842 |
w = RootWindow(dpy, screen); |
|
3843 |
#endif |
|
23 | 3844 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
70 | 3845 |
&rootX, &rootY, |
3846 |
&winX, &winY, |
|
3847 |
&mask); |
|
54 | 3848 |
END_INTERRUPTSBLOCKED |
23 | 3849 |
RETURN (_MKSMALLINT(mask)); |
3850 |
%} |
|
3851 |
! |
|
3852 |
||
133 | 3853 |
leftButtonStateMask |
3854 |
"return an integer for masking out the left button from a |
|
3855 |
buttonStates value" |
|
3856 |
||
3857 |
^ 256 |
|
3858 |
! |
|
3859 |
||
3860 |
middleButtonStateMask |
|
3861 |
"return an integer for masking out the middle button from a |
|
3862 |
buttonStates value" |
|
3863 |
||
3864 |
^ 512 |
|
3865 |
! |
|
3866 |
||
3867 |
rightButtonStateMask |
|
3868 |
"return an integer for masking out the right button from a |
|
3869 |
buttonStates value" |
|
3870 |
||
3871 |
^ 1024 |
|
0 | 3872 |
! ! |
3873 |
||
3874 |
!XWorkstation methodsFor:'color stuff'! |
|
3875 |
||
3876 |
listOfAvailableColors |
|
3877 |
"return a list of all available colornames. |
|
3878 |
This should not be used, since colornames are very |
|
3879 |
display-specific (here X-specific)." |
|
3880 |
||
3881 |
|aStream list line index colorName| |
|
3882 |
||
3883 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
3884 |
aStream isNil ifTrue:[^ nil]. |
|
96 | 3885 |
list := OrderedCollection new. |
0 | 3886 |
[aStream atEnd] whileFalse:[ |
70 | 3887 |
line := aStream nextLine. |
3888 |
line notNil ifTrue:[ |
|
3889 |
"skip the r/g/b numbers" |
|
3890 |
index := 1. |
|
3891 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
3892 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
3893 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
3894 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
3895 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
3896 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
3897 |
colorName := line copyFrom:index. |
|
3898 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
3899 |
list add:colorName |
|
3900 |
] |
|
3901 |
] |
|
0 | 3902 |
]. |
3903 |
aStream close. |
|
3904 |
^ list sort |
|
3905 |
! |
|
3906 |
||
3907 |
freeColor:colorIndex |
|
3908 |
"free a display color when its no longer needed" |
|
3909 |
||
3910 |
%{ /* NOCONTEXT */ |
|
3911 |
||
3912 |
Display *dpy = myDpy; |
|
3913 |
unsigned long color; |
|
3914 |
int screen = _intVal(_INST(screen)); |
|
3915 |
||
193 | 3916 |
#ifdef LATER |
3917 |
if (_INST(visualType) == @symbol(TrueColor)) { |
|
3918 |
/* no need to do anything on TrueColor displays ... */ |
|
3919 |
RETURN (self); |
|
3920 |
} |
|
3921 |
#endif |
|
150 | 3922 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
70 | 3923 |
color = (long) _intVal(colorIndex); |
3924 |
BEGIN_INTERRUPTSBLOCKED |
|
3925 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
3926 |
END_INTERRUPTSBLOCKED |
|
3927 |
RETURN ( self ); |
|
0 | 3928 |
} |
3929 |
%} |
|
3930 |
. |
|
3931 |
self primitiveFailed |
|
3932 |
! |
|
3933 |
||
3934 |
percentToXColorValue:aPercentage |
|
3935 |
"given a color-component value in percent (0..100), return the corresponding |
|
3936 |
x-component value (0..65k) as an integer" |
|
3937 |
||
3938 |
%{ /* NOCONTEXT */ |
|
3939 |
||
97 | 3940 |
if (__isSmallInteger(aPercentage)) { |
70 | 3941 |
RETURN ( _MKSMALLINT(0xFFFF * _intVal(aPercentage) / 100) ); |
0 | 3942 |
} |
36 | 3943 |
if (__isFloat(aPercentage)) { |
70 | 3944 |
RETURN ( _MKSMALLINT(0xFFFF * (int)(_floatVal(aPercentage)) / 100) ); |
0 | 3945 |
} |
3946 |
%} |
|
3947 |
. |
|
3948 |
^ (16rFFFF * aPercentage / 100) rounded |
|
3949 |
! |
|
3950 |
||
3951 |
colorRed:redVal green:greenVal blue:blueVal |
|
3952 |
"allocate a color with rgb values (0..100) - return index" |
|
3953 |
||
3954 |
|r g b| |
|
3955 |
||
3956 |
r := self percentToXColorValue:redVal. |
|
3957 |
g := self percentToXColorValue:greenVal. |
|
3958 |
b := self percentToXColorValue:blueVal. |
|
3959 |
%{ |
|
3960 |
Display *dpy = myDpy; |
|
3961 |
XColor ecolor; |
|
3962 |
int screen = _intVal(_INST(screen)); |
|
54 | 3963 |
Status ok; |
0 | 3964 |
|
150 | 3965 |
if (__bothSmallInteger(r, g) |
3966 |
&& __isSmallInteger(b) |
|
3967 |
&& ISCONNECTED) { |
|
70 | 3968 |
ecolor.red = _intVal(r); |
3969 |
ecolor.green= _intVal(g); |
|
3970 |
ecolor.blue = _intVal(b); |
|
3971 |
BEGIN_INTERRUPTSBLOCKED |
|
3972 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
3973 |
END_INTERRUPTSBLOCKED |
|
3974 |
if (! ok) { |
|
3975 |
RETURN ( nil ); |
|
3976 |
} |
|
3977 |
RETURN ( _MKSMALLINT(ecolor.pixel) ); |
|
0 | 3978 |
} |
3979 |
%} |
|
3980 |
. |
|
43 | 3981 |
self primitiveFailed. |
3982 |
^ nil |
|
0 | 3983 |
! |
3984 |
||
3985 |
colorNamed:aString |
|
3986 |
"allocate a color with color name - return index. |
|
3987 |
Dont use this method, colornames are mostly X specific" |
|
3988 |
||
3989 |
%{ /* NOCONTEXT */ |
|
3990 |
||
3991 |
char *colorname; |
|
3992 |
Display *dpy = myDpy; |
|
3993 |
XColor scolor, ecolor; |
|
3994 |
int screen =_intVal(_INST(screen)); |
|
54 | 3995 |
Status ok; |
0 | 3996 |
|
150 | 3997 |
if (ISCONNECTED) { |
3998 |
if (__isString(aString) || __isSymbol(aString)) { |
|
3999 |
colorname = (char *)_stringVal(aString); |
|
4000 |
||
4001 |
BEGIN_INTERRUPTSBLOCKED |
|
4002 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
4003 |
if (ok) { |
|
4004 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
4005 |
} |
|
4006 |
END_INTERRUPTSBLOCKED |
|
4007 |
if (! ok) { |
|
4008 |
RETURN ( nil ); |
|
4009 |
} |
|
4010 |
RETURN ( _MKSMALLINT(ecolor.pixel) ); |
|
70 | 4011 |
} |
0 | 4012 |
} |
4013 |
%} |
|
4014 |
. |
|
43 | 4015 |
self primitiveFailed. |
4016 |
^ nil |
|
0 | 4017 |
! |
4018 |
||
4019 |
colorCell |
|
4020 |
"allocate a color cell - return index. |
|
4021 |
This method will return nil for StaticGrey and StaticGrey displays." |
|
4022 |
||
4023 |
%{ /* NOCONTEXT */ |
|
4024 |
||
4025 |
Display *dpy = myDpy; |
|
4026 |
int screen = _intVal(_INST(screen)); |
|
4027 |
XColor color; |
|
4028 |
unsigned long dummy; |
|
4029 |
Status ok; |
|
4030 |
||
54 | 4031 |
BEGIN_INTERRUPTSBLOCKED |
0 | 4032 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
70 | 4033 |
&dummy, 0, &color.pixel, 1); |
54 | 4034 |
END_INTERRUPTSBLOCKED |
0 | 4035 |
if (ok) { |
70 | 4036 |
RETURN ( _MKSMALLINT(color.pixel) ); |
0 | 4037 |
} |
4038 |
%} |
|
4039 |
. |
|
4040 |
^ nil |
|
4041 |
! |
|
4042 |
||
4043 |
setColor:index red:redVal green:greenVal blue:blueVal |
|
4044 |
"change color in map at:index to rgb (0..100). |
|
4045 |
This method is a noop for StaticGrey and StaticGrey displays." |
|
4046 |
||
4047 |
%{ /* NOCONTEXT */ |
|
4048 |
||
4049 |
char *colorname; |
|
4050 |
Display *dpy = myDpy; |
|
4051 |
XColor color; |
|
4052 |
int screen = _intVal(_INST(screen)); |
|
4053 |
int r, g, b; |
|
4054 |
int ok = 1; |
|
4055 |
||
97 | 4056 |
if (__isSmallInteger(redVal)) |
70 | 4057 |
r = 0xFFFF * _intVal(redVal) / 100; |
36 | 4058 |
else if (__isFloat(redVal)) |
70 | 4059 |
r = 0xFFFF * (int)(_floatVal(redVal)) / 100; |
0 | 4060 |
else ok = 0; |
4061 |
||
97 | 4062 |
if (__isSmallInteger(greenVal)) |
70 | 4063 |
g = 0xFFFF * _intVal(greenVal) / 100; |
36 | 4064 |
else if (__isFloat(greenVal)) |
70 | 4065 |
g = 0xFFFF * (int)(_floatVal(greenVal)) / 100; |
0 | 4066 |
else ok = 0; |
4067 |
||
97 | 4068 |
if (__isSmallInteger(blueVal)) |
70 | 4069 |
b = 0xFFFF * _intVal(blueVal) / 100; |
36 | 4070 |
else if (__isFloat(blueVal)) |
70 | 4071 |
b = 0xFFFF * (int)(_floatVal(blueVal)) / 100; |
0 | 4072 |
else ok = 0; |
4073 |
||
97 | 4074 |
if (__isSmallInteger(index) && ok) { |
70 | 4075 |
color.pixel = _intVal(index); |
4076 |
color.red = r; |
|
4077 |
color.green = g; |
|
4078 |
color.blue = b; |
|
4079 |
color.flags = DoRed | DoGreen | DoBlue; |
|
4080 |
||
4081 |
BEGIN_INTERRUPTSBLOCKED |
|
4082 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
4083 |
END_INTERRUPTSBLOCKED |
|
4084 |
RETURN ( self ); |
|
0 | 4085 |
} |
4086 |
%} |
|
4087 |
. |
|
4088 |
self primitiveFailed |
|
4089 |
! |
|
4090 |
||
4091 |
getRGBFromName:colorName into:aBlock |
|
4092 |
"get rgb components (0..100) of color named colorName, |
|
4093 |
and evaluate the 3-arg block, aBlock with them" |
|
4094 |
||
4095 |
|r g b| |
|
150 | 4096 |
|
4097 |
displayId isNil ifTrue:[ |
|
4098 |
self pimitiveFailed. |
|
4099 |
^ nil |
|
4100 |
]. |
|
0 | 4101 |
%{ |
4102 |
Display *dpy = myDpy; |
|
4103 |
int screen = _intVal(_INST(screen)); |
|
4104 |
XColor color; |
|
4105 |
double fr, fg, fb; |
|
4106 |
double floor(); |
|
4107 |
||
36 | 4108 |
if (__isString(colorName) || __isSymbol(colorName)) { |
70 | 4109 |
BEGIN_INTERRUPTSBLOCKED |
4110 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
4111 |
(char *)_stringVal(colorName), &color)) { |
|
4112 |
/* |
|
4113 |
* scale to 0..100 and round to the first decimal |
|
4114 |
*/ |
|
4115 |
fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
4116 |
fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
4117 |
fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
4118 |
||
212
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4119 |
r = _MKFLOAT(fr COMMA_CON); |
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4120 |
g = _MKFLOAT(fg COMMA_CON); |
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4121 |
b = _MKFLOAT(fb COMMA_CON); |
70 | 4122 |
} |
4123 |
END_INTERRUPTSBLOCKED |
|
0 | 4124 |
} |
4125 |
%} |
|
4126 |
. |
|
4127 |
aBlock value:r value:g value:b |
|
4128 |
! |
|
4129 |
||
4130 |
getRGBFrom:index into:aBlock |
|
4131 |
"get rgb components (0..100) of color in map at:index, |
|
4132 |
and evaluate the 3-arg block, aBlock with them" |
|
4133 |
||
4134 |
|r g b| |
|
4135 |
%{ |
|
4136 |
Display *dpy = myDpy; |
|
4137 |
int screen = _intVal(_INST(screen)); |
|
4138 |
XColor color; |
|
4139 |
double fr, fg, fb; |
|
4140 |
double floor(); |
|
4141 |
int bits, scale, shift; |
|
4142 |
||
97 | 4143 |
if (__isSmallInteger(index)) { |
70 | 4144 |
color.pixel = _intVal(index); |
4145 |
BEGIN_INTERRUPTSBLOCKED |
|
4146 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
4147 |
END_INTERRUPTSBLOCKED |
|
4148 |
||
4149 |
/* scale to 0..100 and round to the first decimal */ |
|
4150 |
||
4151 |
/* |
|
4152 |
* have to compensate for an error in X ?, which does not scale |
|
4153 |
* colors correctly if lesser than 16bits are valid in a color, |
|
4154 |
* (for example, color white on a 4bitsPerRGB server will return |
|
4155 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
4156 |
*/ |
|
4157 |
bits = _intVal(_INST(bitsPerRGB)); |
|
4158 |
scale = (1<<bits) - 1; |
|
4159 |
shift = 16 - bits; |
|
4160 |
||
4161 |
fr = floor( ( ((double)(color.red>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
4162 |
fg = floor( ( ((double)(color.green>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
4163 |
fb = floor( ( ((double)(color.blue>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
4164 |
||
212
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4165 |
r = _MKFLOAT(fr COMMA_CON); |
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4166 |
g = _MKFLOAT(fg COMMA_CON); |
fc4c2afefff1
on IRIX5: no remote GL (to avoid exit in gl)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
4167 |
b = _MKFLOAT(fb COMMA_CON); |
0 | 4168 |
} |
157 | 4169 |
%}. |
0 | 4170 |
aBlock value:r value:g value:b |
4171 |
! ! |
|
4172 |
||
4173 |
!XWorkstation methodsFor:'window stuff'! |
|
4174 |
||
4175 |
setBackingStore:how in:aWindowId |
|
4176 |
"turn on/off backing-store for a window" |
|
4177 |
||
4178 |
%{ /* NOCONTEXT */ |
|
4179 |
||
4180 |
XSetWindowAttributes wa; |
|
4181 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4182 |
if (__isExternalAddress(aWindowId)) { |
70 | 4183 |
if (_INST(ignoreBackingStore) != true) { |
4184 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
4185 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
4186 |
else if (how == true) wa.backing_store = Always; |
|
4187 |
else wa.backing_store = 0; |
|
4188 |
BEGIN_INTERRUPTSBLOCKED |
|
4189 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
4190 |
END_INTERRUPTSBLOCKED |
|
4191 |
} |
|
4192 |
RETURN ( self ); |
|
0 | 4193 |
} |
157 | 4194 |
%}. |
0 | 4195 |
self primitiveFailed |
4196 |
! |
|
4197 |
||
72 | 4198 |
setBitGravity:how in:aWindowId |
4199 |
"set bit gravity for a window" |
|
4200 |
||
4201 |
%{ /* NOCONTEXT */ |
|
4202 |
||
4203 |
XSetWindowAttributes wa; |
|
4204 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4205 |
if (__isExternalAddress(aWindowId)) { |
72 | 4206 |
if (how == @symbol(NorthWest)) { |
4207 |
wa.bit_gravity = NorthWestGravity; |
|
4208 |
} else if (how == @symbol(NorthEast)) { |
|
4209 |
wa.bit_gravity = NorthEastGravity; |
|
4210 |
} else if (how == @symbol(SouthWest)) { |
|
4211 |
wa.bit_gravity = SouthWestGravity; |
|
4212 |
} else if (how == @symbol(SouthEast)) { |
|
4213 |
wa.bit_gravity = SouthEastGravity; |
|
4214 |
} else if (how == @symbol(Center)) { |
|
4215 |
wa.bit_gravity = CenterGravity; |
|
4216 |
} else if (how == @symbol(North)) { |
|
4217 |
wa.bit_gravity = NorthGravity; |
|
4218 |
} else if (how == @symbol(South)) { |
|
4219 |
wa.bit_gravity = SouthGravity; |
|
4220 |
} else if (how == @symbol(West)) { |
|
4221 |
wa.bit_gravity = WestGravity; |
|
4222 |
} else if (how == @symbol(East)) { |
|
4223 |
wa.bit_gravity = EastGravity; |
|
4224 |
} else { |
|
4225 |
wa.bit_gravity = NorthWestGravity; |
|
4226 |
} |
|
4227 |
||
4228 |
BEGIN_INTERRUPTSBLOCKED |
|
4229 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
4230 |
END_INTERRUPTSBLOCKED |
|
4231 |
RETURN ( self ); |
|
4232 |
} |
|
157 | 4233 |
%}. |
72 | 4234 |
self primitiveFailed |
4235 |
! |
|
4236 |
||
4237 |
setWindowGravity:how in:aWindowId |
|
4238 |
"set window gravity for a window" |
|
4239 |
||
4240 |
%{ /* NOCONTEXT */ |
|
4241 |
||
4242 |
XSetWindowAttributes wa; |
|
4243 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4244 |
if (__isExternalAddress(aWindowId)) { |
72 | 4245 |
if (how == @symbol(NorthWest)) { |
4246 |
wa.win_gravity = NorthWestGravity; |
|
4247 |
} else if (how == @symbol(NorthEast)) { |
|
4248 |
wa.win_gravity = NorthEastGravity; |
|
4249 |
} else if (how == @symbol(SouthWest)) { |
|
4250 |
wa.win_gravity = SouthWestGravity; |
|
4251 |
} else if (how == @symbol(SouthEast)) { |
|
4252 |
wa.win_gravity = SouthEastGravity; |
|
4253 |
} else if (how == @symbol(Center)) { |
|
4254 |
wa.win_gravity = CenterGravity; |
|
4255 |
} else if (how == @symbol(North)) { |
|
4256 |
wa.win_gravity = NorthGravity; |
|
4257 |
} else if (how == @symbol(South)) { |
|
4258 |
wa.win_gravity = SouthGravity; |
|
4259 |
} else if (how == @symbol(West)) { |
|
4260 |
wa.win_gravity = WestGravity; |
|
4261 |
} else if (how == @symbol(East)) { |
|
4262 |
wa.win_gravity = EastGravity; |
|
4263 |
} else { |
|
4264 |
wa.win_gravity = NorthWestGravity; |
|
4265 |
} |
|
4266 |
||
4267 |
BEGIN_INTERRUPTSBLOCKED |
|
4268 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
4269 |
END_INTERRUPTSBLOCKED |
|
4270 |
RETURN ( self ); |
|
4271 |
} |
|
157 | 4272 |
%}. |
72 | 4273 |
self primitiveFailed |
4274 |
! |
|
4275 |
||
0 | 4276 |
setSaveUnder:yesOrNo in:aWindowId |
4277 |
"turn on/off save-under for a window" |
|
4278 |
||
4279 |
%{ /* NOCONTEXT */ |
|
4280 |
||
4281 |
XSetWindowAttributes wa; |
|
4282 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4283 |
if (__isExternalAddress(aWindowId)) { |
70 | 4284 |
if (_INST(hasSaveUnder) == true) { |
4285 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
4286 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
4287 |
} |
|
4288 |
RETURN ( self ); |
|
0 | 4289 |
} |
157 | 4290 |
%}. |
0 | 4291 |
self primitiveFailed |
4292 |
! |
|
4293 |
||
4294 |
setWindowBackground:aColorIndex in:aWindowId |
|
90 | 4295 |
"set the windows background color. This is the color with which |
4296 |
the view is filled whenever exposed. Do not confuse this with |
|
4297 |
the background drawing color, which is used with opaque drawing." |
|
0 | 4298 |
|
4299 |
%{ /* NOCONTEXT */ |
|
4300 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4301 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4302 |
&& __isSmallInteger(aColorIndex)) { |
70 | 4303 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex)); |
4304 |
RETURN ( self ); |
|
0 | 4305 |
} |
157 | 4306 |
%}. |
0 | 4307 |
self primitiveFailed |
4308 |
! |
|
4309 |
||
4310 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
90 | 4311 |
"set the windows background pattern to be a form. |
4312 |
This is the pattern with which the view is filled whenever exposed. |
|
4313 |
Do not confuse this with the background drawing color, which is used |
|
4314 |
with opaque drawing." |
|
0 | 4315 |
|
4316 |
%{ /* NOCONTEXT */ |
|
4317 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4318 |
if (__isExternalAddress(aWindowId) |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
4319 |
&& __isExternalAddress(aPixmapId)) { |
70 | 4320 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
4321 |
RETURN ( self ); |
|
0 | 4322 |
} |
157 | 4323 |
%}. |
0 | 4324 |
self primitiveFailed |
4325 |
! |
|
4326 |
||
4327 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
4328 |
"set the windows border color" |
|
4329 |
||
4330 |
%{ /* NOCONTEXT */ |
|
4331 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4332 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4333 |
&& __isSmallInteger(aColorIndex)) { |
70 | 4334 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), _intVal(aColorIndex)); |
4335 |
RETURN ( self ); |
|
0 | 4336 |
} |
157 | 4337 |
%}. |
0 | 4338 |
self primitiveFailed |
4339 |
! |
|
4340 |
||
4341 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
12 | 4342 |
"set the windows border pattern" |
0 | 4343 |
|
4344 |
%{ /* NOCONTEXT */ |
|
4345 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4346 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4347 |
&& __isExternalAddress(aPixmapId)) { |
70 | 4348 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
4349 |
RETURN ( self ); |
|
0 | 4350 |
} |
4351 |
%} |
|
4352 |
. |
|
4353 |
self primitiveFailed |
|
4354 |
! |
|
4355 |
||
4356 |
setWindowBorderWidth:aNumber in:aWindowId |
|
12 | 4357 |
"set the windows border width" |
0 | 4358 |
|
4359 |
%{ /* NOCONTEXT */ |
|
4360 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4361 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4362 |
&& __isSmallInteger(aNumber)) { |
70 | 4363 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), _intVal(aNumber)); |
4364 |
RETURN ( self ); |
|
0 | 4365 |
} |
157 | 4366 |
%}. |
0 | 4367 |
self primitiveFailed |
4368 |
! |
|
4369 |
||
4370 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
12 | 4371 |
"set the windows border shape" |
4372 |
||
0 | 4373 |
hasShapeExtension ifFalse:[^ self]. |
4374 |
||
4375 |
%{ /* NOCONTEXT */ |
|
4376 |
||
4377 |
#ifdef SHAPE |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4378 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4379 |
&& __isExternalAddress(aPixmapId)) { |
70 | 4380 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
4381 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
4382 |
RETURN ( self ); |
|
0 | 4383 |
} |
4384 |
#endif |
|
157 | 4385 |
%}. |
0 | 4386 |
self primitiveFailed |
4387 |
! |
|
4388 |
||
4389 |
setWindowShape:aPixmapId in:aWindowId |
|
12 | 4390 |
"set the windows shape" |
4391 |
||
0 | 4392 |
hasShapeExtension ifFalse:[^ self]. |
4393 |
||
4394 |
%{ /* NOCONTEXT */ |
|
4395 |
||
4396 |
#ifdef SHAPE |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4397 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4398 |
&& __isExternalAddress(aPixmapId)) { |
70 | 4399 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
4400 |
0, 0, |
|
4401 |
_PixmapVal(aPixmapId), ShapeSet); |
|
4402 |
RETURN ( self ); |
|
0 | 4403 |
} |
4404 |
#endif |
|
157 | 4405 |
%}. |
0 | 4406 |
self primitiveFailed |
4407 |
! |
|
4408 |
||
4409 |
setCursor:aCursorId in:aWindowId |
|
12 | 4410 |
"define a windows cursor" |
0 | 4411 |
|
4412 |
%{ /* NOCONTEXT */ |
|
4413 |
||
4414 |
Display *dpy = myDpy; |
|
4415 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4416 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4417 |
&& __isExternalAddress(aCursorId)) { |
70 | 4418 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
4419 |
RETURN ( self ); |
|
0 | 4420 |
} |
157 | 4421 |
%}. |
0 | 4422 |
self primitiveFailed |
4423 |
! |
|
4424 |
||
4425 |
setWindowName:aString in:aWindowId |
|
12 | 4426 |
"define a windows name" |
0 | 4427 |
|
4428 |
%{ /* NOCONTEXT */ |
|
4429 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4430 |
if (__isExternalAddress(aWindowId) |
36 | 4431 |
&& (__isString(aString) || __isSymbol(aString))) { |
70 | 4432 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
4433 |
RETURN ( self ); |
|
0 | 4434 |
} |
157 | 4435 |
%}. |
0 | 4436 |
self primitiveFailed |
4437 |
! |
|
4438 |
||
4439 |
setIconName:aString in:aWindowId |
|
12 | 4440 |
"define a windows iconname" |
0 | 4441 |
|
4442 |
%{ /* NOCONTEXT */ |
|
4443 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4444 |
if (__isExternalAddress(aWindowId) |
36 | 4445 |
&& (__isString(aString) || __isSymbol(aString))) { |
70 | 4446 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
4447 |
RETURN ( self ); |
|
0 | 4448 |
} |
157 | 4449 |
%}. |
0 | 4450 |
self primitiveFailed |
4451 |
! |
|
4452 |
||
4453 |
setWindowIcon:aForm in:aWindowId |
|
12 | 4454 |
"define a bitmap to be used as icon" |
4455 |
||
0 | 4456 |
|iconId| |
4457 |
||
4458 |
aForm notNil ifTrue:[ |
|
70 | 4459 |
iconId := aForm id |
0 | 4460 |
]. |
4461 |
%{ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4462 |
if (__isExternalAddress(iconId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4463 |
&& __isExternalAddress(aWindowId)) { |
70 | 4464 |
XWMHints hints; |
4465 |
||
4466 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
4467 |
hints.flags = IconPixmapHint; |
|
4468 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
4469 |
RETURN ( self ); |
|
0 | 4470 |
} |
157 | 4471 |
%}. |
0 | 4472 |
self primitiveFailed |
4473 |
! |
|
4474 |
||
4475 |
setWindowIconWindow:aView in:aWindowId |
|
12 | 4476 |
"define a window to be used as icon" |
4477 |
||
0 | 4478 |
|iconWindowId| |
4479 |
||
4480 |
aView notNil ifTrue:[ |
|
70 | 4481 |
iconWindowId := aView id |
0 | 4482 |
]. |
4483 |
%{ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4484 |
if (__isExternalAddress(iconWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4485 |
&& __isExternalAddress(aWindowId)) { |
157 | 4486 |
XWMHints wmhints; |
4487 |
||
4488 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
4489 |
wmhints.flags = IconWindowHint; |
|
4490 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
70 | 4491 |
RETURN ( self ); |
0 | 4492 |
} |
157 | 4493 |
%}. |
0 | 4494 |
self primitiveFailed |
4495 |
! |
|
4496 |
||
54 | 4497 |
setTransient:aWindowId for:aMainWindowId |
4498 |
"set aWindowId to be a transient of aMainWindow" |
|
4499 |
||
4500 |
%{ /* NOCONTEXT */ |
|
4501 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4502 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4503 |
&& __isExternalAddress(aMainWindowId)) { |
70 | 4504 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), |
4505 |
_WindowVal(aMainWindowId)); |
|
4506 |
RETURN ( self ); |
|
54 | 4507 |
} |
157 | 4508 |
%}. |
54 | 4509 |
self primitiveFailed |
4510 |
! |
|
4511 |
||
0 | 4512 |
clearWindow:aWindowId |
12 | 4513 |
"clear a window to viewbackground" |
0 | 4514 |
|
4515 |
%{ /* NOCONTEXT */ |
|
4516 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4517 |
if (__isExternalAddress(aWindowId)) { |
70 | 4518 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
4519 |
RETURN ( self ); |
|
0 | 4520 |
} |
4521 |
%} |
|
4522 |
. |
|
4523 |
self primitiveFailed |
|
4524 |
! |
|
4525 |
||
4526 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
12 | 4527 |
"clear a rectangular area to viewbackground" |
0 | 4528 |
|
4529 |
%{ /* NOCONTEXT */ |
|
4530 |
||
4531 |
int w, h; |
|
4532 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4533 |
if (__isExternalAddress(aWindowId) |
97 | 4534 |
&& __bothSmallInteger(x, y) |
4535 |
&& __bothSmallInteger(width, height)) { |
|
70 | 4536 |
w = _intVal(width); |
4537 |
h = _intVal(height); |
|
4538 |
if (w < 0) w = 0; |
|
4539 |
if (h < 0) h = 0; |
|
4540 |
XClearArea(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y), w, h, 0); |
|
4541 |
RETURN ( self ); |
|
0 | 4542 |
} |
4543 |
%} |
|
4544 |
. |
|
4545 |
self primitiveFailed |
|
4546 |
! |
|
4547 |
||
23 | 4548 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
4549 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
4550 |
||
4551 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
4552 |
||
4553 |
aBoolean ifTrue:[ |
|
70 | 4554 |
wicon := aView icon. |
4555 |
wicon notNil ifTrue:[ |
|
4556 |
wiconId := wicon id |
|
4557 |
]. |
|
4558 |
wiconView := aView iconView. |
|
4559 |
wiconView notNil ifTrue:[ |
|
4560 |
wiconViewId := wiconView id |
|
4561 |
]. |
|
4562 |
wlabel := aView label. |
|
23 | 4563 |
]. |
4564 |
%{ |
|
4565 |
||
4566 |
XWMHints wmhints; |
|
0 | 4567 |
XSizeHints szhints; |
4568 |
Display *dpy = myDpy; |
|
4569 |
Window win; |
|
4570 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4571 |
if (__isExternalAddress(aWindowId)) { |
70 | 4572 |
win = _WindowVal(aWindowId); |
4573 |
||
4574 |
szhints.flags = 0; |
|
97 | 4575 |
if (__bothSmallInteger(xPos, yPos)) { |
70 | 4576 |
szhints.x = _intVal(xPos); |
4577 |
szhints.y = _intVal(yPos); |
|
4578 |
szhints.flags |= USPosition; |
|
4579 |
} |
|
97 | 4580 |
if (__bothSmallInteger(w, h)) { |
70 | 4581 |
szhints.width = _intVal(w); |
4582 |
szhints.height = _intVal(h); |
|
4583 |
szhints.flags |= USSize; |
|
4584 |
} |
|
4585 |
||
4586 |
if (aBoolean == true) { |
|
4587 |
char *windowName; |
|
4588 |
Pixmap iconBitmap = (Pixmap)0; |
|
4589 |
Window iconWindow; |
|
4590 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4591 |
if (__isExternalAddress(wiconId)) |
70 | 4592 |
iconBitmap = _PixmapVal(wiconId); |
4593 |
else |
|
4594 |
iconBitmap = (Pixmap)0; |
|
4595 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4596 |
if (__isExternalAddress(wiconViewId)) |
70 | 4597 |
iconWindow = _WindowVal(wiconViewId); |
4598 |
else |
|
4599 |
iconWindow = (Window)0; |
|
4600 |
||
4601 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
4602 |
windowName = (char *)_stringVal(wlabel); |
|
4603 |
else |
|
4604 |
windowName = ""; |
|
4605 |
||
4606 |
if (iconBitmap || windowName) { |
|
4607 |
XSetStandardProperties(dpy, win, |
|
4608 |
windowName, windowName, |
|
4609 |
iconBitmap, |
|
4610 |
0, 0, &szhints); |
|
4611 |
} |
|
4612 |
||
4613 |
wmhints.flags = 0; |
|
4614 |
if (iconBitmap) { |
|
4615 |
wmhints.flags |= IconPixmapHint; |
|
4616 |
wmhints.icon_pixmap = iconBitmap; |
|
4617 |
} |
|
4618 |
if (iconWindow) { |
|
4619 |
wmhints.flags |= IconWindowHint; |
|
4620 |
wmhints.icon_window = iconWindow; |
|
4621 |
} |
|
4622 |
||
4623 |
wmhints.initial_state = IconicState; |
|
4624 |
wmhints.flags |= StateHint; |
|
4625 |
XSetWMHints(dpy, win, &wmhints); |
|
4626 |
} |
|
4627 |
||
4628 |
if (szhints.flags) { |
|
4629 |
XSetNormalHints(dpy, win, &szhints); |
|
4630 |
} |
|
4631 |
||
4632 |
XMapWindow(dpy, win); |
|
4633 |
RETURN ( self ); |
|
0 | 4634 |
} |
4635 |
%} |
|
4636 |
. |
|
4637 |
self primitiveFailed |
|
4638 |
! |
|
4639 |
||
4640 |
mapWindow:aWindowId |
|
12 | 4641 |
"make a window visible" |
0 | 4642 |
|
4643 |
%{ /* NOCONTEXT */ |
|
4644 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4645 |
if (__isExternalAddress(aWindowId)) { |
70 | 4646 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
4647 |
RETURN ( self ); |
|
0 | 4648 |
} |
4649 |
%} |
|
4650 |
. |
|
4651 |
self primitiveFailed |
|
4652 |
! |
|
4653 |
||
4654 |
unmapWindow:aWindowId |
|
12 | 4655 |
"make a window invisible" |
0 | 4656 |
|
4657 |
%{ /* NOCONTEXT */ |
|
4658 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4659 |
if (__isExternalAddress(aWindowId)) { |
70 | 4660 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
4661 |
RETURN ( self ); |
|
0 | 4662 |
} |
4663 |
%} |
|
4664 |
. |
|
4665 |
self primitiveFailed |
|
4666 |
! |
|
4667 |
||
4668 |
raiseWindow:aWindowId |
|
12 | 4669 |
"bring a window to front" |
0 | 4670 |
|
4671 |
%{ /* NOCONTEXT */ |
|
4672 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4673 |
if (__isExternalAddress(aWindowId)) { |
70 | 4674 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
4675 |
RETURN ( self ); |
|
0 | 4676 |
} |
4677 |
%} |
|
4678 |
. |
|
4679 |
self primitiveFailed |
|
4680 |
! |
|
4681 |
||
4682 |
lowerWindow:aWindowId |
|
12 | 4683 |
"bring a window to back" |
0 | 4684 |
|
4685 |
%{ /* NOCONTEXT */ |
|
4686 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4687 |
if (__isExternalAddress(aWindowId)) { |
70 | 4688 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
4689 |
RETURN ( self ); |
|
0 | 4690 |
} |
4691 |
%} |
|
4692 |
. |
|
4693 |
self primitiveFailed |
|
4694 |
! |
|
4695 |
||
4696 |
moveWindow:aWindowId x:x y:y |
|
12 | 4697 |
"move a window" |
0 | 4698 |
|
4699 |
%{ /* NOCONTEXT */ |
|
4700 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4701 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
70 | 4702 |
XMoveWindow(myDpy, _WindowVal(aWindowId), _intVal(x), _intVal(y)); |
4703 |
RETURN ( self ); |
|
0 | 4704 |
} |
4705 |
%} |
|
4706 |
. |
|
4707 |
self primitiveFailed |
|
4708 |
! |
|
4709 |
||
4710 |
resizeWindow:aWindowId width:w height:h |
|
12 | 4711 |
"resize a window" |
0 | 4712 |
|
4713 |
%{ /* NOCONTEXT */ |
|
200 | 4714 |
|
0 | 4715 |
int newWidth, newHeight; |
4716 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4717 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
70 | 4718 |
newWidth = _intVal(w); |
4719 |
newHeight = _intVal(h); |
|
4720 |
if (newWidth < 1) newWidth = 1; |
|
4721 |
if (newHeight < 1) newHeight = 1; |
|
4722 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
4723 |
RETURN ( self ); |
|
0 | 4724 |
} |
4725 |
%} |
|
4726 |
. |
|
4727 |
self primitiveFailed |
|
4728 |
! |
|
4729 |
||
4730 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
12 | 4731 |
"move and resize a window" |
0 | 4732 |
|
4733 |
%{ /* NOCONTEXT */ |
|
200 | 4734 |
|
0 | 4735 |
int newWidth, newHeight; |
4736 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4737 |
if (__isExternalAddress(aWindowId) |
97 | 4738 |
&& __bothSmallInteger(w, h) |
4739 |
&& __bothSmallInteger(x, y)) { |
|
70 | 4740 |
newWidth = _intVal(w); |
4741 |
newHeight = _intVal(h); |
|
4742 |
if (newWidth < 1) newWidth = 1; |
|
4743 |
if (newHeight < 1) newHeight = 1; |
|
4744 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
4745 |
_intVal(x), _intVal(y), |
|
4746 |
newWidth, newHeight); |
|
4747 |
RETURN ( self ); |
|
0 | 4748 |
} |
4749 |
%} |
|
4750 |
. |
|
4751 |
self primitiveFailed |
|
70 | 4752 |
! |
4753 |
||
4754 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
4755 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
4756 |
||
4757 |
%{ /* NOCONTEXT */ |
|
4758 |
||
4759 |
XWindowChanges chg; |
|
4760 |
int mask = CWSibling | CWStackMode; |
|
4761 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4762 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4763 |
&& __isExternalAddress(siblingId)) { |
70 | 4764 |
if (modeSymbol == @symbol(above)) { |
4765 |
chg.stack_mode = Above; |
|
4766 |
} else if (modeSymbol == @symbol(below)) { |
|
4767 |
chg.stack_mode = Below; |
|
4768 |
} else if (modeSymbol == @symbol(topIf)) { |
|
4769 |
chg.stack_mode = TopIf; |
|
4770 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
4771 |
chg.stack_mode = BottomIf; |
|
4772 |
} else if (modeSymbol == @symbol(opposite)) { |
|
4773 |
chg.stack_mode = Opposite; |
|
4774 |
} else { |
|
4775 |
mask = CWSibling; |
|
4776 |
} |
|
4777 |
||
4778 |
chg.sibling = _WindowVal(siblingId); |
|
4779 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
4780 |
mask, &chg); |
|
4781 |
RETURN ( self ); |
|
4782 |
} |
|
4783 |
bad: ; |
|
4784 |
%} |
|
4785 |
. |
|
4786 |
self primitiveFailed |
|
0 | 4787 |
! ! |
4788 |
||
157 | 4789 |
!XWorkstation ignoredMethodsFor:'window stuff'! |
4790 |
||
4791 |
iconifyWindow:aWindowId |
|
4792 |
"iconify a topView" |
|
4793 |
||
4794 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4795 |
if (__isExternalAddress(aWindowId)) { |
157 | 4796 |
XWMHints wmhints; |
4797 |
||
4798 |
wmhints.initial_state = IconicState; |
|
4799 |
wmhints.flags |= StateHint; |
|
4800 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
4801 |
RETURN ( self ); |
|
4802 |
} |
|
4803 |
%}. |
|
4804 |
self primitiveFailed |
|
4805 |
! ! |
|
4806 |
||
0 | 4807 |
!XWorkstation methodsFor:'graphic context stuff'! |
4808 |
||
4809 |
setForeground:fgColorIndex in:aGCId |
|
4810 |
"set foreground color to be drawn with" |
|
4811 |
||
4812 |
%{ /* NOCONTEXT */ |
|
4813 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4814 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4815 |
&& __isSmallInteger(fgColorIndex)) { |
70 | 4816 |
XSetForeground(myDpy, _GCVal(aGCId), _intVal(fgColorIndex)); |
4817 |
RETURN ( self ); |
|
0 | 4818 |
} |
4819 |
%} |
|
4820 |
. |
|
4821 |
self primitiveFailed |
|
4822 |
! |
|
4823 |
||
4824 |
setBackground:bgColorIndex in:aGCId |
|
4825 |
"set background color to be drawn with" |
|
4826 |
||
4827 |
%{ /* NOCONTEXT */ |
|
4828 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4829 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4830 |
&& __isSmallInteger(bgColorIndex)) { |
70 | 4831 |
XSetBackground(myDpy, _GCVal(aGCId), _intVal(bgColorIndex)); |
4832 |
RETURN ( self ); |
|
0 | 4833 |
} |
4834 |
%} |
|
4835 |
. |
|
4836 |
self primitiveFailed |
|
4837 |
! |
|
4838 |
||
4839 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
4840 |
"set foreground and background colors to be drawn with" |
|
4841 |
||
4842 |
%{ /* NOCONTEXT */ |
|
4843 |
||
4844 |
Display *dpy = myDpy; |
|
4845 |
GC gc = _GCVal(aGCId); |
|
4846 |
||
97 | 4847 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4848 |
&& __isExternalAddress(aGCId)) { |
70 | 4849 |
XSetForeground(dpy, gc, _intVal(fgColorIndex)); |
4850 |
XSetBackground(dpy, gc, _intVal(bgColorIndex)); |
|
4851 |
RETURN ( self ); |
|
0 | 4852 |
} |
4853 |
%} |
|
4854 |
. |
|
4855 |
self primitiveFailed |
|
4856 |
! |
|
4857 |
||
4858 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
4859 |
"set foreground and background colors to be drawn with using mask or |
|
4860 |
solid (if aBitmapId is nil)" |
|
4861 |
||
4862 |
%{ /* NOCONTEXT */ |
|
4863 |
||
4864 |
Display *dpy = myDpy; |
|
4865 |
GC gc = _GCVal(aGCId); |
|
4866 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4867 |
if (__isExternalAddress(aGCId)) { |
97 | 4868 |
if (__isSmallInteger(fgColor)) |
70 | 4869 |
XSetForeground(dpy, gc, _intVal(fgColor)); |
97 | 4870 |
if (__isSmallInteger(bgColor)) |
70 | 4871 |
XSetBackground(dpy, gc, _intVal(bgColor)); |
4872 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4873 |
if (__isExternalAddress(aBitmapId)) { |
70 | 4874 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
4875 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
4876 |
RETURN ( self ); |
|
4877 |
} |
|
4878 |
if (aBitmapId == nil) { |
|
4879 |
XSetFillStyle(dpy, gc, FillSolid); |
|
4880 |
RETURN ( self ); |
|
4881 |
} |
|
0 | 4882 |
} |
4883 |
%} |
|
4884 |
. |
|
4885 |
self primitiveFailed |
|
4886 |
! |
|
4887 |
||
4888 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
4889 |
"set line attributes" |
|
4890 |
||
4891 |
%{ /* NOCONTEXT */ |
|
4892 |
||
4893 |
int x_style, x_cap, x_join; |
|
4894 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4895 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4896 |
&& __isSmallInteger(aNumber)) { |
97 | 4897 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
4898 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
4899 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
4900 |
else goto bad; |
|
4901 |
||
4902 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
4903 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
4904 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
4905 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
4906 |
else goto bad; |
|
4907 |
||
4908 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
4909 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
4910 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
4911 |
else goto bad; |
|
4912 |
||
4913 |
XSetLineAttributes(myDpy, |
|
70 | 4914 |
_GCVal(aGCId), _intVal(aNumber), |
4915 |
x_style, x_cap, x_join); |
|
97 | 4916 |
RETURN ( self ); |
0 | 4917 |
} |
4918 |
bad: ; |
|
4919 |
%} |
|
4920 |
. |
|
97 | 4921 |
" |
4922 |
either aGCId is invalid, |
|
4923 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
4924 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
4925 |
and/or joinStyle is none of #miter, #bevel, #round |
|
4926 |
" |
|
0 | 4927 |
self primitiveFailed |
4928 |
! |
|
4929 |
||
4930 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
4931 |
"set foreground and background colors to be drawn with using mask or |
|
4932 |
solid (if aBitmapId is nil); also set lineWidth" |
|
4933 |
||
4934 |
%{ /* NOCONTEXT */ |
|
4935 |
||
4936 |
Display *dpy = myDpy; |
|
4937 |
GC gc = _GCVal(aGCId); |
|
4938 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4939 |
if (__isExternalAddress(aGCId)) { |
97 | 4940 |
if (__isSmallInteger(lw)) { |
70 | 4941 |
XSetLineAttributes(dpy, gc, _intVal(lw), |
4942 |
LineSolid, CapNotLast, JoinMiter); |
|
4943 |
} |
|
97 | 4944 |
if (__isSmallInteger(fgColor)) |
70 | 4945 |
XSetForeground(dpy, gc, _intVal(fgColor)); |
97 | 4946 |
if (__isSmallInteger(bgColor)) |
70 | 4947 |
XSetBackground(dpy, gc, _intVal(bgColor)); |
4948 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4949 |
if (__isExternalAddress(aBitmapId)) { |
70 | 4950 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
4951 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
4952 |
RETURN ( self ); |
|
4953 |
} |
|
4954 |
if (aBitmapId == nil) { |
|
4955 |
XSetFillStyle(dpy, gc, FillSolid); |
|
4956 |
RETURN ( self ); |
|
4957 |
} |
|
0 | 4958 |
} |
4959 |
%} |
|
4960 |
. |
|
4961 |
self primitiveFailed |
|
4962 |
! |
|
4963 |
||
4964 |
setFunction:aFunctionSymbol in:aGCId |
|
4965 |
"set alu function to be drawn with" |
|
4966 |
||
4967 |
%{ /* NOCONTEXT */ |
|
4968 |
||
4969 |
GC gc = _GCVal(aGCId); |
|
4970 |
int fun = -1; |
|
4971 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
4972 |
if (__isExternalAddress(aGCId)) { |
70 | 4973 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
4974 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
4975 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
4976 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
4977 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
4978 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
4979 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
4980 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
4981 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
4982 |
if (fun != -1) { |
|
4983 |
XSetFunction(myDpy, gc, fun); |
|
4984 |
RETURN ( self ); |
|
4985 |
} |
|
0 | 4986 |
} |
4987 |
%} |
|
4988 |
. |
|
43 | 4989 |
" |
4990 |
either aGCId is not an integer, or an invalid symbol |
|
97 | 4991 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
4992 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
43 | 4993 |
" |
0 | 4994 |
self primitiveFailed |
4995 |
! |
|
4996 |
||
4997 |
setFont:aFontId in:aGCId |
|
4998 |
"set font to be drawn in" |
|
4999 |
||
5000 |
%{ /* NOCONTEXT */ |
|
5001 |
||
5002 |
XFontStruct *f; |
|
5003 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5004 |
if (__isExternalAddress(aFontId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5005 |
&& __isExternalAddress(aGCId)) { |
70 | 5006 |
f = (XFontStruct *) _FontVal(aFontId); |
5007 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5008 |
RETURN ( self ); |
|
0 | 5009 |
} |
5010 |
%} |
|
5011 |
. |
|
43 | 5012 |
" |
5013 |
aGCId and/or aFontId are invalid |
|
5014 |
" |
|
0 | 5015 |
self primitiveFailed |
5016 |
! |
|
5017 |
||
5018 |
setPixmapMask:aPixmapId in:aGCId |
|
5019 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5020 |
||
5021 |
%{ /* NOCONTEXT */ |
|
5022 |
||
5023 |
Display *dpy = myDpy; |
|
5024 |
GC gc = _GCVal(aGCId); |
|
5025 |
Pixmap pixmap; |
|
5026 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5027 |
if (__isExternalAddress(aGCId)) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5028 |
if (__isExternalAddress(aPixmapId)) { |
70 | 5029 |
pixmap = _PixmapVal(aPixmapId); |
5030 |
XSetTile(dpy, gc, pixmap); |
|
5031 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5032 |
RETURN ( self ); |
|
5033 |
} |
|
5034 |
if (aPixmapId == nil) { |
|
5035 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5036 |
RETURN ( self ); |
|
5037 |
} |
|
0 | 5038 |
} |
5039 |
%} |
|
5040 |
. |
|
5041 |
self primitiveFailed |
|
5042 |
! |
|
5043 |
||
5044 |
setBitmapMask:aBitmapId in:aGCId |
|
5045 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5046 |
||
5047 |
%{ /* NOCONTEXT */ |
|
5048 |
||
5049 |
Display *dpy = myDpy; |
|
5050 |
GC gc = _GCVal(aGCId); |
|
5051 |
Pixmap bitmap; |
|
5052 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5053 |
if (__isExternalAddress(aGCId)) { |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5054 |
if (__isExternalAddress(aBitmapId)) { |
70 | 5055 |
bitmap = _PixmapVal(aBitmapId); |
5056 |
XSetStipple(dpy, gc, bitmap); |
|
5057 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5058 |
RETURN ( self ); |
|
5059 |
} |
|
5060 |
if (aBitmapId == nil) { |
|
5061 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5062 |
RETURN ( self ); |
|
5063 |
} |
|
0 | 5064 |
} |
5065 |
%} |
|
5066 |
. |
|
5067 |
self primitiveFailed |
|
5068 |
! |
|
5069 |
||
5070 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5071 |
"set the mask origin" |
|
5072 |
||
5073 |
%{ /* NOCONTEXT */ |
|
5074 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5075 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
70 | 5076 |
XSetTSOrigin(myDpy, _GCVal(aGCid), _intVal(orgX), _intVal(orgY)); |
5077 |
RETURN ( self ); |
|
0 | 5078 |
} |
5079 |
%} |
|
5080 |
. |
|
5081 |
self primitiveFailed |
|
5082 |
! |
|
5083 |
||
5084 |
setClipByChildren:aBool in:aGCId |
|
5085 |
"enable/disable drawing into child views" |
|
5086 |
||
5087 |
%{ /* NOCONTEXT */ |
|
5088 |
||
5089 |
XGCValues gcv; |
|
5090 |
GC gc = _GCVal(aGCId); |
|
5091 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5092 |
if (__isExternalAddress(aGCId)) { |
70 | 5093 |
if (aBool == true) |
5094 |
gcv.subwindow_mode = ClipByChildren; |
|
5095 |
else |
|
5096 |
gcv.subwindow_mode = IncludeInferiors; |
|
5097 |
||
5098 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5099 |
RETURN ( self ); |
|
0 | 5100 |
} |
5101 |
%} |
|
5102 |
. |
|
5103 |
self primitiveFailed |
|
5104 |
! |
|
5105 |
||
5106 |
noClipIn:aGCId |
|
5107 |
"disable clipping rectangle" |
|
5108 |
||
5109 |
%{ /* NOCONTEXT */ |
|
5110 |
||
5111 |
XGCValues gcv; |
|
5112 |
GC gc = _GCVal(aGCId); |
|
5113 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5114 |
if (__isExternalAddress(aGCId)) { |
70 | 5115 |
gcv.clip_mask = None; |
5116 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5117 |
RETURN ( self ); |
|
0 | 5118 |
} |
5119 |
%} |
|
5120 |
. |
|
5121 |
self primitiveFailed |
|
5122 |
! |
|
5123 |
||
5124 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5125 |
"clip to a rectangle" |
|
5126 |
||
5127 |
%{ /* NOCONTEXT */ |
|
5128 |
||
5129 |
XRectangle r; |
|
5130 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5131 |
if (__isExternalAddress(aGCId) |
97 | 5132 |
&& __bothSmallInteger(clipX, clipY) |
5133 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
70 | 5134 |
r.x = _intVal(clipX); |
5135 |
r.y = _intVal(clipY); |
|
5136 |
r.width = _intVal(clipWidth); |
|
5137 |
r.height = _intVal(clipHeight); |
|
5138 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
5139 |
RETURN ( self ); |
|
0 | 5140 |
} |
5141 |
%} |
|
5142 |
. |
|
5143 |
self primitiveFailed |
|
5144 |
! |
|
5145 |
||
5146 |
setGraphicsExposures:aBoolean in:aGCId |
|
5147 |
"set or clear the graphics exposures flag" |
|
5148 |
||
5149 |
%{ /* NOCONTEXT */ |
|
5150 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5151 |
if (__isExternalAddress(aGCId)) { |
70 | 5152 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
5153 |
RETURN ( self ); |
|
0 | 5154 |
} |
5155 |
%} |
|
5156 |
. |
|
5157 |
self primitiveFailed |
|
5158 |
! ! |
|
5159 |
||
5160 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
5161 |
||
5162 |
getPixelX:x y:y from:aDrawableId |
|
132 | 5163 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left." |
5164 |
||
160 | 5165 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
132 | 5166 |
|
0 | 5167 |
Window win = _WindowVal(aDrawableId); |
5168 |
XImage *img; |
|
26 | 5169 |
int ret; |
0 | 5170 |
int xpos, ypos; |
5171 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5172 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
70 | 5173 |
xpos = _intVal(x); |
5174 |
ypos = _intVal(y); |
|
5175 |
if ((xpos < 0) || (ypos < 0)) { |
|
5176 |
RETURN ( _MKSMALLINT(0) ); |
|
5177 |
} |
|
5178 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
5179 |
ret = XGetPixel(img, 0, 0); |
|
5180 |
XDestroyImage(img); |
|
5181 |
RETURN ( _MKSMALLINT(ret) ); |
|
0 | 5182 |
} |
160 | 5183 |
%}. |
43 | 5184 |
^ nil |
0 | 5185 |
! |
5186 |
||
5187 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
5188 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
72 | 5189 |
must be big enough for the data to fit. If ok, returns an array with some |
5190 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
5191 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
5192 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
5193 |
||
5194 |
|info| |
|
5195 |
||
5196 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
70 | 5197 |
self primitiveFailed. |
5198 |
^ nil |
|
72 | 5199 |
]. |
5200 |
||
5201 |
info := Array with:nil "depth" |
|
5202 |
with:nil "bit order" |
|
90 | 5203 |
with:nil "bytes_per_line" |
5204 |
with:nil "byte_order". |
|
72 | 5205 |
|
160 | 5206 |
"/ had to extract the getPixel call into a separate method, to specify |
5207 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
5208 |
"/ of temporary stack space |
|
5209 |
||
72 | 5210 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInfo:info) ifTrue:[ |
5211 |
^ info |
|
5212 |
]. |
|
5213 |
" |
|
5214 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
5215 |
or is too small to hold the bits |
|
5216 |
" |
|
5217 |
^ self primitiveFailed |
|
5218 |
! |
|
5219 |
||
5220 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInfo:info |
|
132 | 5221 |
"since XGetImage may allocate huge amount of stack space |
5222 |
(some implementations use alloca), this must run with unlimited stack." |
|
5223 |
||
72 | 5224 |
%{ /* UNLIMITEDSTACK */ |
5225 |
||
5226 |
Display *dpy = myDpy; |
|
5227 |
Window win = _WindowVal(aDrawableId); |
|
90 | 5228 |
XImage *image = (XImage *)0; |
5229 |
int pad, bytes_per_line, numBytes; |
|
72 | 5230 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5231 |
if (__isExternalAddress(aDrawableId) |
97 | 5232 |
&& __bothSmallInteger(srcx, srcy) |
5233 |
&& __bothSmallInteger(w, h) |
|
72 | 5234 |
&& __isArray(info) |
5235 |
&& __isByteArray(imageBits)) { |
|
5236 |
image = XGetImage(dpy, win, _intVal(srcx), _intVal(srcy), |
|
5237 |
_intVal(w), _intVal(h), |
|
5238 |
(unsigned)AllPlanes, ZPixmap); |
|
5239 |
||
5240 |
pad = image->bitmap_pad; |
|
12 | 5241 |
#ifdef SUPERDEBUG |
72 | 5242 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
12 | 5243 |
#endif |
72 | 5244 |
switch (image->depth) { |
5245 |
case 1: |
|
5246 |
case 2: |
|
5247 |
case 4: |
|
5248 |
case 8: |
|
5249 |
case 16: |
|
5250 |
case 24: |
|
233 | 5251 |
case 32: |
90 | 5252 |
numBytes = image->bytes_per_line * image->height; |
72 | 5253 |
break; |
5254 |
default: |
|
5255 |
/* unsupported depth */ |
|
233 | 5256 |
printf("unsupported depth:%d in primGetBits\n", image->depth); |
72 | 5257 |
goto fail; |
5258 |
} |
|
0 | 5259 |
|
12 | 5260 |
#ifdef SUPERDEBUG |
90 | 5261 |
printf("bytes need:%d bytes given:%d\n", numBytes, _byteArraySize(imageBits)); |
12 | 5262 |
#endif |
0 | 5263 |
|
90 | 5264 |
if (numBytes > _byteArraySize(imageBits)) { |
72 | 5265 |
/* imageBits too small */ |
5266 |
goto fail; |
|
70 | 5267 |
} |
72 | 5268 |
if (image->bitmap_bit_order == MSBFirst) |
5269 |
_ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
5270 |
else |
|
5271 |
_ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
90 | 5272 |
_ArrayInstPtr(info)->a_element[1] = _MKSMALLINT(image->depth); |
5273 |
_ArrayInstPtr(info)->a_element[2] = _MKSMALLINT(image->bytes_per_line); |
|
5274 |
if (image->byte_order == MSBFirst) |
|
5275 |
_ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
5276 |
else |
|
5277 |
_ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
5278 |
bcopy(image->data, _ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
72 | 5279 |
XDestroyImage(image); |
5280 |
RETURN ( true ); |
|
0 | 5281 |
} |
90 | 5282 |
fail: |
5283 |
if (image) { |
|
5284 |
XDestroyImage(image); |
|
5285 |
} |
|
72 | 5286 |
%}. |
5287 |
^ false |
|
0 | 5288 |
! ! |
5289 |
||
5290 |
!XWorkstation methodsFor:'drawing'! |
|
5291 |
||
73 | 5292 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
37 | 5293 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
5294 |
foreground and background characters. |
|
73 | 5295 |
If the coordinates are not integers, an error is triggered." |
0 | 5296 |
|
5297 |
%{ /* NOCONTEXT */ |
|
5298 |
||
5299 |
GC gc = _GCVal(aGCId); |
|
5300 |
Window win = _WindowVal(aDrawableId); |
|
5301 |
unsigned char *cp; |
|
5302 |
int n; |
|
90 | 5303 |
OBJ cls; |
0 | 5304 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5305 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5306 |
&& __isExternalAddress(aDrawableId) |
90 | 5307 |
&& __isNonNilObject(aString) |
97 | 5308 |
&& __bothSmallInteger(x, y)) { |
135 | 5309 |
cls = __qClass(aString); |
90 | 5310 |
if ((cls == String) || (cls == Symbol)) { |
70 | 5311 |
cp = _stringVal(aString); |
5312 |
n = _stringSize(aString); |
|
5313 |
if (n > 1000) n = 1000; |
|
5314 |
if (opaque == true) |
|
5315 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
|
5316 |
else |
|
5317 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, n); |
|
5318 |
RETURN ( self ); |
|
5319 |
} |
|
0 | 5320 |
#ifdef TWOBYTESTRINGS |
150 | 5321 |
if (cls == @global(TwoByteString)) { |
70 | 5322 |
cp = _stringVal(aString); |
5323 |
n = _byteArraySize(aString) / 2; |
|
5324 |
if (n > 1000) n = 1000; |
|
5325 |
if (opaque == true) |
|
5326 |
XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n); |
|
5327 |
else |
|
5328 |
XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, n); |
|
5329 |
RETURN ( self ); |
|
5330 |
} |
|
0 | 5331 |
#endif |
5332 |
} |
|
73 | 5333 |
%}. |
37 | 5334 |
"x/y not integer, badGC or drawable, or not a string" |
0 | 5335 |
self primitiveFailed |
5336 |
! |
|
5337 |
||
73 | 5338 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
37 | 5339 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
5340 |
foreground and background characters. |
|
73 | 5341 |
If the coordinates are not integers, an error is triggered." |
0 | 5342 |
|
5343 |
%{ /* NOCONTEXT */ |
|
5344 |
||
5345 |
GC gc = _GCVal(aGCId); |
|
5346 |
Window win = _WindowVal(aDrawableId); |
|
5347 |
unsigned char *cp; |
|
90 | 5348 |
OBJ cls; |
0 | 5349 |
int i1, i2, l, n; |
5350 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5351 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5352 |
&& __isExternalAddress(aDrawableId) |
90 | 5353 |
&& __isNonNilObject(aString) |
97 | 5354 |
&& __bothSmallInteger(index1, index2) |
5355 |
&& __bothSmallInteger(x, y)) { |
|
135 | 5356 |
cls = __qClass(aString); |
90 | 5357 |
if ((cls == String) || (cls == Symbol)) { |
70 | 5358 |
i1 = _intVal(index1) - 1; |
5359 |
i2 = _intVal(index2) - 1; |
|
5360 |
n = _stringSize(aString); |
|
5361 |
cp = _stringVal(aString); |
|
5362 |
if ((i1 >= 0) && (i2 < n)) { |
|
5363 |
if (i2 >= i1) { |
|
5364 |
cp += i1; |
|
5365 |
l = i2 - i1 + 1; |
|
5366 |
if (l > 1000) l = 1000; |
|
5367 |
if (opaque == true) |
|
5368 |
XDrawImageString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
|
5369 |
else |
|
5370 |
XDrawString(myDpy, win, gc, _intVal(x), _intVal(y), (char *)cp, l); |
|
5371 |
} |
|
5372 |
RETURN ( self ); |
|
5373 |
} |
|
5374 |
} |
|
0 | 5375 |
#ifdef TWOBYTESTRINGS |
150 | 5376 |
if (cls == @global(TwoByteString)) { |
70 | 5377 |
i1 = _intVal(index1) - 1; |
5378 |
i2 = _intVal(index2) - 1; |
|
5379 |
n = _byteArraySize(aString) / 2; |
|
5380 |
cp = _stringVal(aString); |
|
5381 |
if ((i1 >= 0) && (i2 < n)) { |
|
5382 |
if (i2 >= i1) { |
|
5383 |
cp += (i1 * 2); |
|
5384 |
l = i2 - i1 + 1; |
|
5385 |
if (l > 1000) l = 1000; |
|
5386 |
if (opaque == true) |
|
5387 |
XDrawImageString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l); |
|
5388 |
else |
|
5389 |
XDrawString16(myDpy, win, gc, _intVal(x), _intVal(y), (XChar2b *)cp, l); |
|
5390 |
RETURN ( self ); |
|
5391 |
} |
|
5392 |
} |
|
5393 |
} |
|
0 | 5394 |
#endif |
5395 |
} |
|
73 | 5396 |
%}. |
37 | 5397 |
"x/y not integer, badGC or drawable, or not a string" |
0 | 5398 |
self primitiveFailed |
5399 |
! |
|
5400 |
||
23 | 5401 |
displayPointX:x y:y in:aDrawableId with:aGCId |
118 | 5402 |
"draw a point. If x/y are not integers, an error is triggered." |
0 | 5403 |
|
5404 |
%{ /* NOCONTEXT */ |
|
5405 |
||
5406 |
GC gc = _GCVal(aGCId); |
|
5407 |
Window win = _WindowVal(aDrawableId); |
|
5408 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5409 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5410 |
&& __isExternalAddress(aDrawableId) |
97 | 5411 |
&& __bothSmallInteger(x, y)) { |
70 | 5412 |
XDrawPoint(myDpy, win, gc, _intVal(x), _intVal(y)); |
5413 |
RETURN ( self ); |
|
0 | 5414 |
} |
73 | 5415 |
%}. |
5416 |
"badGC, badDrawable or x/y not integer" |
|
0 | 5417 |
self primitiveFailed |
5418 |
! |
|
5419 |
||
5420 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
|
73 | 5421 |
"draw a line. If the coordinates are not integers, an error is triggered." |
0 | 5422 |
|
5423 |
%{ /* NOCONTEXT */ |
|
5424 |
||
5425 |
GC gc = _GCVal(aGCId); |
|
5426 |
Window win = _WindowVal(aDrawableId); |
|
5427 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5428 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5429 |
&& __isExternalAddress(aDrawableId) |
97 | 5430 |
&& __bothSmallInteger(x0, y0) |
5431 |
&& __bothSmallInteger(x1, y1)) { |
|
70 | 5432 |
XDrawLine(myDpy, win, gc, _intVal(x0), _intVal(y0), |
5433 |
_intVal(x1), _intVal(y1)); |
|
5434 |
RETURN ( self ); |
|
0 | 5435 |
} |
73 | 5436 |
%}. |
5437 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5438 |
self primitiveFailed |
5439 |
! |
|
5440 |
||
26 | 5441 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
73 | 5442 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
0 | 5443 |
|
5444 |
%{ /* NOCONTEXT */ |
|
5445 |
||
5446 |
GC gc = _GCVal(aGCId); |
|
5447 |
Window win = _WindowVal(aDrawableId); |
|
5448 |
int w, h; |
|
5449 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5450 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5451 |
&& __isExternalAddress(aDrawableId) |
97 | 5452 |
&& __bothSmallInteger(x, y) |
5453 |
&& __bothSmallInteger(width, height)) { |
|
70 | 5454 |
w = _intVal(width); |
5455 |
h = _intVal(height); |
|
5456 |
/* |
|
5457 |
* need this check here: some servers simply dump core with bad args |
|
5458 |
*/ |
|
5459 |
if ((w >= 0) && (h >= 0)) { |
|
5460 |
XDrawRectangle(myDpy, win, gc, _intVal(x), _intVal(y), w, h); |
|
5461 |
} |
|
5462 |
RETURN ( self ); |
|
0 | 5463 |
} |
73 | 5464 |
%}. |
5465 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5466 |
self primitiveFailed |
5467 |
! |
|
5468 |
||
26 | 5469 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
73 | 5470 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
5471 |
define the polygon. |
|
5472 |
If any coordinate is not integer, an error is triggered." |
|
5473 |
||
5474 |
|numberOfPoints newPoints| |
|
0 | 5475 |
|
5476 |
numberOfPoints := aPolygon size. |
|
5477 |
%{ |
|
73 | 5478 |
GC gc = _GCVal(aGCId); |
5479 |
Window win = _WindowVal(aDrawableId); |
|
193 | 5480 |
extern OBJ Point, __AT_(); |
73 | 5481 |
OBJ point, x, y; |
5482 |
int i, num; |
|
5483 |
XPoint *points; |
|
5484 |
XPoint qPoints[100]; |
|
5485 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5486 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5487 |
&& __isExternalAddress(aDrawableId) |
97 | 5488 |
&& __isSmallInteger(numberOfPoints)) { |
73 | 5489 |
num = _intVal(numberOfPoints); |
5490 |
/* |
|
5491 |
* avoid a (slow) malloc, if the number of points is small |
|
5492 |
*/ |
|
96 | 5493 |
if (num > 100) { |
73 | 5494 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
96 | 5495 |
if (! points) goto fail; |
5496 |
} else |
|
73 | 5497 |
points = qPoints; |
5498 |
||
5499 |
for (i=0; i<num; i++) { |
|
193 | 5500 |
point = __AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1)); |
73 | 5501 |
if (! __isPoint(point)) goto fail; |
5502 |
x = _point_X(point); |
|
5503 |
y = _point_Y(point); |
|
97 | 5504 |
if (! __bothSmallInteger(x, y)) |
73 | 5505 |
goto fail; |
5506 |
points[i].x = _intVal(x); |
|
5507 |
points[i].y = _intVal(y); |
|
70 | 5508 |
} |
73 | 5509 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
5510 |
if (num > 100) |
|
5511 |
free(points); |
|
5512 |
RETURN ( self ); |
|
0 | 5513 |
} |
73 | 5514 |
fail: ; |
5515 |
%}. |
|
5516 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5517 |
self primitiveFailed |
5518 |
! |
|
5519 |
||
5520 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 5521 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 5522 |
|
5523 |
"do a bit-blt of a compressed FAX image |
|
5524 |
- this needs my private FAX extension" |
|
132 | 5525 |
|
5526 |
%{ /* NOCONTEXT */ |
|
0 | 5527 |
#ifdef FAX |
5528 |
GC gc = _GCVal(aGCId); |
|
5529 |
FAXImage source; |
|
5530 |
Drawable dest; |
|
5531 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5532 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5533 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5534 |
&& __isExternalAddress(destId) |
97 | 5535 |
&& __bothSmallInteger(scaleX, scaleY) |
5536 |
&& __bothSmallInteger(w, h) |
|
5537 |
&& __bothSmallInteger(srcX, srcY) |
|
5538 |
&& __bothSmallInteger(dstX, dstY)) { |
|
70 | 5539 |
source = (FAXImage) _WindowVal(sourceId); |
5540 |
dest = (Drawable) _WindowVal(destId); |
|
5541 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
5542 |
_intVal(srcX), _intVal(srcY), |
|
5543 |
_intVal(w), _intVal(h), |
|
5544 |
_intVal(dstX), _intVal(dstY), |
|
5545 |
_intVal(scaleX), _intVal(scaleY)); |
|
5546 |
RETURN ( self ); |
|
0 | 5547 |
} |
5548 |
#endif |
|
118 | 5549 |
%}. |
0 | 5550 |
self primitiveFailed |
5551 |
! |
|
5552 |
||
5553 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 5554 |
width:w height:h with:aGCId |
118 | 5555 |
"do a bit-blt; copy bits from the rectangle defined by |
5556 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
5557 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
5558 |
argument is not integer." |
|
0 | 5559 |
|
5560 |
%{ /* NOCONTEXT */ |
|
5561 |
||
5562 |
GC gc = _GCVal(aGCId); |
|
5563 |
Drawable source, dest; |
|
5564 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5565 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5566 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5567 |
&& __isExternalAddress(destId) |
97 | 5568 |
&& __bothSmallInteger(w, h) |
5569 |
&& __bothSmallInteger(srcX, srcY) |
|
5570 |
&& __bothSmallInteger(dstX, dstY)) { |
|
70 | 5571 |
source = (Drawable) _WindowVal(sourceId); |
5572 |
dest = (Drawable) _WindowVal(destId); |
|
5573 |
XCopyArea(myDpy, source, dest, gc, |
|
5574 |
_intVal(srcX), _intVal(srcY), |
|
5575 |
_intVal(w), _intVal(h), |
|
5576 |
_intVal(dstX), _intVal(dstY)); |
|
5577 |
RETURN ( self ); |
|
0 | 5578 |
} |
118 | 5579 |
%}. |
5580 |
"badGC, bad sourceDrawableId or destDrawableID |
|
5581 |
or any non integer coordinate" |
|
5582 |
||
0 | 5583 |
self primitiveFailed |
5584 |
! |
|
5585 |
||
5586 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 5587 |
width:w height:h with:aGCId |
118 | 5588 |
"do a bit-blt, but only copy the low-bit plane; |
5589 |
copy bits from the rectangle defined by |
|
5590 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
5591 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
5592 |
argument is not integer." |
|
0 | 5593 |
|
5594 |
%{ /* NOCONTEXT */ |
|
5595 |
||
5596 |
GC gc = _GCVal(aGCId); |
|
5597 |
Drawable source, dest; |
|
5598 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5599 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5600 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5601 |
&& __isExternalAddress(destId) |
97 | 5602 |
&& __bothSmallInteger(w, h) |
5603 |
&& __bothSmallInteger(srcX, srcY) |
|
5604 |
&& __bothSmallInteger(dstX, dstY)) { |
|
70 | 5605 |
source = (Drawable) _WindowVal(sourceId); |
5606 |
dest = (Drawable) _WindowVal(destId); |
|
5607 |
XCopyPlane(myDpy, source, dest, gc, |
|
5608 |
_intVal(srcX), _intVal(srcY), |
|
5609 |
_intVal(w), _intVal(h), |
|
5610 |
_intVal(dstX), _intVal(dstY), 1); |
|
5611 |
RETURN ( self ); |
|
0 | 5612 |
} |
118 | 5613 |
%}. |
5614 |
"badGC, bad sourceDrawableId or destDrawableID |
|
5615 |
or any non integer coordinate" |
|
5616 |
||
0 | 5617 |
self primitiveFailed |
5618 |
! |
|
5619 |
||
73 | 5620 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 5621 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
5622 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 5623 |
|
5624 |
%{ /* NOCONTEXT */ |
|
5625 |
||
5626 |
GC gc = _GCVal(aGCId); |
|
5627 |
Window win = _WindowVal(aDrawableId); |
|
5628 |
int w, h, angle1, angle2; |
|
5629 |
double f; |
|
5630 |
||
97 | 5631 |
if (__isSmallInteger(startAngle)) |
70 | 5632 |
angle1 = _intVal(startAngle) * 64; |
36 | 5633 |
else if (__isFloat(startAngle)) { |
70 | 5634 |
f = _floatVal(startAngle); |
5635 |
angle1 = f * 64; |
|
0 | 5636 |
} |
97 | 5637 |
if (__isSmallInteger(angle)) |
70 | 5638 |
angle2 = _intVal(angle) * 64; |
36 | 5639 |
else if (__isFloat(angle)) { |
70 | 5640 |
f = _floatVal(angle); |
5641 |
angle2 = f * 64; |
|
0 | 5642 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5643 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5644 |
&& __isExternalAddress(aDrawableId) |
97 | 5645 |
&& __bothSmallInteger(x, y) |
5646 |
&& __bothSmallInteger(width, height)) { |
|
70 | 5647 |
w = _intVal(width); |
5648 |
h = _intVal(height); |
|
5649 |
/* |
|
5650 |
* need this check here: some servers simply dump core with bad args |
|
5651 |
*/ |
|
5652 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
5653 |
XDrawArc(myDpy, win, gc, _intVal(x), _intVal(y), |
|
5654 |
w, h, angle1, angle2); |
|
5655 |
} |
|
5656 |
RETURN ( self ); |
|
0 | 5657 |
} |
73 | 5658 |
%}. |
5659 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5660 |
self primitiveFailed |
5661 |
! |
|
5662 |
||
5663 |
fillArcX:x y:y w:width h:height from:startAngle angle:angle |
|
70 | 5664 |
in:aDrawableId with:aGCId |
90 | 5665 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
5666 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 5667 |
|
5668 |
%{ /* NOCONTEXT */ |
|
5669 |
||
5670 |
GC gc = _GCVal(aGCId); |
|
5671 |
Window win = _WindowVal(aDrawableId); |
|
5672 |
int w, h, angle1, angle2; |
|
5673 |
double f; |
|
5674 |
||
97 | 5675 |
if (__isSmallInteger(startAngle)) |
70 | 5676 |
angle1 = _intVal(startAngle) * 64; |
36 | 5677 |
else if (__isFloat(startAngle)) { |
70 | 5678 |
f = _floatVal(startAngle); |
5679 |
angle1 = f * 64; |
|
0 | 5680 |
} |
97 | 5681 |
if (__isSmallInteger(angle)) |
70 | 5682 |
angle2 = _intVal(angle) * 64; |
36 | 5683 |
else if (__isFloat(angle)) { |
70 | 5684 |
f = _floatVal(angle); |
5685 |
angle2 = f * 64; |
|
0 | 5686 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5687 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5688 |
&& __isExternalAddress(aDrawableId) |
97 | 5689 |
&& __bothSmallInteger(x, y) |
5690 |
&& __bothSmallInteger(width, height)) { |
|
70 | 5691 |
w = _intVal(width); |
5692 |
h = _intVal(height); |
|
5693 |
/* |
|
5694 |
* need this check here: some servers simply dump core with bad args |
|
5695 |
*/ |
|
5696 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
5697 |
XFillArc(myDpy, win, gc, _intVal(x), _intVal(y), |
|
5698 |
w, h, angle1, angle2); |
|
5699 |
} |
|
5700 |
RETURN ( self ); |
|
0 | 5701 |
} |
73 | 5702 |
%}. |
5703 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5704 |
self primitiveFailed |
5705 |
! |
|
5706 |
||
5707 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
73 | 5708 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
0 | 5709 |
|
5710 |
%{ /* NOCONTEXT */ |
|
5711 |
||
5712 |
int w, h; |
|
5713 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5714 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5715 |
&& __isExternalAddress(aDrawableId) |
97 | 5716 |
&& __bothSmallInteger(x, y) |
5717 |
&& __bothSmallInteger(width, height)) { |
|
70 | 5718 |
w = _intVal(width); |
5719 |
h = _intVal(height); |
|
5720 |
/* |
|
5721 |
* need this check here: some servers simply dump core with bad args |
|
5722 |
*/ |
|
5723 |
if ((w >= 0) && (h >= 0)) { |
|
5724 |
XFillRectangle(myDpy, |
|
5725 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
5726 |
_intVal(x), _intVal(y), w, h); |
|
5727 |
} |
|
5728 |
RETURN ( self ); |
|
0 | 5729 |
} |
73 | 5730 |
%}. |
5731 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5732 |
self primitiveFailed |
5733 |
! |
|
5734 |
||
5735 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 5736 |
"fill a polygon given by its points. |
5737 |
If any coordinate is not integer, an error is triggered." |
|
73 | 5738 |
|
5739 |
|numberOfPoints| |
|
0 | 5740 |
|
5741 |
numberOfPoints := aPolygon size. |
|
5742 |
%{ |
|
73 | 5743 |
GC gc = _GCVal(aGCId); |
5744 |
Window win = _WindowVal(aDrawableId); |
|
5745 |
OBJ point, x, y; |
|
193 | 5746 |
extern OBJ Point, __AT_(); |
73 | 5747 |
int i, num; |
5748 |
XPoint *points; |
|
5749 |
XPoint qPoints[100]; |
|
5750 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5751 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5752 |
&& __isExternalAddress(aDrawableId) |
97 | 5753 |
&& __isSmallInteger(numberOfPoints)) { |
73 | 5754 |
num = _intVal(numberOfPoints); |
5755 |
if (num < 3) { |
|
70 | 5756 |
RETURN ( self ); |
5757 |
} |
|
73 | 5758 |
/* |
5759 |
* avoid (slow) malloc, if not many points |
|
5760 |
*/ |
|
96 | 5761 |
if (num > 100) { |
73 | 5762 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 5763 |
if (! points) goto fail; |
5764 |
} else |
|
73 | 5765 |
points = qPoints; |
5766 |
for (i=0; i<num; i++) { |
|
193 | 5767 |
point = __AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1)); |
73 | 5768 |
if (! __isPoint(point)) goto fail; |
5769 |
x = _point_X(point); |
|
5770 |
y = _point_Y(point); |
|
97 | 5771 |
if (! __bothSmallInteger(x, y)) |
73 | 5772 |
goto fail; |
5773 |
points[i].x = _intVal(x); |
|
5774 |
points[i].y = _intVal(y); |
|
5775 |
} |
|
5776 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
5777 |
if (num > 100) |
|
5778 |
free(points); |
|
5779 |
RETURN ( self ); |
|
0 | 5780 |
fail: ; |
5781 |
} |
|
73 | 5782 |
%}. |
5783 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 5784 |
self primitiveFailed |
5785 |
! |
|
5786 |
||
43 | 5787 |
drawBits:imageBits depth:imageDepth |
70 | 5788 |
width:imageWidth height:imageHeight |
5789 |
x:srcx y:srcy |
|
5790 |
into:aDrawableId |
|
5791 |
x:dstx y:dsty |
|
5792 |
width:w height:h |
|
5793 |
with:aGCId |
|
43 | 5794 |
|
118 | 5795 |
"draw a bitImage which has depth id, width iw and height ih into |
5796 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
5797 |
Individual source pixels must have imageDepth bits. |
|
5798 |
It has to be checked elsewhere, that the server can do it with the given |
|
5799 |
depth - otherwise, primitive failure will be signalled. |
|
5800 |
Also it is assumed, that the colormap is setup correctly and the |
|
5801 |
colors are allocated - otherwise the colors may be wrong." |
|
5802 |
||
43 | 5803 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
70 | 5804 |
width:imageWidth height:imageHeight |
5805 |
x:srcx y:srcy |
|
5806 |
into:aDrawableId |
|
5807 |
x:dstx y:dsty |
|
5808 |
width:w height:h |
|
5809 |
with:aGCId |
|
43 | 5810 |
|
12 | 5811 |
! |
5812 |
||
43 | 5813 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
70 | 5814 |
width:imageWidth height:imageHeight |
5815 |
x:srcx y:srcy |
|
5816 |
into:aDrawableId |
|
5817 |
x:dstx y:dsty |
|
5818 |
width:w height:h |
|
5819 |
with:aGCId |
|
12 | 5820 |
|
73 | 5821 |
"draw a bitImage which has depth id, width iw and height ih into |
0 | 5822 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
43 | 5823 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
5824 |
depth and pixel-units to be different. |
|
5825 |
It has to be checked elsewhere, that the server can do it with the given |
|
5826 |
depth - otherwise, primitive failure will be signalled. |
|
5827 |
Also it is assumed, that the colormap is setup correctly and the |
|
5828 |
colors are allocated - otherwise the colors may be wrong." |
|
5829 |
||
5830 |
" |
|
5831 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
5832 |
an unlimited stack, and thus cannot send primitiveFailed |
|
5833 |
" |
|
5834 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 5835 |
width:imageWidth height:imageHeight |
5836 |
x:srcx y:srcy |
|
5837 |
into:aDrawableId |
|
5838 |
x:dstx y:dsty |
|
5839 |
width:w height:h |
|
5840 |
with:aGCId) |
|
43 | 5841 |
ifFalse:[ |
70 | 5842 |
" |
5843 |
also happens, if a segmentation violation occurs in the |
|
5844 |
XPutImage ... |
|
5845 |
" |
|
5846 |
self primitiveFailed |
|
43 | 5847 |
]. |
5848 |
! |
|
5849 |
||
5850 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 5851 |
width:imageWidth height:imageHeight |
5852 |
x:srcx y:srcy |
|
5853 |
into:aDrawableId |
|
5854 |
x:dstx y:dsty |
|
5855 |
width:w height:h |
|
5856 |
with:aGCId |
|
0 | 5857 |
|
132 | 5858 |
"since XPutImage may allocate huge amount of stack space |
5859 |
(some implementations use alloca), this must run with unlimited stack." |
|
5860 |
||
12 | 5861 |
%{ /* UNLIMITEDSTACK */ |
0 | 5862 |
|
43 | 5863 |
/* |
5864 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
5865 |
* XPutImage |
|
5866 |
*/ |
|
5867 |
Display *dpy = myDpy; |
|
5868 |
GC gc = _GCVal(aGCId); |
|
5869 |
Window win = _WindowVal(aDrawableId); |
|
5870 |
XImage image; |
|
5871 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5872 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5873 |
&& __isExternalAddress(aDrawableId) |
97 | 5874 |
&& __bothSmallInteger(srcx, srcy) |
5875 |
&& __bothSmallInteger(dstx, dsty) |
|
5876 |
&& __bothSmallInteger(w, h) |
|
5877 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
5878 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 5879 |
&& __isByteArray(imageBits)) { |
46 | 5880 |
#ifdef ARGDEBUG |
70 | 5881 |
printf("args ok\n"); |
46 | 5882 |
#endif |
70 | 5883 |
image.data = (char *)_ByteArrayInstPtr(imageBits)->ba_element; |
5884 |
image.width = _intVal(imageWidth); |
|
5885 |
image.height = _intVal(imageHeight); |
|
5886 |
image.xoffset = 0; |
|
5887 |
image.format = ZPixmap; |
|
5888 |
image.byte_order = MSBFirst; |
|
5889 |
image.bitmap_unit = 8; |
|
5890 |
image.bitmap_bit_order = MSBFirst; |
|
5891 |
image.bitmap_pad = 8; |
|
5892 |
image.depth = _intVal(imageDepth); |
|
5893 |
image.bits_per_pixel = _intVal(bitsPerPixel); |
|
5894 |
switch (image.bits_per_pixel) { |
|
5895 |
case 1: |
|
5896 |
image.bytes_per_line = (_intVal(imageWidth) + 7) / 8; |
|
5897 |
break; |
|
5898 |
case 2: |
|
5899 |
image.bytes_per_line = (_intVal(imageWidth)*2 + 7) / 8; |
|
5900 |
break; |
|
5901 |
case 4: |
|
5902 |
image.bytes_per_line = (_intVal(imageWidth)*4 + 7) / 8; |
|
5903 |
break; |
|
5904 |
case 8: |
|
5905 |
image.bytes_per_line = _intVal(imageWidth); |
|
5906 |
break; |
|
5907 |
case 16: |
|
5908 |
image.bytes_per_line = _intVal(imageWidth)*2; |
|
5909 |
break; |
|
5910 |
case 24: |
|
5911 |
image.bytes_per_line = _intVal(imageWidth)*3; |
|
5912 |
break; |
|
193 | 5913 |
case 32: |
5914 |
image.bytes_per_line = _intVal(imageWidth)*4; |
|
5915 |
break; |
|
70 | 5916 |
default: |
46 | 5917 |
#ifdef ARGDEBUG |
70 | 5918 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 5919 |
#endif |
70 | 5920 |
goto fail; |
5921 |
} |
|
5922 |
image.red_mask = 0xFFFF; |
|
5923 |
image.green_mask = 0xFFFF; |
|
5924 |
image.blue_mask = 0xFFFF; |
|
5925 |
XPutImage(dpy, win, gc, &image, _intVal(srcx), _intVal(srcy), |
|
5926 |
_intVal(dstx), _intVal(dsty), |
|
5927 |
_intVal(w), _intVal(h)); |
|
5928 |
RETURN ( true ); |
|
43 | 5929 |
} |
46 | 5930 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5931 |
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
|
5932 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 5933 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
5934 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
5935 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
5936 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
5937 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
5938 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
5939 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
5940 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
5941 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
5942 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
5943 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 5944 |
#endif |
5945 |
||
0 | 5946 |
fail: ; |
5947 |
%} |
|
5948 |
. |
|
12 | 5949 |
^ false |
0 | 5950 |
! ! |
5951 |
||
86 | 5952 |
!XWorkstation methodsFor:'event handling'! |
0 | 5953 |
|
5954 |
eventMaskFor:anEventSymbol |
|
12 | 5955 |
"return the eventMask bit-constant corresponding to an event symbol" |
5956 |
||
132 | 5957 |
%{ /* NOCONTEXT */ |
5958 |
||
63 | 5959 |
int m = 0; |
5960 |
||
5961 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
5962 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
5963 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
5964 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
5965 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
5966 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
5967 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
5968 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
5969 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
5970 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
5971 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
5972 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
5973 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
5974 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
5975 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
5976 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
5977 |
RETURN (_MKSMALLINT(m)); |
|
5978 |
%} |
|
0 | 5979 |
! |
5980 |
||
5981 |
setEventMask:aMask in:aWindowId |
|
12 | 5982 |
"tell X that we are only interrested in events from aMask, which |
5983 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
|
0 | 5984 |
|
5985 |
%{ /* NOCONTEXT */ |
|
5986 |
||
5987 |
int mask; |
|
5988 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5989 |
if (__isExternalAddress(aWindowId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
5990 |
&& __isSmallInteger(aMask)) { |
70 | 5991 |
mask = _intVal(aMask); |
5992 |
||
109 | 5993 |
#ifdef OLD |
70 | 5994 |
/* these may not be disabled */ |
109 | 5995 |
mask |= ExposureMask | StructureNotifyMask | |
144 | 5996 |
KeyPressMask | KeyReleaseMask | |
150 | 5997 |
EnterWindowMask | LeaveWindowMask | |
109 | 5998 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
5999 |
#endif |
|
70 | 6000 |
|
6001 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
6002 |
RETURN ( self ); |
|
0 | 6003 |
} |
6004 |
%} |
|
6005 |
. |
|
6006 |
self primitiveFailed |
|
6007 |
! |
|
6008 |
||
12 | 6009 |
startDispatch |
6010 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
6011 |
||
6012 |
dispatching ifTrue:[^ self]. |
|
6013 |
dispatchingExpose := nil. |
|
6014 |
super startDispatch |
|
6015 |
! |
|
6016 |
||
190 | 6017 |
XXcheckForEndOfDispatch |
12 | 6018 |
"return true, if there are still any views of interrest - if not, |
6019 |
stop dispatch" |
|
6020 |
||
44 | 6021 |
"/ idToViewMapping isEmpty ifTrue:[ |
54 | 6022 |
"/ dispatching := false. |
44 | 6023 |
"/ ] ifFalse:[ |
6024 |
"/ ((idToViewMapping size == 1) and:[idToViewMapping includesValue:RootView]) ifTrue:[ |
|
54 | 6025 |
"/ dispatching := false. |
6026 |
"/ ] |
|
44 | 6027 |
"/ ] |
6028 |
||
12 | 6029 |
knownViews isEmpty ifTrue:[ |
70 | 6030 |
dispatching := false. |
6031 |
^ self |
|
12 | 6032 |
]. |
135 | 6033 |
((knownViews size == 1) and:[(knownViews at:1) == rootView]) ifTrue:[ |
70 | 6034 |
dispatching := false. |
12 | 6035 |
] |
6036 |
! |
|
6037 |
||
6038 |
dispatchPendingEvents |
|
6039 |
"central event handling method: |
|
6040 |
this code is somewhat special, since X has a concept of graphic |
|
6041 |
expose events (which are sent after a bitblt). After such a bitblt, |
|
6042 |
we only handle exposes until the graphicsExpose arrives. |
|
6043 |
Other systems may not need such a kludge" |
|
6044 |
||
6045 |
"interrested in exposes only ?" |
|
6046 |
dispatchingExpose notNil ifTrue:[ |
|
70 | 6047 |
[self exposeEventPendingFor:dispatchingExpose] whileTrue:[ |
6048 |
self dispatchExposeEventFor:dispatchingExpose |
|
6049 |
]. |
|
6050 |
^ self |
|
12 | 6051 |
]. |
6052 |
||
54 | 6053 |
"no, general dispatch" |
12 | 6054 |
[self eventPendingWithoutSync] whileTrue:[ |
70 | 6055 |
self dispatchEventFor:nil withMask:nil |
12 | 6056 |
] |
6057 |
! |
|
6058 |
||
6059 |
handleExposeOnlyFor:aView |
|
6060 |
"from now on, handle expose events only" |
|
6061 |
||
6062 |
dispatchingExpose := aView id |
|
6063 |
! |
|
6064 |
||
6065 |
handleAllEvents |
|
6066 |
"from now on, handle any kind of event" |
|
6067 |
||
6068 |
dispatchingExpose := nil |
|
6069 |
! |
|
6070 |
||
6071 |
dispatchExposeEventFor:aViewIdOrNil |
|
54 | 6072 |
"get next expose event and send appropriate message to the sensor or view. |
12 | 6073 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
6074 |
otherwise only events for the view with given id are processed." |
|
200 | 6075 |
|
12 | 6076 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
6077 |
! |
|
6078 |
||
0 | 6079 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
6080 |
"central event handling method: |
|
54 | 6081 |
get next event and send appropriate message to the sensor or view. |
0 | 6082 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 6083 |
otherwise only events for the view with given id are processed. |
6084 |
If the argument aMask is nonNil, only events for this eventMask are |
|
6085 |
handled." |
|
6086 |
||
54 | 6087 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
83 | 6088 |
Object abortSignal catch:[ |
6089 |
self dispatchLastEvent. |
|
6090 |
] |
|
54 | 6091 |
]. |
12 | 6092 |
! |
6093 |
||
6094 |
getEventFor:aViewIdOrNil withMask:eventMask |
|
135 | 6095 |
"read next event - put into local eventBuffer. |
6096 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
6097 |
otherwise only events for that specific view will be fetched. |
|
6098 |
Returns true, if there was an event, false otherwise. |
|
6099 |
This method may block - so you better check for pending events |
|
6100 |
before calling for it. |
|
81 | 6101 |
|
6102 |
Sorry I had to split dispatch into this fetch method and an extra |
|
6103 |
handle method to allow unlimitedstack here. |
|
54 | 6104 |
(some Xlibs do a big alloca there ...) which cannot be done in |
6105 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
81 | 6106 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
6107 |
display connections. |
|
54 | 6108 |
" |
12 | 6109 |
|
6110 |
%{ /* UNLIMITEDSTACK */ |
|
6111 |
||
6112 |
Display *dpy = myDpy; |
|
6113 |
Window win, wWanted; |
|
54 | 6114 |
int evMask; |
135 | 6115 |
OBJ eB; |
6116 |
XEvent *ev; |
|
6117 |
||
150 | 6118 |
if (! ISCONNECTED) { |
6119 |
RETURN (false); |
|
6120 |
} |
|
6121 |
||
135 | 6122 |
eB = _INST(eventBuffer); |
6123 |
if (__isByteArray(eB)) { |
|
6124 |
ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element); |
|
6125 |
} else { |
|
6126 |
printf("DISPLAY: no eventBuffer\n"); |
|
6127 |
RETURN (false); |
|
6128 |
} |
|
6129 |
ev->type = 0; |
|
54 | 6130 |
|
97 | 6131 |
if (__isSmallInteger(eventMask)) { |
70 | 6132 |
evMask = _intVal(eventMask); |
54 | 6133 |
} else { |
70 | 6134 |
evMask = ~0; |
54 | 6135 |
} |
6136 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6137 |
if (__isExternalAddress(aViewIdOrNil)) { |
70 | 6138 |
wWanted = _WindowVal(aViewIdOrNil); |
135 | 6139 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
70 | 6140 |
RETURN ( true ); |
6141 |
} |
|
12 | 6142 |
} else { |
70 | 6143 |
if (evMask == ~0) { |
135 | 6144 |
XNextEvent(dpy, ev); |
70 | 6145 |
RETURN (true); |
6146 |
} |
|
135 | 6147 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
70 | 6148 |
RETURN (true); |
6149 |
} |
|
12 | 6150 |
} |
54 | 6151 |
%}. |
6152 |
^ false |
|
12 | 6153 |
! |
6154 |
||
6155 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6156 |
|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
|
6157 |
eventType| |
12 | 6158 |
|
6159 |
%{ /* STACK: 8000 */ |
|
6160 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 6161 |
|
6162 |
Display *dpy = myDpy; |
|
135 | 6163 |
OBJ eB; |
6164 |
XEvent *ev; |
|
6165 |
||
6166 |
# define ae ((XAnyEvent *)ev) |
|
6167 |
# define ee ((XExposeEvent *)ev) |
|
6168 |
# define ke ((XKeyPressedEvent *)ev) |
|
6169 |
# define be ((XButtonPressedEvent *)ev) |
|
6170 |
# define ce ((XConfigureEvent *)ev) |
|
6171 |
# define me ((XMotionEvent *)ev) |
|
6172 |
# define ewe ((XEnterWindowEvent *)ev) |
|
6173 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
6174 |
# define de ((XDestroyWindowEvent *)ev) |
|
6175 |
# define ve ((XVisibilityEvent *)ev) |
|
6176 |
||
0 | 6177 |
KeySym keySym; |
6178 |
unsigned char buffer[10]; |
|
6179 |
int i, nchars; |
|
6180 |
char *keySymString; |
|
6181 |
char keySymStringBuffer[32]; |
|
6182 |
static unsigned multiClickTime = 0; |
|
6183 |
unsigned nextMultiClickTime; |
|
150 | 6184 |
OBJ upDown; |
193 | 6185 |
extern OBJ __AT_(); |
115 | 6186 |
|
6187 |
struct inlineCache *ipS; |
|
0 | 6188 |
static struct inlineCache vid = _ILC1; |
12 | 6189 |
|
6190 |
static struct inlineCache expS = _ILC5; |
|
6191 |
static struct inlineCache gexpS = _ILC5; |
|
6192 |
static struct inlineCache nexpS = _ILC1; |
|
6193 |
static struct inlineCache motS = _ILC4; |
|
6194 |
static struct inlineCache bpS = _ILC4; |
|
6195 |
static struct inlineCache bmpS = _ILC4; |
|
6196 |
static struct inlineCache bspS = _ILC4; |
|
6197 |
static struct inlineCache brS = _ILC4; |
|
6198 |
static struct inlineCache focInS = _ILC1; |
|
6199 |
static struct inlineCache focOutS = _ILC1; |
|
6200 |
static struct inlineCache peS = _ILC4; |
|
6201 |
static struct inlineCache plS = _ILC2; |
|
54 | 6202 |
static struct inlineCache termS = _ILC1; |
6203 |
static struct inlineCache savtermS = _ILC1; |
|
6204 |
static struct inlineCache destrS = _ILC1; |
|
6205 |
static struct inlineCache unmapS = _ILC1; |
|
6206 |
static struct inlineCache mapS = _ILC1; |
|
6207 |
static struct inlineCache confS = _ILC5; |
|
70 | 6208 |
static struct inlineCache coveredS = _ILC2; |
12 | 6209 |
|
6210 |
static struct inlineCache keymap = _ILC0; |
|
6211 |
static struct inlineCache created = _ILC0; |
|
6212 |
static struct inlineCache mapReq = _ILC0; |
|
6213 |
static struct inlineCache repar = _ILC0; |
|
6214 |
static struct inlineCache confReq = _ILC0; |
|
6215 |
static struct inlineCache resReq = _ILC0; |
|
6216 |
static struct inlineCache prop = _ILC0; |
|
129 | 6217 |
static struct inlineCache selClear = _ILC1; |
90 | 6218 |
static struct inlineCache selReq = _ILC4; |
6219 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 6220 |
static struct inlineCache colormap = _ILC0; |
70 | 6221 |
static struct inlineCache vis = _ILC1; |
12 | 6222 |
|
6223 |
static struct inlineCache skpS = _ILC4; |
|
63 | 6224 |
static struct inlineCache skrS = _ILC4; |
12 | 6225 |
|
135 | 6226 |
eB = _INST(eventBuffer); |
6227 |
if (__isByteArray(eB)) { |
|
6228 |
ev = (XEvent *)(_ByteArrayInstPtr(eB)->ba_element); |
|
6229 |
} else { |
|
6230 |
printf("DISPLAY: no eventBuffer\n"); |
|
6231 |
RETURN (false); |
|
6232 |
} |
|
6233 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6234 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6235 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 6236 |
|
6237 |
if (theView == nil) { |
|
70 | 6238 |
RETURN (nil); |
12 | 6239 |
} |
6240 |
||
6241 |
/* |
|
6242 |
* key, button and pointer events are sent to the sensor, |
|
6243 |
* or (if there is none) to the delegate. |
|
6244 |
* or (if there is none) to the view. |
|
26 | 6245 |
* |
6246 |
* expose events are sent to the sensor, |
|
6247 |
* or (if there is none) to the view |
|
6248 |
* |
|
12 | 6249 |
* sensor and delegate get view as additional argument |
115 | 6250 |
* all of this has been taken out of here to corresponding methods |
6251 |
* in DeviceWorkstation. |
|
12 | 6252 |
*/ |
90 | 6253 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6254 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6255 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6256 |
#endif |
135 | 6257 |
switch (ev->type) { |
70 | 6258 |
case KeyRelease: |
115 | 6259 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 6260 |
ipS = &skrS; |
150 | 6261 |
upDown = false; |
70 | 6262 |
goto keyPressAndRelease; |
6263 |
||
6264 |
case KeyPress: |
|
115 | 6265 |
symS = @symbol(keyPress:x:y:view:); |
70 | 6266 |
ipS = &skpS; |
150 | 6267 |
upDown = true; |
6268 |
/* FALL INTO */ |
|
70 | 6269 |
|
6270 |
keyPressAndRelease: |
|
6271 |
_INST(eventRootX) = _MKSMALLINT(ke->x_root); |
|
6272 |
_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
|
6273 |
#ifdef OLD |
70 | 6274 |
_INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
6275 |
_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
|
6276 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6277 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6278 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6279 |
#endif |
70 | 6280 |
_INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
150 | 6281 |
_INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
70 | 6282 |
|
6283 |
arg = nil; |
|
6284 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
6285 |
if (nchars |
|
6286 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
6287 |
|| (buffer[0] >= 0x80))) { |
|
6288 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
6289 |
keySymString = NULL; |
|
6290 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6291 |
#ifdef OLD |
150 | 6292 |
switch (keySym) { |
6293 |
case XK_Control_L: |
|
6294 |
case XK_Control_R: |
|
6295 |
_INST(ctrlDown) = upDown; |
|
6296 |
break; |
|
6297 |
case XK_Shift_L: |
|
6298 |
case XK_Shift_R: |
|
6299 |
_INST(shiftDown) = upDown; |
|
6300 |
break; |
|
6301 |
case XK_Meta_L: |
|
6302 |
case XK_Meta_R: |
|
6303 |
_INST(metaDown) = upDown; |
|
6304 |
break; |
|
6305 |
case XK_Alt_L: |
|
6306 |
case XK_Alt_R: |
|
6307 |
_INST(altDown) = upDown; |
|
6308 |
break; |
|
6309 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6310 |
#endif |
150 | 6311 |
|
70 | 6312 |
keySymString = XKeysymToString(keySym); |
6313 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6314 |
#ifdef OLD |
70 | 6315 |
if (keySymString[0] == 'D') { |
6316 |
/* |
|
6317 |
* remove underscore, dont want it in symbols |
|
6318 |
*/ |
|
6319 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
6320 |
keySymString = "DeleteLine"; |
|
6321 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
6322 |
keySymString = "DeleteWord"; |
|
6323 |
} |
|
6324 |
} |
|
6325 |
/* |
|
6326 |
* make names compatible |
|
6327 |
*/ |
|
6328 |
if (strcmp(keySymString, "Down") == 0) { |
|
6329 |
keySymString = "CursorDown"; |
|
6330 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
6331 |
keySymString = "CursorUp"; |
|
6332 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
6333 |
keySymString = "CursorLeft"; |
|
6334 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
6335 |
keySymString = "CursorRight"; |
|
6336 |
} |
|
6337 |
arg = _MKSYMBOL(keySymString, (OBJ *)0, __context); |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6338 |
#else |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6339 |
PROTECT(theView); |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6340 |
arg = __MKSTRING(keySymString COMMA_CON); |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6341 |
UNPROTECT(theView); |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
6342 |
#endif |
70 | 6343 |
} |
6344 |
} |
|
6345 |
||
6346 |
if (arg == nil) { |
|
6347 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
6348 |
break; |
|
6349 |
} |
|
6350 |
||
115 | 6351 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
6352 |
arg, |
|
6353 |
_MKSMALLINT(ke->x), |
|
6354 |
_MKSMALLINT(ke->y), |
|
6355 |
theView); |
|
70 | 6356 |
break; |
6357 |
||
6358 |
case ButtonPress: |
|
6359 |
_INST(buttonsPressed) = _MKSMALLINT(_intVal(_INST(buttonsPressed)) | (1 << be->button)); |
|
6360 |
_INST(eventRootX) = _MKSMALLINT(be->x_root); |
|
6361 |
_INST(eventRootY) = _MKSMALLINT(be->y_root); |
|
6362 |
||
97 | 6363 |
if (__isSmallInteger(_INST(multiClickTimeDelta))) |
70 | 6364 |
nextMultiClickTime = be->time + _intVal(_INST(multiClickTimeDelta)); |
6365 |
else |
|
6366 |
nextMultiClickTime = 0; |
|
6367 |
||
6368 |
if (multiClickTime) { |
|
6369 |
if (be->time < multiClickTime) { |
|
6370 |
multiClickTime = nextMultiClickTime; |
|
6371 |
ipS = &bmpS; |
|
6372 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
6373 |
goto sendButtonEvent; |
|
6374 |
break; |
|
6375 |
} |
|
6376 |
} |
|
6377 |
multiClickTime = nextMultiClickTime; |
|
6378 |
if (be->state & ShiftMask) { |
|
6379 |
ipS = &bspS; |
|
6380 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
6381 |
goto sendButtonEvent; |
|
6382 |
} |
|
6383 |
ipS = &bpS; |
|
6384 |
symS = @symbol(buttonPress:x:y:view:); |
|
6385 |
goto sendButtonEvent; |
|
200 | 6386 |
|
70 | 6387 |
/* NOT REACHED */ |
6388 |
||
6389 |
case ButtonRelease: |
|
6390 |
_INST(buttonsPressed) = _MKSMALLINT(_intVal(_INST(buttonsPressed)) & ~(1 << be->button)); |
|
6391 |
_INST(eventRootX) = _MKSMALLINT(be->x_root); |
|
6392 |
_INST(eventRootY) = _MKSMALLINT(be->y_root); |
|
6393 |
ipS = &brS; |
|
6394 |
symS = @symbol(buttonRelease:x:y:view:); |
|
6395 |
/* fall into */ |
|
6396 |
||
6397 |
sendButtonEvent: |
|
6398 |
butt = _MKSMALLINT(be->button); |
|
12 | 6399 |
#ifdef NOTDEF |
70 | 6400 |
/* |
6401 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
6402 |
*/ |
|
6403 |
if (_INST(metaDown) == true) |
|
6404 |
butt = _MKSMALLINT(2); |
|
6405 |
else |
|
0 | 6406 |
#endif |
193 | 6407 |
butt = __AT_(_INST(buttonTranslation), butt); |
200 | 6408 |
|
12 | 6409 |
|
115 | 6410 |
(*(*ipS).ilc_func)(self, |
6411 |
symS |
|
6412 |
COMMA_CON, nil, ipS, |
|
6413 |
butt, |
|
6414 |
_MKSMALLINT(ke->x), |
|
6415 |
_MKSMALLINT(ke->y), |
|
6416 |
theView); |
|
70 | 6417 |
break; |
6418 |
||
6419 |
case MotionNotify: |
|
6420 |
if (_INST(motionEventCompression) != false) { |
|
135 | 6421 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 6422 |
} |
6423 |
||
6424 |
_INST(eventRootX) = _MKSMALLINT(me->x_root); |
|
6425 |
_INST(eventRootY) = _MKSMALLINT(me->y_root); |
|
6426 |
||
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6427 |
#ifdef OLD |
150 | 6428 |
_INST(altDown) = (me->state & Mod2Mask) ? true : false; |
6429 |
_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
|
6430 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6431 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6432 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6433 |
#endif |
150 | 6434 |
_INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
6435 |
_INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
6436 |
||
115 | 6437 |
(*motS.ilc_func)(self, |
6438 |
@symbol(buttonMotion:x:y:view:) |
|
6439 |
COMMA_CON, nil, &motS, |
|
6440 |
_MKSMALLINT(me->state), |
|
6441 |
_MKSMALLINT(me->x), |
|
6442 |
_MKSMALLINT(me->y), |
|
6443 |
theView); |
|
70 | 6444 |
break; |
6445 |
||
6446 |
case FocusIn: |
|
115 | 6447 |
(*focInS.ilc_func)(self, |
6448 |
@symbol(focusInView:) |
|
6449 |
COMMA_CON, nil, &focInS, |
|
6450 |
theView); |
|
70 | 6451 |
break; |
6452 |
||
6453 |
case FocusOut: |
|
115 | 6454 |
(*focOutS.ilc_func)(self, |
6455 |
@symbol(focusOutView:) |
|
6456 |
COMMA_CON, nil, &focOutS, |
|
6457 |
theView); |
|
70 | 6458 |
break; |
6459 |
||
6460 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6461 |
#ifdef OLD |
150 | 6462 |
_INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
6463 |
_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
|
6464 |
#else |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6465 |
_INST(altDown) = (ke->state & __intVal(_INST(altModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6466 |
_INST(metaDown) = (ke->state & __intVal(_INST(metaModifierMask))) ? true : false; |
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
6467 |
#endif |
150 | 6468 |
_INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
6469 |
_INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
6470 |
||
115 | 6471 |
(*peS.ilc_func)(self, |
6472 |
@symbol(pointerEnter:x:y:view:) |
|
6473 |
COMMA_CON, nil, &peS, |
|
6474 |
_MKSMALLINT(ewe->state), |
|
6475 |
_MKSMALLINT(ewe->x), |
|
6476 |
_MKSMALLINT(ewe->y), |
|
6477 |
theView); |
|
70 | 6478 |
break; |
6479 |
||
6480 |
case LeaveNotify: |
|
115 | 6481 |
(*plS.ilc_func)(self, |
6482 |
@symbol(pointerLeave:view:) |
|
6483 |
COMMA_CON, nil, &plS, |
|
6484 |
_MKSMALLINT(lwe->state), |
|
6485 |
theView); |
|
70 | 6486 |
break; |
6487 |
||
6488 |
case GraphicsExpose: |
|
115 | 6489 |
(*gexpS.ilc_func)(self, |
6490 |
@symbol(graphicExposeX:y:width:height:view:) |
|
6491 |
COMMA_CON, nil, &gexpS, |
|
6492 |
_MKSMALLINT(ee->x), |
|
6493 |
_MKSMALLINT(ee->y), |
|
6494 |
_MKSMALLINT(ee->width), |
|
6495 |
_MKSMALLINT(ee->height), |
|
6496 |
theView); |
|
6497 |
||
6498 |
if (ee->count != 0) { |
|
70 | 6499 |
break; |
6500 |
} |
|
115 | 6501 |
/* fall into */ |
6502 |
||
6503 |
case NoExpose: |
|
6504 |
(*nexpS.ilc_func)(self, |
|
6505 |
@symbol(noExposeView:) |
|
6506 |
COMMA_CON, nil, &nexpS, |
|
6507 |
theView); |
|
6508 |
break; |
|
6509 |
||
6510 |
case Expose: |
|
6511 |
(*expS.ilc_func)(self, |
|
6512 |
@symbol(exposeX:y:width:height:view:) |
|
6513 |
COMMA_CON, nil, &expS, |
|
70 | 6514 |
_MKSMALLINT(ee->x), |
6515 |
_MKSMALLINT(ee->y), |
|
6516 |
_MKSMALLINT(ee->width), |
|
115 | 6517 |
_MKSMALLINT(ee->height), |
6518 |
theView); |
|
70 | 6519 |
break; |
6520 |
||
6521 |
case ConfigureNotify: |
|
6522 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6523 |
siblingID = __MKOBJ(ce->above); |
70 | 6524 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6525 |
COMMA_CON, nil, &vid, siblingID); |
70 | 6526 |
} |
6527 |
||
115 | 6528 |
(*confS.ilc_func)(self, |
6529 |
@symbol(configureX:y:width:height:view:) |
|
6530 |
COMMA_CON, nil, &confS, |
|
70 | 6531 |
_MKSMALLINT(ce->x), |
6532 |
_MKSMALLINT(ce->y), |
|
6533 |
_MKSMALLINT(ce->width), |
|
115 | 6534 |
_MKSMALLINT(ce->height), |
6535 |
theView); |
|
70 | 6536 |
if (sibling != nil) { |
115 | 6537 |
(*coveredS.ilc_func)(self, |
6538 |
@symbol(coveredBy:view:) |
|
6539 |
COMMA_CON, nil, &coveredS, |
|
6540 |
theView, |
|
6541 |
sibling); |
|
70 | 6542 |
} |
6543 |
break; |
|
6544 |
||
6545 |
case ClientMessage: |
|
135 | 6546 |
if (ev->xclient.message_type == (int) _AtomVal(_INST(protocolsAtom))) { |
6547 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(_INST(quitAppAtom))) |
|
6548 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(_INST(deleteWindowAtom)))) { |
|
115 | 6549 |
(*termS.ilc_func)(self, |
6550 |
@symbol(terminateView:) |
|
6551 |
COMMA_CON, nil, &termS, theView); |
|
70 | 6552 |
break; |
6553 |
} |
|
135 | 6554 |
if (ev->xclient.data.l[0] == (int) _AtomVal(_INST(saveYourselfAtom))) { |
115 | 6555 |
(*savtermS.ilc_func)(self, |
6556 |
@symbol(saveAndTerminateView:) |
|
6557 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 6558 |
break; |
6559 |
} |
|
6560 |
} |
|
6561 |
break; |
|
6562 |
||
6563 |
case DestroyNotify: |
|
115 | 6564 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
6565 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 6566 |
break; |
6567 |
||
6568 |
case UnmapNotify: |
|
115 | 6569 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
6570 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 6571 |
break; |
6572 |
||
6573 |
case MapNotify: |
|
115 | 6574 |
(*mapS.ilc_func)(self, |
6575 |
@symbol(mappedView:) |
|
6576 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 6577 |
break; |
6578 |
||
6579 |
case KeymapNotify: |
|
115 | 6580 |
(*keymap.ilc_func)(theView, |
6581 |
@symbol(keyMapChange) |
|
6582 |
COMMA_CON, nil, &keymap); |
|
70 | 6583 |
break; |
6584 |
||
6585 |
case VisibilityNotify: |
|
6586 |
switch (ve->state) { |
|
6587 |
case VisibilityUnobscured: |
|
6588 |
arg = @symbol(unobscured); |
|
6589 |
break; |
|
6590 |
case VisibilityPartiallyObscured: |
|
6591 |
arg = @symbol(partiallyObscured); |
|
6592 |
break; |
|
6593 |
case VisibilityFullyObscured: |
|
6594 |
arg = @symbol(fullyObscured); |
|
6595 |
break; |
|
6596 |
} |
|
6597 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
6598 |
break; |
|
6599 |
||
6600 |
case CreateNotify: |
|
6601 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
6602 |
break; |
|
6603 |
||
6604 |
case MapRequest: |
|
6605 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
6606 |
break; |
|
6607 |
||
6608 |
case ReparentNotify: |
|
6609 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
6610 |
break; |
|
6611 |
||
6612 |
case ConfigureRequest: |
|
6613 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
6614 |
break; |
|
6615 |
||
6616 |
case GravityNotify: |
|
6617 |
case ResizeRequest: |
|
6618 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
6619 |
break; |
|
6620 |
||
6621 |
case CirculateNotify: |
|
6622 |
case CirculateRequest: |
|
6623 |
break; |
|
6624 |
||
6625 |
case PropertyNotify: |
|
115 | 6626 |
(*prop.ilc_func)(theView, |
6627 |
@symbol(propertyChange) |
|
6628 |
COMMA_CON, nil, &prop); |
|
70 | 6629 |
break; |
6630 |
||
6631 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6632 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 6633 |
(*selClear.ilc_func)(theView, |
129 | 6634 |
@symbol(selectionClear:) |
6635 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6636 |
selectionID); |
70 | 6637 |
break; |
6638 |
||
90 | 6639 |
case SelectionNotify: |
6640 |
/* |
|
6641 |
* returned selection value (answer from SelectionRequest) |
|
6642 |
*/ |
|
129 | 6643 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 6644 |
ev->xselection.property, ev->xselection.target, |
6645 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 6646 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6647 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6648 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6649 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6650 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 6651 |
(*selNotify.ilc_func)(theView, |
6652 |
@symbol(selectionNotify:target:selection:from:) |
|
6653 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6654 |
propertyID, targetID, selectionID, requestorID); |
70 | 6655 |
break; |
6656 |
||
90 | 6657 |
case SelectionRequest: |
129 | 6658 |
/* |
6659 |
* someone wants the selection |
|
6660 |
*/ |
|
6661 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 6662 |
ev->xselectionrequest.property, |
6663 |
ev->xselectionrequest.target, |
|
6664 |
ev->xselectionrequest.selection, |
|
6665 |
ev->xselectionrequest.requestor)); |
|
129 | 6666 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6667 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6668 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6669 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
6670 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 6671 |
(*selReq.ilc_func)(theView, |
6672 |
@symbol(selectionRequest:target:selection:from:) |
|
6673 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6674 |
propertyID, targetID, selectionID, requestorID); |
70 | 6675 |
break; |
6676 |
||
6677 |
case ColormapNotify: |
|
115 | 6678 |
(*colormap.ilc_func)(theView, |
6679 |
@symbol(colorMapChange) |
|
6680 |
COMMA_CON, nil, &colormap); |
|
70 | 6681 |
break; |
6682 |
||
6683 |
case MappingNotify: |
|
90 | 6684 |
/* |
23 | 6685 |
printf("mapping\n"); |
90 | 6686 |
*/ |
23 | 6687 |
/* |
115 | 6688 |
(*mapping.ilc_func)(theView, |
6689 |
@symbol(mapping) |
|
6690 |
COMMA_CON, nil, &mapping); |
|
23 | 6691 |
*/ |
70 | 6692 |
break; |
0 | 6693 |
} |
135 | 6694 |
#undef ae |
0 | 6695 |
#undef ee |
6696 |
#undef ke |
|
6697 |
#undef be |
|
6698 |
#undef ce |
|
6699 |
#undef me |
|
6700 |
#undef ewe |
|
6701 |
#undef lwe |
|
6702 |
#undef de |
|
6703 |
%} |
|
6704 |
. |
|
6705 |
^ true |
|
6706 |
! |
|
6707 |
||
81 | 6708 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
6709 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
6710 |
events matching the mask are thrown away regardless of which |
|
6711 |
view they are for. Otherwise, only matching events for that |
|
6712 |
view are flushed." |
|
0 | 6713 |
|
6714 |
%{ /* NOCONTEXT */ |
|
6715 |
||
6716 |
Display *dpy = myDpy; |
|
6717 |
XEvent ev; |
|
6718 |
Window win; |
|
6719 |
||
97 | 6720 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6721 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 6722 |
win = _WindowVal(aWindowIdOrNil); |
6723 |
while (XCheckWindowEvent(dpy, win, _intVal(aMask), &ev)) ;; |
|
6724 |
} else { |
|
6725 |
while (XCheckMaskEvent(dpy, _intVal(aMask), &ev)) ;; |
|
6726 |
} |
|
70 | 6727 |
RETURN ( self ); |
0 | 6728 |
} |
6729 |
%} |
|
6730 |
. |
|
6731 |
self primitiveFailed |
|
6732 |
! |
|
6733 |
||
12 | 6734 |
eventPending |
6735 |
"return true, if any event is pending" |
|
6736 |
||
6737 |
dispatchingExpose notNil ifTrue:[ |
|
70 | 6738 |
^ self exposeEventPendingFor:dispatchingExpose |
12 | 6739 |
]. |
54 | 6740 |
"/ ^ self eventPendingWithSync |
6741 |
^ self eventPendingWithoutSync |
|
0 | 6742 |
! |
6743 |
||
12 | 6744 |
eventPendingWithSync |
7 | 6745 |
"return true, if any event is pending. |
6746 |
Do a flush output buffer before." |
|
0 | 6747 |
|
12 | 6748 |
%{ /* UNLIMITEDSTACK */ |
0 | 6749 |
|
6750 |
Display *dpy = myDpy; |
|
6751 |
||
150 | 6752 |
if (ISCONNECTED) { |
6753 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
6754 |
if (XPending(dpy)) { |
|
6755 |
RETURN (true); |
|
6756 |
} |
|
6757 |
} |
|
6758 |
RETURN ( false ); |
|
0 | 6759 |
%} |
6760 |
! |
|
6761 |
||
6762 |
eventPendingWithoutSync |
|
23 | 6763 |
"return true, if any event is pending." |
12 | 6764 |
|
6765 |
%{ /* UNLIMITEDSTACK */ |
|
0 | 6766 |
|
150 | 6767 |
if (ISCONNECTED) { |
6768 |
if (XPending(myDpy)) { |
|
6769 |
RETURN (true); |
|
6770 |
} |
|
6771 |
} |
|
6772 |
RETURN ( false ); |
|
0 | 6773 |
%} |
6774 |
! |
|
6775 |
||
81 | 6776 |
exposeEventPendingFor:aWindowIdOrNil |
7 | 6777 |
"return true, if any expose event is pending" |
6778 |
||
12 | 6779 |
%{ /* UNLIMITEDSTACK */ |
7 | 6780 |
|
6781 |
Display *dpy = myDpy; |
|
6782 |
XEvent ev; |
|
6783 |
Window win; |
|
81 | 6784 |
int thereIsOne; |
6785 |
||
150 | 6786 |
if (ISCONNECTED) { |
6787 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6788 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 6789 |
win = _WindowVal(aWindowIdOrNil); |
6790 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
6791 |
} else { |
|
6792 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
6793 |
} |
|
6794 |
if (thereIsOne) { |
|
6795 |
XPutBackEvent(dpy, &ev); |
|
6796 |
RETURN ( true ); |
|
6797 |
} |
|
81 | 6798 |
} |
6799 |
RETURN ( false ); |
|
6800 |
%} |
|
6801 |
! |
|
6802 |
||
6803 |
eventsPending:anEventMask for:aWindowIdOrNil |
|
6804 |
"return true, if any of the masked events is pending" |
|
6805 |
||
6806 |
%{ /* UNLIMITEDSTACK */ |
|
6807 |
||
6808 |
Display *dpy = myDpy; |
|
6809 |
XEvent ev; |
|
6810 |
Window win; |
|
6811 |
int thereIsOne; |
|
6812 |
||
150 | 6813 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
81 | 6814 |
XSync(dpy, 0); /* make certain everything is flushed */ |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
6815 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 6816 |
win = _WindowVal(aWindowIdOrNil); |
6817 |
thereIsOne = XCheckWindowEvent(dpy, win, _intVal(anEventMask), &ev); |
|
6818 |
} else { |
|
6819 |
thereIsOne = XCheckMaskEvent(dpy, _intVal(anEventMask), &ev); |
|
6820 |
} |
|
6821 |
if (thereIsOne) { |
|
70 | 6822 |
XPutBackEvent(dpy, &ev); |
6823 |
RETURN ( true ); |
|
6824 |
} |
|
7 | 6825 |
} |
12 | 6826 |
RETURN ( false ); |
7 | 6827 |
%} |
6828 |
! |
|
216 | 6829 |
|
81 | 6830 |
eventPending:anEventSymbol for:aWindowIdOrNil |
0 | 6831 |
"return true, if a specific event is pending" |
6832 |
||
81 | 6833 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil |
0 | 6834 |
! ! |