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