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