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