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