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