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