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