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