author | Claus Gittinger <cg@exept.de> |
Fri, 19 Jul 1996 18:39:53 +0200 | |
changeset 963 | 45ebbbb40f38 |
parent 928 | 680dcd56df6b |
child 972 | ff1c744b8d88 |
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 |
|
341 | 14 |
instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
15 |
hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
16 |
hasPEXExtension hasImageExtension hasInputExtension |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
17 |
ignoreBackingStore blackpixel whitepixel protocolsAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
18 |
deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
19 |
secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
20 |
buttonsPressed eventRootX eventRootY displayName eventTrace |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
21 |
dispatchingExpose rgbVisual virtualRootId rootId eventBuffer |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
22 |
altModifierMask metaModifierMask' |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
23 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
341 | 24 |
poolDictionaries:'' |
25 |
category:'Interface-Graphics' |
|
295 | 26 |
! |
0 | 27 |
|
78 | 28 |
!XWorkstation primitiveDefinitions! |
0 | 29 |
%{ |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
30 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
31 |
#define COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
32 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
33 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
34 |
static int __cnt_color = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
35 |
static int __cnt_bitmap = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
36 |
static int __cnt_view = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
37 |
static int __cnt_gc = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
38 |
static int __cnt_cursor = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
39 |
static int __cnt_font = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
40 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
41 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
42 |
|
46 | 43 |
/* |
44 |
* x does a typedef Time - I need Object Time ... |
|
45 |
*/ |
|
0 | 46 |
#define Time XTime |
47 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
48 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
49 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
50 |
* we are lucky - the ST/X True/False are not needed |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
51 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
52 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
53 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
54 |
|
37 | 55 |
#ifdef memset |
56 |
# undef memset |
|
57 |
#endif |
|
58 |
||
0 | 59 |
#include <stdio.h> |
60 |
#include <X11/Xlib.h> |
|
61 |
#include <X11/Xutil.h> |
|
62 |
#include <X11/Xatom.h> |
|
63 |
||
150 | 64 |
#define XK_MISCELLANY |
65 |
#include <X11/keysymdef.h> |
|
66 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
67 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
68 |
|
90 | 69 |
/* |
70 |
* this define adds support for two-byte-strings. |
|
71 |
* leaving it undefined does not really save you much |
|
72 |
* (the define will vanish) |
|
73 |
*/ |
|
36 | 74 |
#define TWOBYTESTRINGS |
75 |
||
0 | 76 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
77 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
78 |
* TrueColor systems - I am not certain, if this is |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
79 |
* always legal to do (it works with XFree servers). |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
80 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
81 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
82 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
83 |
/* |
0 | 84 |
* shape support works; enabled by -DSHAPE in makefile |
85 |
* see RoundClock and RoundGlobe examples |
|
86 |
*/ |
|
87 |
#ifdef SHAPE |
|
88 |
# include <X11/extensions/shape.h> |
|
89 |
#endif |
|
90 |
||
91 |
/* |
|
150 | 92 |
* shared memory extension access is currently not supported |
0 | 93 |
* (only query is implemented) |
94 |
*/ |
|
95 |
#ifdef SHM |
|
96 |
# include <X11/extensions/XShm.h> |
|
97 |
#endif |
|
98 |
||
99 |
/* |
|
150 | 100 |
* multiBuffer extension access is currently not supported |
101 |
* (only query is implemented) |
|
102 |
*/ |
|
103 |
#ifdef MBUF |
|
104 |
# include <X11/extensions/multibuf.h> |
|
105 |
#endif |
|
106 |
||
107 |
/* |
|
108 |
* XVideo extension access is currently not supported |
|
109 |
* (only query is implemented) |
|
110 |
*/ |
|
111 |
#ifdef XVIDEO |
|
112 |
# include <X11/extensions/Xv.h> |
|
113 |
#endif |
|
114 |
||
115 |
/* |
|
0 | 116 |
* this is a non-standard fax-image decompression extension |
117 |
* (only found in megascan servers ported by myself) |
|
118 |
*/ |
|
119 |
#ifdef FAX |
|
120 |
# include <X11/extensions/XFAXImage.h> |
|
121 |
#endif |
|
122 |
||
123 |
/* |
|
186 | 124 |
* PEX extension - if available |
125 |
*/ |
|
126 |
#ifdef PEX5 |
|
127 |
# include <PEX5/PEX.h> |
|
128 |
#endif |
|
129 |
||
130 |
/* |
|
131 |
* XImage extension - if available |
|
132 |
*/ |
|
133 |
#ifdef XIE |
|
134 |
# include <X11/extensions/XIE.h> |
|
135 |
#endif |
|
136 |
||
137 |
/* |
|
90 | 138 |
* when I have more time to check it out, I will support display-PS |
0 | 139 |
*/ |
140 |
#ifdef DPS |
|
141 |
# ifdef sgi |
|
142 |
# include <X11/extensions/XDPS.h> |
|
143 |
# include <X11/extensions/XDPSlib.h> |
|
144 |
# include <X11/extensions/dpsXclient.h> |
|
145 |
# else |
|
146 |
# include <DPS/XDPS.h> |
|
147 |
# include <DPS/XDPSlib.h> |
|
148 |
# include <DPS/dpsXclient.h> |
|
149 |
# endif |
|
150 |
#endif |
|
151 |
||
90 | 152 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
153 |
/* |
|
154 |
* accessing private data in Display ... sorry |
|
155 |
*/ |
|
156 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
157 |
#else |
|
158 |
# define DISPLAYACCESS(d) d |
|
159 |
#endif |
|
160 |
||
78 | 161 |
/* |
162 |
* some defines - tired of typing ... |
|
163 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
164 |
#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
|
165 |
#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
|
166 |
#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
|
167 |
#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
|
168 |
#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
|
169 |
#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
|
170 |
#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
|
171 |
|
211 | 172 |
#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
|
173 |
#define _AtomVal(o) __intVal(o) |
211 | 174 |
#define __isAtomID(o) __isSmallInteger(o) |
175 |
||
555 | 176 |
#define myDpy _DisplayVal(__INST(displayId)) |
177 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 178 |
|
179 |
#ifndef THISCONTEXT_IN_REGISTER |
|
180 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
181 |
# define END_INTERRUPTSBLOCKED /* */ |
|
182 |
#else |
|
183 |
extern int __interruptsBlocked; |
|
184 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
185 |
{ \ |
|
850 | 186 |
int needUnblock = 0; \ |
187 |
extern OBJ __thisContext__; \ |
|
188 |
\ |
|
189 |
__thisContext__ = __thisContext;\ |
|
190 |
if (!__interruptsBlocked) { \ |
|
191 |
__BLOCKINTERRUPTS(); \ |
|
192 |
needUnblock = 1; \ |
|
193 |
} |
|
78 | 194 |
|
195 |
# define END_INTERRUPTSBLOCKED \ |
|
850 | 196 |
__thisContext = __thisContext; \ |
197 |
__thisContext__ = 0; \ |
|
198 |
if (needUnblock) { \ |
|
199 |
__UNBLOCKINTERRUPTS(); \ |
|
200 |
} \ |
|
78 | 201 |
} |
202 |
||
203 |
#endif |
|
204 |
%} |
|
205 |
! ! |
|
206 |
||
207 |
!XWorkstation primitiveVariables! |
|
208 |
%{ |
|
0 | 209 |
/* |
146 | 210 |
* remembered info from private error handler |
0 | 211 |
*/ |
2 | 212 |
static char lastErrorMsg[80] = ""; |
213 |
static unsigned lastRequestCode = 0; |
|
214 |
static unsigned lastMinorCode = 0; |
|
215 |
static unsigned lastResource = 0; |
|
129 | 216 |
|
217 |
static int __debug__ = 0; |
|
218 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 219 |
%} |
220 |
! ! |
|
221 |
||
222 |
!XWorkstation primitiveFunctions! |
|
223 |
%{ |
|
18 | 224 |
/* |
144 | 225 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
226 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 227 |
* the implementation below is somewhat wrong: it will |
78 | 228 |
* report all errors for Display, even though there could be |
162 | 229 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
230 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 231 |
*/ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
232 |
|
12 | 233 |
__XErrorHandler__(dpy, event) |
0 | 234 |
Display *dpy; |
235 |
XErrorEvent *event; |
|
236 |
{ |
|
237 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
|
238 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 239 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 240 |
} |
2 | 241 |
lastRequestCode = event->request_code; |
242 |
lastMinorCode = event->minor_code; |
|
243 |
lastResource = event->resourceid; |
|
911 | 244 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
245 |
/* |
|
246 |
* this is a BadWindow error for X_DestroyWindow. |
|
247 |
* ignore it here, since it results from the GC freeing windows |
|
248 |
* in non bottom-up window order. |
|
249 |
*/ |
|
250 |
return 0; |
|
251 |
} |
|
2 | 252 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
253 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
254 |
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
|
255 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
256 |
event->minor_code, event->minor_code, event->resourceid); |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
257 |
fprintf(stderr, "XWORKSTAT: x-error message is [%d] '%s'\n", event->error_code, lastErrorMsg); |
218
10072d9beba5
can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
258 |
} |
43 | 259 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
260 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 261 |
return 0; |
262 |
} |
|
263 |
||
90 | 264 |
#ifdef VIRTUAL_ROOT |
0 | 265 |
/* |
18 | 266 |
* added since RootWindow-macro is not suficient |
267 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
268 |
*/ |
|
269 |
static Window |
|
270 |
getRootWindow(dpy, screen) |
|
271 |
Display *dpy; |
|
272 |
{ |
|
273 |
Window root; |
|
274 |
Atom vRootAtom = None; |
|
275 |
int i; |
|
276 |
Window rootReturn, parentReturn; |
|
277 |
Window* children; |
|
278 |
unsigned int numChildren; |
|
279 |
||
280 |
root = RootWindow(dpy, screen); |
|
281 |
/* |
|
282 |
* on IRIS, this creates a badwindow error - why ? |
|
283 |
* children contains a funny window (000034) |
|
284 |
*/ |
|
90 | 285 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 286 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 287 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
288 |
if (vRootAtom != None) { |
|
289 |
for (i=0; i < numChildren; i++) { |
|
290 |
Atom actual_type; |
|
291 |
int actual_format; |
|
292 |
unsigned long nitems, bytesafter; |
|
293 |
Window* newRoot = (Window*) 0; |
|
294 |
||
295 |
if (children[i]) { |
|
296 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
297 |
0L, 1L, False, XA_WINDOW, |
|
298 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
299 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
300 |
root = *newRoot; |
|
301 |
break; |
|
302 |
} |
|
303 |
} |
|
304 |
} |
|
305 |
if (children) XFree( children ); |
|
306 |
} |
|
18 | 307 |
} |
90 | 308 |
# endif |
18 | 309 |
return root; |
310 |
} |
|
90 | 311 |
#endif |
0 | 312 |
%} |
78 | 313 |
! ! |
0 | 314 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
315 |
!XWorkstation class methodsFor:'documentation'! |
295 | 316 |
|
317 |
copyright |
|
318 |
" |
|
319 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
320 |
All Rights Reserved |
|
321 |
||
322 |
This software is furnished under a license and may be used |
|
323 |
only in accordance with the terms of that license and with the |
|
324 |
inclusion of the above copyright notice. This software may not |
|
325 |
be provided or otherwise made available to, or used by, any |
|
326 |
other person. No title to or ownership of the software is |
|
327 |
hereby transferred. |
|
328 |
" |
|
329 |
! |
|
330 |
||
331 |
documentation |
|
332 |
" |
|
333 |
this class provides the interface to X11. It redefines all required methods |
|
334 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
335 |
limited to one display - in theory, you can create Views on many displays |
|
336 |
simultanously. However, the default setup is for one display only. |
|
337 |
To support multiple displays, you will have to start another event dispatcher |
|
338 |
process for the other display(s) and create the other views with a slightly |
|
339 |
different protocol. However, 'normal' applications do not have to care for |
|
340 |
all of this ... |
|
341 |
||
342 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 343 |
|
344 |
[author:] |
|
850 | 345 |
Claus Gittinger |
295 | 346 |
" |
347 |
! ! |
|
348 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
349 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
350 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
351 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
352 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
353 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
354 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
355 |
|
386 | 356 |
RawKeysymTranslation isNil ifTrue:[ |
357 |
"/ the following table maps X-keyevents to ST/X |
|
358 |
"/ device independed events. |
|
359 |
"/ It is NOT meant as a keyboardMap replacement. |
|
360 |
||
361 |
RawKeysymTranslation := d := Dictionary new. |
|
362 |
d at:'Delete_line' put:#DeleteLine. |
|
363 |
d at:'Delete_word' put:#DeleteWord. |
|
364 |
d at:'Down' put:#CursorDown. |
|
365 |
d at:'Up' put:#CursorUp. |
|
366 |
d at:'Left' put:#CursorLeft. |
|
367 |
d at:'Right' put:#CursorRight. |
|
368 |
] |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
369 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
370 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
371 |
!XWorkstation class methodsFor:'error handling'! |
2 | 372 |
|
129 | 373 |
debug:aBoolean |
374 |
%{ /* NOCONTEXT */ |
|
375 |
||
376 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
377 |
%} |
|
378 |
! |
|
379 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
380 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
381 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
382 |
#ifdef COUNT_RESOURCES |
928 | 383 |
printf("colors %d bitmaps %d view %d gc %d cursor %d font %d\n", |
384 |
__cnt_color, __cnt_bitmap, |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
385 |
__cnt_view, __cnt_gc, __cnt_cursor, __cnt_font); |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
386 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
387 |
%} |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
388 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
389 |
|
78 | 390 |
errorStringOfLastError |
391 |
%{ |
|
216 | 392 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 393 |
%} |
394 |
! |
|
395 |
||
135 | 396 |
lastErrorString |
2 | 397 |
"return the last X-error string - |
398 |
when buffering is on, this may be |
|
399 |
an error for a long-ago operation" |
|
78 | 400 |
|
401 |
|string requestCode s match line| |
|
402 |
||
403 |
string := self errorStringOfLastError. |
|
404 |
requestCode := self requestCodeOfLastError. |
|
405 |
" |
|
406 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
407 |
and append the name of the corresponding X-request |
|
408 |
" |
|
409 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
410 |
s notNil ifTrue:[ |
|
411 |
match := 'XRequest.' , requestCode printString. |
|
412 |
line := s peekForLineStartingWith:match. |
|
413 |
line notNil ifTrue:[ |
|
414 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
415 |
]. |
|
416 |
s close. |
|
417 |
]. |
|
418 |
^ string |
|
295 | 419 |
! |
420 |
||
421 |
minorCodeOfLastError |
|
422 |
%{ /* NOCONTEXT */ |
|
423 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
424 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 425 |
%} |
426 |
! |
|
427 |
||
428 |
requestCodeOfLastError |
|
152 | 429 |
%{ /* NOCONTEXT */ |
430 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
431 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 432 |
%} |
135 | 433 |
! |
434 |
||
295 | 435 |
resourceIdOfLastError |
0 | 436 |
%{ /* NOCONTEXT */ |
295 | 437 |
|
438 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 439 |
%} |
440 |
! ! |
|
441 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
442 |
!XWorkstation class methodsFor:'queries'! |
104 | 443 |
|
444 |
platformName |
|
133 | 445 |
"ST-80 compatibility. |
446 |
Return a string describing the display systems platform." |
|
447 |
||
715 | 448 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
449 |
||
450 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 451 |
! ! |
452 |
||
0 | 453 |
!XWorkstation methodsFor:'accessing & queries'! |
454 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
455 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
456 |
"return the state-mask for any button in motion events' state-field. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
457 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
458 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
459 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
460 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
461 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
462 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
463 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
464 |
|
295 | 465 |
blackpixel |
466 |
"return the colornumber of black" |
|
467 |
||
468 |
^ blackpixel |
|
469 |
! |
|
470 |
||
471 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
472 |
"return the state-mask for button1 in motion events' state-field. |
295 | 473 |
For backward compatibility." |
474 |
||
475 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
476 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 477 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
478 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
479 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
480 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
481 |
" |
295 | 482 |
! |
483 |
||
484 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
485 |
"return the state-mask for button2 in motion events' state-field |
295 | 486 |
For backward compatibility." |
487 |
||
488 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
489 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 490 |
%} |
491 |
! |
|
492 |
||
493 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
494 |
"return the state-mask for button3 in motion events' state-field |
295 | 495 |
For backward compatibility." |
496 |
||
497 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
498 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 499 |
%} |
500 |
! |
|
501 |
||
502 |
buttonMotionMask:aButton |
|
503 |
"return the state-mask for button1 in motion events state-field. |
|
504 |
This is the devices mask." |
|
505 |
||
506 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
507 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
508 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
509 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
510 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
511 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
512 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
513 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
514 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 515 |
} |
516 |
%}. |
|
517 |
^ nil |
|
518 |
! |
|
519 |
||
382 | 520 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
521 |
"return the state-mask for the CTRL modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
522 |
|
382 | 523 |
%{ /* NOCONTEXT */ |
524 |
RETURN (__MKSMALLINT(ControlMask)); |
|
525 |
%} |
|
526 |
! |
|
527 |
||
295 | 528 |
defaultEventMask |
529 |
"return a mask to enable some events by default." |
|
530 |
||
531 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
532 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 533 |
KeyPressMask | KeyReleaseMask | |
534 |
EnterWindowMask | LeaveWindowMask | |
|
535 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
536 |
%} |
|
537 |
! |
|
538 |
||
0 | 539 |
displayFileDescriptor |
540 |
"return the displays fileNumber - for select" |
|
541 |
||
542 |
%{ /* NOCONTEXT */ |
|
543 |
||
150 | 544 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
545 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 546 |
} |
547 |
RETURN (nil); |
|
0 | 548 |
%} |
549 |
! |
|
550 |
||
133 | 551 |
displayName |
552 |
"return the X-connections display name. |
|
553 |
This is (currently) nil for the default display, |
|
554 |
something like foo:0 for any other remote display. |
|
555 |
Future versions may return non-nil strings for the default display as well." |
|
556 |
||
557 |
^ displayName |
|
558 |
! |
|
559 |
||
341 | 560 |
protocolVersion |
561 |
"return the X-servers protocol version - should normally not be of |
|
562 |
any interest" |
|
563 |
||
564 |
%{ /* NOCONTEXT */ |
|
565 |
if (ISCONNECTED) { |
|
566 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
567 |
} |
|
568 |
RETURN (nil); |
|
569 |
%} |
|
570 |
||
571 |
" |
|
572 |
Display protocolVersion |
|
573 |
" |
|
574 |
! |
|
575 |
||
576 |
serverVendor |
|
577 |
"return the X-server vendor string - this should normally not be of |
|
578 |
any interest, but can be for special cases |
|
579 |
(to avoid bugs in certain implementations)" |
|
580 |
%{ |
|
581 |
if (ISCONNECTED) { |
|
582 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
583 |
} |
|
584 |
RETURN (nil); |
|
585 |
%} |
|
586 |
||
587 |
" |
|
588 |
Display serverVendor |
|
589 |
" |
|
590 |
! |
|
591 |
||
382 | 592 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
593 |
"return the state-mask for the SHIFT modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
594 |
|
382 | 595 |
%{ /* NOCONTEXT */ |
596 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
597 |
%} |
|
598 |
! |
|
599 |
||
341 | 600 |
translatePoint:aPoint from:windowId1 to:windowId2 |
601 |
"given a point in window1, return the coordinate in window2. |
|
602 |
This expects a device coordinate (relative to the first views origin) |
|
603 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
604 |
- use to xlate points from a window to rootwindow" |
|
605 |
||
606 |
|x1 y1 x2 y2| |
|
607 |
||
608 |
x1 := x2 := aPoint x truncated. |
|
609 |
y1 := y2 := aPoint y truncated. |
|
610 |
%{ |
|
611 |
int xpos, ypos; |
|
612 |
Window w1, w2, child_return; |
|
555 | 613 |
int screen = __intVal(__INST(screen)); |
341 | 614 |
Display *dpy = myDpy; |
615 |
||
616 |
if (__isExternalAddress(windowId1) |
|
617 |
&& __isExternalAddress(windowId2) |
|
618 |
&& __bothSmallInteger(x1, y1)) { |
|
619 |
w1 = _WindowVal(windowId1); |
|
620 |
w2 = _WindowVal(windowId2); |
|
621 |
#ifdef VIRTUAL_ROOT |
|
622 |
if ((w1 == RootWindow(dpy, screen)) |
|
623 |
|| (w2 == RootWindow(dpy, screen))) { |
|
624 |
if (w1 == RootWindow(dpy, screen)) { |
|
625 |
w1 = getRootWindow(dpy, screen); |
|
626 |
} |
|
627 |
if (w2 == RootWindow(dpy, screen)) { |
|
628 |
w2 = getRootWindow(dpy, screen); |
|
629 |
} |
|
630 |
} |
|
631 |
#endif |
|
632 |
BEGIN_INTERRUPTSBLOCKED |
|
633 |
XTranslateCoordinates(dpy, w1, w2, |
|
555 | 634 |
__intVal(x1), __intVal(y1), |
341 | 635 |
&xpos, &ypos, &child_return); |
636 |
END_INTERRUPTSBLOCKED |
|
637 |
x2 = __MKSMALLINT(xpos); |
|
638 |
y2 = __MKSMALLINT(ypos); |
|
639 |
} |
|
640 |
%}. |
|
641 |
||
642 |
^ (x2 @ y2) |
|
643 |
! |
|
644 |
||
645 |
vendorRelease |
|
646 |
"return the X-servers vendor release - should normally not be of |
|
647 |
any interest, but can be for special cases. |
|
648 |
(to avoid bugs in certain implementations)" |
|
649 |
||
650 |
%{ /* NOCONTEXT */ |
|
651 |
if (ISCONNECTED) { |
|
652 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
653 |
} |
|
654 |
RETURN (nil); |
|
655 |
%} |
|
656 |
||
657 |
" |
|
658 |
Display vendorRelease |
|
659 |
" |
|
660 |
! |
|
661 |
||
662 |
viewIdFromPoint:aPoint in:windowId |
|
663 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
664 |
hit by this coordinate. Return nil if no view was hit. |
|
665 |
The returned id may be the id of a non ST view. |
|
666 |
- used to find the window to drop objects after a cross-view drag." |
|
667 |
||
668 |
%{ /* NOCONTEXT */ |
|
669 |
||
670 |
Display *dpy = myDpy; |
|
555 | 671 |
int screen = __intVal(__INST(screen)); |
341 | 672 |
OBJ xp, yp; |
673 |
int xpos, ypos; |
|
674 |
Window child_return; |
|
675 |
||
676 |
if (__isExternalAddress(windowId) |
|
677 |
&& __isPoint(aPoint)) { |
|
678 |
xp = _point_X(aPoint); |
|
679 |
yp = _point_Y(aPoint); |
|
680 |
if (__bothSmallInteger(xp, yp)) { |
|
681 |
BEGIN_INTERRUPTSBLOCKED |
|
682 |
XTranslateCoordinates(dpy, |
|
683 |
RootWindow(dpy, screen), |
|
684 |
_WindowVal(windowId), |
|
555 | 685 |
__intVal(xp), __intVal(yp), |
341 | 686 |
&xpos, &ypos, &child_return); |
687 |
END_INTERRUPTSBLOCKED |
|
688 |
if (child_return) { |
|
689 |
RETURN ( __MKOBJ(child_return) ); |
|
690 |
} |
|
691 |
RETURN ( nil ); |
|
692 |
} |
|
693 |
} |
|
694 |
%}. |
|
695 |
windowId notNil ifTrue:[ |
|
696 |
aPoint isPoint ifTrue:[ |
|
697 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
698 |
] |
|
699 |
]. |
|
700 |
||
701 |
^ nil |
|
702 |
! |
|
703 |
||
704 |
virtualExtent |
|
705 |
"return the virtual extent of the display (in pixels). |
|
706 |
On most systems, this is the same as the physical width; |
|
707 |
except, if a window manager with a virtual desktop like olvwm |
|
708 |
(simulating a bigger screen) is running." |
|
709 |
||
710 |
%{ |
|
555 | 711 |
if ((__INST(rootId) != __INST(virtualRootId)) |
712 |
&& __isExternalAddress(__INST(virtualRootId))) { |
|
341 | 713 |
Window vRootWin; |
714 |
Window root; |
|
715 |
int x, y; |
|
716 |
unsigned int width, height; |
|
717 |
unsigned int dummy; |
|
718 |
||
555 | 719 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
341 | 720 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
721 |
&dummy, &dummy)) { |
|
722 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
723 |
} |
|
724 |
} |
|
725 |
%}. |
|
726 |
^ width @ height |
|
727 |
! |
|
728 |
||
729 |
whitepixel |
|
730 |
"return the colornumber of white" |
|
731 |
||
732 |
^ whitepixel |
|
733 |
! ! |
|
734 |
||
735 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
736 |
||
0 | 737 |
hasDPS |
186 | 738 |
"return true, if this workstation supports display postscript. |
739 |
Both the server must support it, and the feature must have been |
|
740 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 741 |
|
742 |
^ hasDPSExtension |
|
186 | 743 |
|
744 |
" |
|
745 |
Display hasDPS |
|
746 |
" |
|
747 |
! |
|
748 |
||
150 | 749 |
hasExtension:extensionString |
750 |
"query for an X extension. The argument, extensionString |
|
751 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 752 |
Return true, if that extension is available in the server. |
753 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 754 |
|
755 |
%{ |
|
756 |
int dummy; |
|
757 |
||
758 |
if (__isString(extensionString) && ISCONNECTED) { |
|
759 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
760 |
RETURN ( true ); |
|
761 |
} |
|
762 |
} |
|
763 |
%}. |
|
764 |
^ false |
|
186 | 765 |
|
766 |
" |
|
767 |
Display hasExtension:'XVideo' |
|
768 |
Display hasExtension:'Input' |
|
769 |
Display hasExtension:'GLX' |
|
770 |
Display hasExtension:'X3D-PEX' |
|
771 |
Display hasExtension:'XInputExtension' |
|
772 |
Display hasExtension:'SHAPE' |
|
773 |
Display hasExtension:'MIT-SHM' |
|
774 |
Display hasExtension:'SGIFullScreenStereo' |
|
775 |
" |
|
150 | 776 |
! |
777 |
||
295 | 778 |
hasFax |
779 |
"return true, if this workstation supports decompression of fax images. |
|
780 |
Both the server must support it, and the feature must have been |
|
781 |
enabled in the smalltalk system, for true to be returned." |
|
782 |
||
783 |
^ hasFaxExtension |
|
784 |
||
785 |
" |
|
786 |
Display hasFaxExtension |
|
787 |
" |
|
788 |
! |
|
789 |
||
790 |
hasImageExtension |
|
791 |
"return true, if this workstation supports the X image extension. |
|
792 |
Both the server must support it, and the feature must have been |
|
793 |
enabled in the smalltalk system, for true to be returned." |
|
794 |
||
795 |
^ hasImageExtension |
|
796 |
||
797 |
" |
|
798 |
Display hasImageExtension |
|
799 |
" |
|
800 |
! |
|
801 |
||
802 |
hasInputExtension |
|
803 |
"return true, if this workstation supports the X input extension. |
|
804 |
Both the server must support it, and the feature must have been |
|
805 |
enabled in the smalltalk system, for true to be returned." |
|
806 |
||
807 |
^ hasInputExtension |
|
808 |
||
809 |
" |
|
810 |
Display hasInputExtension |
|
811 |
" |
|
812 |
! |
|
813 |
||
814 |
hasMultibuffer |
|
815 |
"return true, if this workstation supports the multibuffer extension. |
|
816 |
Both the server must support it, and the feature must have been |
|
817 |
enabled in the smalltalk system, for true to be returned." |
|
818 |
||
819 |
^ hasMbufExtension |
|
820 |
||
821 |
" |
|
822 |
Display hasMultibuffer |
|
823 |
" |
|
824 |
! |
|
825 |
||
826 |
hasPEX |
|
827 |
"return true, if this workstation supports PEX 3D graphics. |
|
828 |
Both the server must support it, and the feature must have been |
|
829 |
enabled in the smalltalk system, for true to be returned." |
|
830 |
||
831 |
^ hasPEXExtension |
|
832 |
||
833 |
" |
|
834 |
Display hasPEX |
|
835 |
" |
|
836 |
! |
|
837 |
||
838 |
hasShape |
|
839 |
"return true, if this workstation supports non-rectangular windows. |
|
840 |
Both the server must support it, and the feature must have been |
|
841 |
enabled in the smalltalk system, for true to be returned." |
|
842 |
||
843 |
^ hasShapeExtension |
|
844 |
||
845 |
" |
|
846 |
Display hasShape |
|
847 |
" |
|
848 |
! |
|
849 |
||
850 |
hasShm |
|
851 |
"return true, if this workstation supports the shared pixmap extension. |
|
852 |
Both the server must support it, and the feature must have been |
|
853 |
enabled in the smalltalk system, for true to be returned." |
|
854 |
||
855 |
^ hasShmExtension |
|
856 |
||
857 |
" |
|
858 |
Display hasShm |
|
859 |
" |
|
860 |
! |
|
861 |
||
862 |
hasXVideo |
|
863 |
"return true, if this workstation supports the XVideo extension. |
|
864 |
Both the server must support it, and the feature must have been |
|
865 |
enabled in the smalltalk system, for true to be returned." |
|
866 |
||
867 |
^ hasXVideoExtension |
|
868 |
||
869 |
" |
|
870 |
Display hasXVideo |
|
871 |
" |
|
872 |
! |
|
873 |
||
874 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
875 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 876 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 877 |
|
878 |
|xIconSizes count ret| |
|
879 |
||
880 |
%{ |
|
881 |
Display *dpy = myDpy; |
|
555 | 882 |
int screen = __intVal(__INST(screen)); |
295 | 883 |
XIconSize *sizeList; |
884 |
int cnt; |
|
885 |
||
886 |
if (ISCONNECTED) { |
|
850 | 887 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
888 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
889 |
count = __MKSMALLINT(cnt); |
|
890 |
} |
|
295 | 891 |
} |
892 |
%}. |
|
893 |
xIconSizes isNil ifTrue:[^ nil]. |
|
894 |
||
895 |
ret := OrderedCollection new:count. |
|
896 |
1 to:count do:[ :i | |
|
850 | 897 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 898 |
|
899 |
%{ |
|
850 | 900 |
XIconSize *slp; |
901 |
||
902 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
903 |
minWidth = __MKSMALLINT(slp->min_width); |
|
904 |
minHeight = __MKSMALLINT(slp->min_height); |
|
905 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
906 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
907 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
908 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 909 |
%}. |
850 | 910 |
d := IdentityDictionary new. |
911 |
d at:#minWidth put:minWidth. |
|
912 |
d at:#maxWidth put:maxWidth. |
|
913 |
d at:#widthStep put:widthStep. |
|
914 |
d at:#minHeight put:minHeight. |
|
915 |
d at:#maxHeight put:maxHeight. |
|
916 |
d at:#heightStep put:heightStep. |
|
917 |
||
918 |
ret add:d |
|
295 | 919 |
]. |
920 |
||
921 |
xIconSizes free. |
|
922 |
^ ret |
|
923 |
||
924 |
" |
|
819 | 925 |
Display iconSizes |
295 | 926 |
" |
927 |
! |
|
928 |
||
341 | 929 |
ignoreBackingStore:aBoolean |
930 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
931 |
no backing store used - this can be used on servers where backing store is |
|
932 |
very slow or is broken (can be put into display-rc-file)" |
|
933 |
||
934 |
ignoreBackingStore := aBoolean |
|
295 | 935 |
! |
936 |
||
823 | 937 |
preferredIconSize |
938 |
"return the displays preferred size for icons. |
|
939 |
Redefined to return a special value on SGI servers." |
|
940 |
||
941 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
850 | 942 |
^ 86@68 |
823 | 943 |
]. |
944 |
^ super preferredIconSize |
|
945 |
||
946 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
947 |
! |
|
948 |
||
43 | 949 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
950 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
951 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
952 |
depth, bitsPerPixel and padding values." |
43 | 953 |
|
150 | 954 |
|nFormats "{ Class: SmallInteger }" |
955 |
formatArray| |
|
43 | 956 |
%{ |
957 |
Display *dpy = myDpy; |
|
150 | 958 |
|
959 |
if (! ISCONNECTED) { |
|
960 |
RETURN (nil); |
|
961 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
962 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 963 |
%}. |
964 |
formatArray := Array new:nFormats. |
|
150 | 965 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
966 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 967 |
|
968 |
i := index. |
|
43 | 969 |
%{ |
70 | 970 |
ScreenFormat *format; |
971 |
Display *dpy = myDpy; |
|
972 |
||
90 | 973 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
555 | 974 |
format += (__intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
975 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
976 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
977 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 978 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
979 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
980 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
981 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
982 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
983 |
formatArray at:index put:info. |
43 | 984 |
]. |
985 |
^ formatArray |
|
986 |
||
987 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
988 |
Display supportedImageFormats |
43 | 989 |
" |
990 |
! |
|
991 |
||
823 | 992 |
supportsIconViews |
993 |
"return true, if this device supports views as icons. |
|
994 |
Only Xservers (currently) support this." |
|
995 |
||
996 |
^ true |
|
997 |
||
998 |
" |
|
999 |
Display supportsIconViews |
|
1000 |
" |
|
1001 |
||
1002 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1003 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1004 |
! |
|
1005 |
||
81 | 1006 |
supportsViewGravity |
1007 |
"return true, if this device supports gravity attributes. |
|
82 | 1008 |
We do not depend on it being implemented, but some resizing operations |
81 | 1009 |
are faster, it is is." |
1010 |
||
1011 |
^ true |
|
0 | 1012 |
! ! |
1013 |
||
1014 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1015 |
||
295 | 1016 |
createBitmapFromArray:anArray width:w height:h |
1017 |
|bitmapId| |
|
1018 |
||
1019 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1020 |
bitmapId isNil ifTrue:[ |
|
1021 |
self primitiveFailed |
|
1022 |
]. |
|
1023 |
^ bitmapId |
|
1024 |
! |
|
1025 |
||
1026 |
createBitmapFromFile:aString for:aForm |
|
1027 |
|id w h| |
|
1028 |
||
1029 |
%{ |
|
1030 |
Display *dpy = myDpy; |
|
555 | 1031 |
int screen = __intVal(__INST(screen)); |
295 | 1032 |
Pixmap newBitmap; |
1033 |
char *filename; |
|
1034 |
unsigned b_width, b_height; |
|
1035 |
int b_x_hot, b_y_hot; |
|
1036 |
int status; |
|
1037 |
||
1038 |
if (ISCONNECTED) { |
|
1039 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1040 |
filename = (char *)_stringVal(aString); |
|
1041 |
||
1042 |
BEGIN_INTERRUPTSBLOCKED |
|
1043 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1044 |
filename, &b_width, &b_height, &newBitmap, |
|
1045 |
&b_x_hot, &b_y_hot); |
|
1046 |
END_INTERRUPTSBLOCKED |
|
1047 |
||
892 | 1048 |
if ((status == BitmapSuccess) && newBitmap) { |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1049 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1050 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1051 |
#endif |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1052 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1053 |
h = __MKSMALLINT(b_height); |
295 | 1054 |
id = __MKOBJ(newBitmap); |
1055 |
} |
|
1056 |
} |
|
1057 |
} |
|
1058 |
%}. |
|
1059 |
id notNil ifTrue:[ |
|
1060 |
aForm setWidth:w height:h |
|
1061 |
]. |
|
1062 |
^ id |
|
1063 |
! |
|
1064 |
||
1065 |
createBitmapWidth:w height:h |
|
1066 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1067 |
(i.e. random). Return a bitmap id or nil" |
|
1068 |
||
1069 |
%{ /* NOCONTEXT */ |
|
1070 |
||
1071 |
Display *dpy = myDpy; |
|
555 | 1072 |
int screen = __intVal(__INST(screen)); |
295 | 1073 |
Pixmap newBitmap; |
1074 |
||
1075 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1076 |
BEGIN_INTERRUPTSBLOCKED |
|
1077 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1078 |
__intVal(w), __intVal(h), 1); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1079 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1080 |
if (newBitmap) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1081 |
__cnt_bitmap++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1082 |
#endif |
295 | 1083 |
END_INTERRUPTSBLOCKED |
1084 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1085 |
} |
|
1086 |
%} |
|
1087 |
. |
|
1088 |
self primitiveFailed. |
|
1089 |
^ nil |
|
1090 |
! |
|
1091 |
||
0 | 1092 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
1093 |
"create a new faxImage in the workstation |
|
1094 |
type: 0 -> uncompressed |
|
70 | 1095 |
1 -> group3 1D (k is void) |
1096 |
2 -> group3 2D |
|
1097 |
3 -> group4 2D (k is void)" |
|
0 | 1098 |
|
1099 |
|nBytes| |
|
1100 |
||
1101 |
hasFaxExtension ifFalse:[^ nil]. |
|
1102 |
nBytes := data size. |
|
1103 |
%{ |
|
1104 |
#ifdef FAX |
|
1105 |
Display *dpy = myDpy; |
|
555 | 1106 |
int screen = __intVal(__INST(screen)); |
0 | 1107 |
FAXImage newImage; |
1108 |
int _type, _msb, _k = 0; |
|
1109 |
unsigned char *bits; |
|
1110 |
||
97 | 1111 |
if (__bothSmallInteger(w, h) |
1112 |
&& __bothSmallInteger(type, k) |
|
1113 |
&& __isSmallInteger(nBytes) |
|
44 | 1114 |
&& __isByteArray(data)) { |
70 | 1115 |
if (msbFirst == true) |
1116 |
_msb = 1; |
|
1117 |
else |
|
1118 |
_msb = 0; |
|
555 | 1119 |
_type = __intVal(type); |
70 | 1120 |
if ((_type < 0) || (_type > 3)) { |
1121 |
RETURN ( nil ); |
|
1122 |
} |
|
1123 |
if (_type == 2) { |
|
97 | 1124 |
if (! __isSmallInteger(k)) { |
70 | 1125 |
RETURN ( nil ); |
1126 |
} |
|
555 | 1127 |
_k = __intVal(k); |
70 | 1128 |
} |
555 | 1129 |
bits = __ByteArrayInstPtr(data)->ba_element; |
70 | 1130 |
BEGIN_INTERRUPTSBLOCKED |
555 | 1131 |
newImage = XFAXImageCreateImage(dpy, __intVal(w), __intVal(h), |
70 | 1132 |
_type, _k, _msb, |
555 | 1133 |
__intVal(nBytes), bits); |
70 | 1134 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1135 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1136 |
} |
1137 |
#else |
|
1138 |
RETURN ( nil ); |
|
1139 |
#endif |
|
1140 |
%} |
|
1141 |
. |
|
43 | 1142 |
self primitiveFailed. |
1143 |
^ nil |
|
0 | 1144 |
! |
1145 |
||
1146 |
createPixmapWidth:w height:h depth:d |
|
1147 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1148 |
(i.e. random). Return a bitmap id or nil" |
|
1149 |
||
1150 |
%{ /* NOCONTEXT */ |
|
1151 |
||
1152 |
Display *dpy = myDpy; |
|
555 | 1153 |
int screen = __intVal(__INST(screen)); |
0 | 1154 |
Pixmap newBitmap; |
1155 |
||
150 | 1156 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1157 |
BEGIN_INTERRUPTSBLOCKED |
1158 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1159 |
__intVal(w), __intVal(h), __intVal(d)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1160 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1161 |
if (newBitmap) |
928 | 1162 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1163 |
#endif |
70 | 1164 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1165 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1166 |
} |
1167 |
%} |
|
1168 |
. |
|
43 | 1169 |
self primitiveFailed. |
1170 |
^ nil |
|
0 | 1171 |
! |
1172 |
||
1173 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1174 |
"will vanish - for compatibility with previous versions" |
1175 |
||
1176 |
^ self |
|
850 | 1177 |
createWindowFor:aView |
1178 |
origin:(xpos @ ypos) |
|
1179 |
extent:(wwidth @ wheight) |
|
1180 |
minExtent:(aView minExtent) |
|
1181 |
maxExtent:(aView maxExtent) |
|
1182 |
borderWidth:(aView borderWidth) |
|
1183 |
subViewOf:(aView superView) |
|
1184 |
onTop:(aView isPopUpView) |
|
1185 |
inputOnly:(aView isInputOnly) |
|
1186 |
label:(aView label) |
|
1187 |
cursor:(aView cursor) |
|
1188 |
icon:(aView icon) |
|
1189 |
iconView:(aView iconView) |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1190 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1191 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1192 |
! |
1193 |
||
1194 |
createWindowFor:aView |
|
70 | 1195 |
origin:origin |
1196 |
extent:extent |
|
1197 |
minExtent:minExt |
|
1198 |
maxExtent:maxExt |
|
1199 |
borderWidth:bWidth |
|
1200 |
subViewOf:wsuperView |
|
157 | 1201 |
onTop:wisPopUpView |
70 | 1202 |
inputOnly:winputOnly |
1203 |
label:wlabel |
|
1204 |
cursor:wcursor |
|
1205 |
icon:wicon |
|
1206 |
iconView:wiconView |
|
46 | 1207 |
|
1208 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1209 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1210 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1211 |
vBgForm deepForm preferredVisual preferredDepth| |
1212 |
||
1213 |
displayId isNil ifTrue:[ |
|
1214 |
self primitiveFailed. |
|
1215 |
^ nil |
|
1216 |
]. |
|
0 | 1217 |
|
46 | 1218 |
origin notNil ifTrue:[ |
70 | 1219 |
xpos := origin x. |
1220 |
ypos := origin y. |
|
46 | 1221 |
] ifFalse:[ |
70 | 1222 |
xpos := ypos := 0. |
0 | 1223 |
]. |
46 | 1224 |
extent notNil ifTrue:[ |
70 | 1225 |
wwidth := extent x. |
1226 |
wheight := extent y. |
|
46 | 1227 |
] ifFalse:[ |
70 | 1228 |
wwidth := wheight := 100. |
46 | 1229 |
]. |
1230 |
minExt notNil ifTrue:[ |
|
70 | 1231 |
minWidth := minExt x. |
1232 |
minHeight := minExt y |
|
0 | 1233 |
]. |
46 | 1234 |
maxExt notNil ifTrue:[ |
70 | 1235 |
maxWidth := maxExt x. |
1236 |
maxHeight := maxExt y |
|
46 | 1237 |
]. |
1238 |
||
0 | 1239 |
wsuperView notNil ifTrue:[ |
70 | 1240 |
wsuperViewId := wsuperView id |
0 | 1241 |
]. |
1242 |
wcursor isNil ifTrue:[ |
|
145 | 1243 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1244 |
] ifFalse:[ |
70 | 1245 |
wcursorId := wcursor id |
0 | 1246 |
]. |
1247 |
||
1248 |
wicon notNil ifTrue:[ |
|
70 | 1249 |
wiconId := wicon id |
0 | 1250 |
]. |
1251 |
wiconView notNil ifTrue:[ |
|
70 | 1252 |
wiconViewId := wiconView id |
0 | 1253 |
]. |
1254 |
weventMask := aView eventMask. |
|
1255 |
||
150 | 1256 |
preferredVisual := aView preferredVisual. |
1257 |
preferredDepth := aView preferredDepth. |
|
23 | 1258 |
|
72 | 1259 |
%{ /* STACK:16000 */ |
0 | 1260 |
Display *dpy = myDpy; |
555 | 1261 |
int screen = __intVal(__INST(screen)); |
0 | 1262 |
Visual visual; |
1263 |
XGCValues xgcv; |
|
1264 |
XSetWindowAttributes xswa; |
|
1265 |
XSizeHints sizehints; |
|
1266 |
XWMHints wmhints; |
|
46 | 1267 |
int bw, bd, bg; |
0 | 1268 |
Window newWindow, parentWindow; |
1269 |
char *windowName; |
|
1270 |
XFontStruct *f; |
|
1271 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1272 |
int flags = 0, depth, ioClass; |
|
1273 |
Window iconWindow; |
|
1274 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1275 |
Atom WmQuitAppAtom; |
|
1276 |
Atom atoms[3]; |
|
1277 |
int atomCount = 0, isTopWindow = 0; |
|
1278 |
||
1279 |
sizehints.flags = 0; |
|
1280 |
sizehints.width = 100; |
|
1281 |
sizehints.height = 100; |
|
1282 |
sizehints.x = 0; |
|
1283 |
sizehints.y = 0; |
|
1284 |
||
97 | 1285 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1286 |
sizehints.flags |= PSize; |
555 | 1287 |
sizehints.width = __intVal(wwidth); |
1288 |
sizehints.height = __intVal(wheight); |
|
0 | 1289 |
} |
97 | 1290 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1291 |
sizehints.flags |= PPosition; |
555 | 1292 |
sizehints.x = __intVal(xpos); |
1293 |
sizehints.y = __intVal(ypos); |
|
0 | 1294 |
} |
97 | 1295 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1296 |
sizehints.flags |= PMinSize; |
555 | 1297 |
sizehints.min_width = __intVal(minWidth); |
1298 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1299 |
} |
97 | 1300 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1301 |
sizehints.flags |= PMaxSize; |
555 | 1302 |
sizehints.max_width = __intVal(maxWidth); |
1303 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1304 |
} |
1305 |
||
37 | 1306 |
bg = WhitePixel(dpy, screen); |
0 | 1307 |
|
97 | 1308 |
if (__isSmallInteger(bWidth)) { |
555 | 1309 |
bw = __intVal(bWidth); |
46 | 1310 |
} else { |
70 | 1311 |
bw = 0; |
0 | 1312 |
} |
1313 |
||
72 | 1314 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1315 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1316 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1317 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1318 |
} else { |
70 | 1319 |
parentWindow = RootWindow(dpy, screen); |
1320 |
isTopWindow = 1; |
|
0 | 1321 |
} |
1322 |
||
157 | 1323 |
if (wisPopUpView == true) |
70 | 1324 |
xswa.override_redirect = 1; |
0 | 1325 |
else |
70 | 1326 |
xswa.override_redirect = 0; |
0 | 1327 |
|
1328 |
if (winputOnly == true) |
|
70 | 1329 |
ioClass = InputOnly; |
0 | 1330 |
else |
70 | 1331 |
ioClass = InputOutput; |
0 | 1332 |
|
97 | 1333 |
if (__isSmallInteger(weventMask)) { |
555 | 1334 |
xswa.event_mask = __intVal(weventMask); |
0 | 1335 |
} else { |
70 | 1336 |
xswa.event_mask = 0; |
0 | 1337 |
} |
1338 |
||
1339 |
if (ioClass == InputOnly) { |
|
70 | 1340 |
bw = 0; |
1341 |
depth = 0; |
|
1342 |
flags |= CWEventMask; |
|
0 | 1343 |
} else { |
70 | 1344 |
depth = DefaultDepth(dpy,screen); |
1345 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1346 |
||
1347 |
if (backPixmap != (Pixmap)0) { |
|
1348 |
xswa.background_pixmap = backPixmap; |
|
1349 |
flags |= CWBackPixmap; |
|
1350 |
} else { |
|
1351 |
xswa.background_pixel = bg; |
|
1352 |
flags |= CWBackPixel; |
|
1353 |
} |
|
1354 |
xswa.border_pixel = bd; |
|
0 | 1355 |
} |
23 | 1356 |
|
0 | 1357 |
visual.visualid = CopyFromParent; |
150 | 1358 |
if (__isSmallInteger(preferredDepth)) { |
555 | 1359 |
depth = __intVal(preferredDepth); |
23 | 1360 |
} |
54 | 1361 |
|
1362 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1363 |
if (preferredVisual != nil) { |
70 | 1364 |
XVisualInfo vi; |
1365 |
int cls; |
|
1366 |
||
150 | 1367 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1368 |
cls = StaticGray; |
150 | 1369 |
else if (preferredVisual == @symbol(GrayScale)) |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
1370 |
cls = GrayScale; |
150 | 1371 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1372 |
cls = StaticColor; |
150 | 1373 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1374 |
cls = PseudoColor; |
150 | 1375 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1376 |
cls = TrueColor; |
150 | 1377 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1378 |
cls = DirectColor; |
1379 |
else |
|
1380 |
cls = PseudoColor; |
|
200 | 1381 |
|
70 | 1382 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1383 |
visual.visualid = vi.visualid; |
|
163 | 1384 |
/* |
1385 |
printf("visualId=%x\n", vi.visualid); |
|
1386 |
*/ |
|
70 | 1387 |
} |
23 | 1388 |
} |
0 | 1389 |
|
1390 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1391 |
sizehints.x, sizehints.y, |
1392 |
sizehints.width, sizehints.height, |
|
1393 |
bw, depth, ioClass, &visual, |
|
1394 |
flags, &xswa); |
|
54 | 1395 |
END_INTERRUPTSBLOCKED |
0 | 1396 |
|
1397 |
if (! newWindow) { |
|
70 | 1398 |
RETURN ( nil ); |
0 | 1399 |
} |
1400 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1401 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1402 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1403 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1404 |
|
54 | 1405 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1406 |
/* |
1407 |
* define its cursor |
|
1408 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1409 |
if (__isExternalAddress(wcursorId)) { |
70 | 1410 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1411 |
} |
1412 |
||
1413 |
/* |
|
1414 |
* define its icon and name |
|
1415 |
* (only makes sense for topWindows) |
|
1416 |
*/ |
|
1417 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1418 |
if (__isExternalAddress(wiconId)) |
70 | 1419 |
iconBitmap = _PixmapVal(wiconId); |
1420 |
else |
|
1421 |
iconBitmap = (Pixmap)0; |
|
1422 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1423 |
if (__isExternalAddress(wiconViewId)) |
70 | 1424 |
iconWindow = _WindowVal(wiconViewId); |
1425 |
else |
|
1426 |
iconWindow = (Window)0; |
|
1427 |
||
1428 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1429 |
windowName = (char *)_stringVal(wlabel); |
|
1430 |
else |
|
1431 |
windowName = ""; |
|
1432 |
||
1433 |
if (iconBitmap || windowName) { |
|
1434 |
XSetStandardProperties(dpy, newWindow, |
|
1435 |
windowName, windowName, |
|
1436 |
iconBitmap, |
|
1437 |
0, 0, &sizehints); |
|
1438 |
||
1439 |
} |
|
1440 |
||
1441 |
wmhints.flags = 0; |
|
1442 |
if (iconBitmap) { |
|
1443 |
wmhints.flags |= IconPixmapHint; |
|
1444 |
wmhints.icon_pixmap = iconBitmap; |
|
1445 |
} |
|
1446 |
if (iconWindow) { |
|
1447 |
wmhints.flags |= IconWindowHint; |
|
1448 |
wmhints.icon_window = iconWindow; |
|
1449 |
} |
|
0 | 1450 |
/* |
70 | 1451 |
wmhints.flags |= InputHint; |
1452 |
wmhints.input = True; |
|
0 | 1453 |
*/ |
70 | 1454 |
XSetWMHints(dpy, newWindow, &wmhints); |
1455 |
||
1456 |
/* |
|
1457 |
* tell window manager to not kill us but send an event instead |
|
1458 |
*/ |
|
1459 |
/* |
|
1460 |
* get atoms first (if not already known) |
|
1461 |
*/ |
|
555 | 1462 |
if (__INST(protocolsAtom) == nil) { |
70 | 1463 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
555 | 1464 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1465 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1466 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
555 | 1467 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1468 |
#endif |
1469 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1470 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
555 | 1471 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1472 |
#endif |
70 | 1473 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
555 | 1474 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1475 |
} else { |
0 | 1476 |
#ifdef USE_QUIT_APP_ATOM |
555 | 1477 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1478 |
#else |
70 | 1479 |
WmQuitAppAtom = 0; |
0 | 1480 |
#endif |
555 | 1481 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1482 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1483 |
#ifdef USE_SAVEYOURSELF_ATOM |
555 | 1484 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1485 |
#else |
70 | 1486 |
WmSaveYourselfAtom = 0; |
0 | 1487 |
#endif |
70 | 1488 |
} |
1489 |
||
1490 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1491 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1492 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1493 |
#endif |
1494 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1495 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1496 |
#endif |
70 | 1497 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1498 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1499 |
} |
1500 |
||
54 | 1501 |
END_INTERRUPTSBLOCKED |
1502 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1503 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1504 |
%}. |
0 | 1505 |
self addKnownView:aView withId:windowId. |
1506 |
^ windowId |
|
1507 |
! |
|
1508 |
||
295 | 1509 |
destroyFaxImage:aFaxImageId |
1510 |
||
1511 |
%{ /* NOCONTEXT */ |
|
1512 |
||
1513 |
#ifdef FAX |
|
1514 |
if (__isExternalAddress(aFaxImageId)) { |
|
70 | 1515 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1516 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
70 | 1517 |
END_INTERRUPTSBLOCKED |
295 | 1518 |
RETURN ( self ); |
1519 |
} |
|
1520 |
#endif |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1521 |
%}. |
295 | 1522 |
self primitiveFailed |
0 | 1523 |
! |
1524 |
||
1525 |
destroyGC:aGCId |
|
1526 |
||
1527 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1528 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1529 |
GC gc = _GCVal(aGCId); |
1530 |
||
1531 |
if (gc) { |
|
1532 |
BEGIN_INTERRUPTSBLOCKED |
|
1533 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1534 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1535 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1536 |
#endif |
366 | 1537 |
END_INTERRUPTSBLOCKED |
1538 |
} |
|
70 | 1539 |
RETURN ( self ); |
0 | 1540 |
} |
118 | 1541 |
%}. |
0 | 1542 |
self primitiveFailed |
1543 |
! |
|
1544 |
||
295 | 1545 |
destroyPixmap:aDrawableId |
0 | 1546 |
|
1547 |
%{ /* NOCONTEXT */ |
|
1548 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1549 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1550 |
Pixmap pix = _PixmapVal(aDrawableId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1551 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1552 |
if (pix) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1553 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1554 |
XFreePixmap(myDpy, pix); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1555 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1556 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1557 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1558 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1559 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1560 |
RETURN ( self ); |
0 | 1561 |
} |
118 | 1562 |
%}. |
295 | 1563 |
self primitiveFailed |
1564 |
! |
|
1565 |
||
1566 |
destroyView:aView withId:aWindowId |
|
1567 |
%{ |
|
1568 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1569 |
Window win = _WindowVal(aWindowId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1570 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1571 |
if (win) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1572 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1573 |
XDestroyWindow(myDpy, win); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1574 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1575 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1576 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1577 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1578 |
} |
295 | 1579 |
} |
1580 |
%}. |
|
1581 |
self removeKnownView:aView |
|
0 | 1582 |
! |
1583 |
||
1584 |
dpsContextFor:aDrawableId and:aGCId |
|
1585 |
||
1586 |
%{ /* NOCONTEXT */ |
|
1587 |
#ifdef XXDPS |
|
555 | 1588 |
int screen = __intVal(__INST(screen)); |
0 | 1589 |
DPSContext dps; |
1590 |
int height; |
|
1591 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1592 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1593 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1594 |
&& ISCONNECTED) { |
70 | 1595 |
BEGIN_INTERRUPTSBLOCKED |
1596 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1597 |
_GCVal(aGCId), |
|
1598 |
0, height, 0, colormap, NULL, 0, |
|
1599 |
XDPSDefaultTextBackstop, |
|
1600 |
XDPSDefaultErrorProc, |
|
1601 |
NULL); |
|
1602 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1603 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1604 |
} |
1605 |
#endif |
|
1606 |
%} |
|
1607 |
. |
|
43 | 1608 |
self primitiveFailed. |
1609 |
^ nil |
|
295 | 1610 |
! |
1611 |
||
1612 |
gcFor:aDrawableId |
|
132 | 1613 |
|
1614 |
%{ /* NOCONTEXT */ |
|
555 | 1615 |
int screen = __intVal(__INST(screen)); |
295 | 1616 |
GC gc; |
1617 |
||
1618 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1619 |
BEGIN_INTERRUPTSBLOCKED |
|
1620 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1621 |
0L, (XGCValues *)0); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1622 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1623 |
if (gc) |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1624 |
__cnt_gc++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1625 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1626 |
|
295 | 1627 |
END_INTERRUPTSBLOCKED |
1628 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1629 |
} |
1630 |
%}. |
|
1631 |
self primitiveFailed. |
|
1632 |
^ nil |
|
295 | 1633 |
! |
1634 |
||
1635 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1636 |
|
1637 |
%{ /* UNLIMITEDSTACK */ |
|
1638 |
||
295 | 1639 |
Display *dpy = myDpy; |
555 | 1640 |
int screen = __intVal(__INST(screen)); |
295 | 1641 |
Pixmap newBitmap; |
1642 |
unsigned int b_width, b_height; |
|
1643 |
REGISTER unsigned char *cp; |
|
1644 |
REGISTER unsigned char *pBits; |
|
1645 |
unsigned char *b_bits, *allocatedBits; |
|
1646 |
int index, row; |
|
1647 |
REGISTER int col; |
|
1648 |
unsigned bits; |
|
1649 |
static char reverseBitTable[256]; |
|
1650 |
static firstCall = 1; |
|
1651 |
int nBytes; |
|
1652 |
unsigned char fastBits[10000]; |
|
1653 |
OBJ num, *op; |
|
1654 |
int bytesPerRow; |
|
1655 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1656 |
if (! ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1657 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1658 |
} |
295 | 1659 |
if (firstCall) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1660 |
for (index=0; index < 256; index++) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1661 |
reverseBitTable[index] = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1662 |
if (index & 128) reverseBitTable[index] |= 1; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1663 |
if (index & 64) reverseBitTable[index] |= 2; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1664 |
if (index & 32) reverseBitTable[index] |= 4; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1665 |
if (index & 16) reverseBitTable[index] |= 8; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1666 |
if (index & 8) reverseBitTable[index] |= 16; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1667 |
if (index & 4) reverseBitTable[index] |= 32; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1668 |
if (index & 2) reverseBitTable[index] |= 64; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1669 |
if (index & 1) reverseBitTable[index] |= 128; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1670 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1671 |
firstCall = 0; |
295 | 1672 |
} |
1673 |
||
1674 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1675 |
newBitmap = (Pixmap)0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1676 |
b_width = __intVal(w); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1677 |
b_height = __intVal(h); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1678 |
bytesPerRow = (b_width + 7) / 8; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1679 |
nBytes = b_height * bytesPerRow; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1680 |
if (nBytes < sizeof(fastBits)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1681 |
cp = b_bits = fastBits; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1682 |
allocatedBits = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1683 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1684 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1685 |
if (! cp) goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1686 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1687 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1688 |
if (__qClass(anArray) == @global(Array)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1689 |
index = 1; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1690 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1691 |
for (row = b_height; row; row--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1692 |
for (col = bytesPerRow; col; col--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1693 |
num = *op++; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1694 |
if (! __isSmallInteger(num)) goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1695 |
bits = __intVal(num); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1696 |
*cp++ = reverseBitTable[bits]; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1697 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1698 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1699 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1700 |
if (__qClass(anArray) == @global(ByteArray)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1701 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1702 |
for (col = b_height*bytesPerRow; col; col--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1703 |
*cp++ = reverseBitTable[*pBits++]; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1704 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1705 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1706 |
goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1707 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1708 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1709 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1710 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1711 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1712 |
(char *)b_bits, |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1713 |
b_width, b_height); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1714 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1715 |
if (newBitmap) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1716 |
__cnt_bitmap++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1717 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1718 |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1719 |
END_INTERRUPTSBLOCKED |
295 | 1720 |
fail: ; |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1721 |
if (allocatedBits) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1722 |
free(allocatedBits); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1723 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
0 | 1724 |
} |
1725 |
%} |
|
295 | 1726 |
! |
1727 |
||
1728 |
realRootWindowFor:aView |
|
1729 |
"the name of this method is historic; |
|
1730 |
- it will vanish" |
|
1731 |
||
1732 |
|id| |
|
1733 |
||
1734 |
id := self realRootWindowId. |
|
1735 |
self addKnownView:aView withId:id. |
|
1736 |
^ id |
|
1737 |
! |
|
1738 |
||
1739 |
realRootWindowId |
|
1740 |
"return the id of the real root window. |
|
1741 |
This may not be the window you see as background, |
|
1742 |
since some window managers install a virtual root window on top |
|
1743 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1744 |
care of any virtual root." |
|
0 | 1745 |
|
1746 |
%{ /* NOCONTEXT */ |
|
1747 |
||
555 | 1748 |
int screen = __intVal(__INST(screen)); |
295 | 1749 |
Window root; |
1750 |
OBJ id; |
|
1751 |
||
555 | 1752 |
if (__INST(rootId) != nil) { |
1753 |
RETURN (__INST(rootId)); |
|
295 | 1754 |
} |
0 | 1755 |
|
150 | 1756 |
if (ISCONNECTED) { |
295 | 1757 |
root = RootWindow(myDpy, screen); |
1758 |
if (! root) { |
|
1759 |
id = nil; |
|
1760 |
} else { |
|
555 | 1761 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1762 |
} |
295 | 1763 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1764 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1765 |
%}. |
295 | 1766 |
self primitiveFailed |
1767 |
! |
|
1768 |
||
1769 |
rootWindowFor:aView |
|
1770 |
|id| |
|
1771 |
||
1772 |
id := self rootWindowId. |
|
1773 |
self addKnownView:aView withId:id. |
|
0 | 1774 |
^ id |
1775 |
! |
|
1776 |
||
295 | 1777 |
rootWindowId |
1778 |
"return the id of the root window. |
|
1779 |
This is the window you see as background, |
|
1780 |
however, it may or may not be the real physical root window, |
|
1781 |
since some window managers install a virtual root window on top |
|
1782 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1783 |
|
0 | 1784 |
%{ /* NOCONTEXT */ |
555 | 1785 |
int screen = __intVal(__INST(screen)); |
295 | 1786 |
Window rootWin, vRootWin; |
1787 |
OBJ id; |
|
1788 |
||
555 | 1789 |
if (__INST(virtualRootId) != nil) { |
1790 |
RETURN (__INST(virtualRootId)); |
|
295 | 1791 |
} |
0 | 1792 |
|
169 | 1793 |
if (ISCONNECTED) { |
295 | 1794 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1795 |
#ifndef IRIS |
|
180 | 1796 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1797 |
/* |
1798 |
* on IRIS, this creates a badwindow error - why ? |
|
1799 |
* children contains a funny window (000034) |
|
1800 |
*/ |
|
1801 |
||
1802 |
/* |
|
1803 |
* care for virtual root windows (tvtwm & friends) |
|
1804 |
*/ |
|
1805 |
{ |
|
1806 |
Atom vRootAtom = None; |
|
1807 |
int i; |
|
1808 |
Window rootReturn, parentReturn; |
|
1809 |
Window* children; |
|
1810 |
unsigned int numChildren; |
|
1811 |
||
1812 |
if (XQueryTree(myDpy, rootWin, |
|
1813 |
&rootReturn, &parentReturn, |
|
1814 |
&children, &numChildren)) { |
|
1815 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1816 |
if (vRootAtom != None) { |
|
1817 |
for (i=0; i < numChildren; i++) { |
|
1818 |
Atom actual_type; |
|
1819 |
int actual_format; |
|
1820 |
unsigned long nitems, bytesafter; |
|
1821 |
Window* newRoot = (Window*) 0; |
|
1822 |
||
1823 |
if (children[i]) { |
|
1824 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1825 |
0L, 1L, False, XA_WINDOW, |
|
1826 |
&actual_type, &actual_format, |
|
1827 |
&nitems, &bytesafter, |
|
1828 |
(unsigned char**) &newRoot |
|
1829 |
) == Success && newRoot) { |
|
1830 |
vRootWin = *newRoot; |
|
1831 |
break; |
|
1832 |
} |
|
1833 |
} |
|
1834 |
} |
|
1835 |
if (children) XFree( children ); |
|
1836 |
} |
|
1837 |
} |
|
1838 |
} |
|
180 | 1839 |
END_INTERRUPTSBLOCKED |
295 | 1840 |
#endif |
1841 |
} |
|
1842 |
||
1843 |
/* cannot happen */ |
|
1844 |
if (! vRootWin) { |
|
1845 |
vRootWin = rootWin; |
|
1846 |
if (! rootWin) { |
|
1847 |
RETURN ( nil ); |
|
1848 |
} |
|
1849 |
} |
|
555 | 1850 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1851 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1852 |
RETURN ( id ); |
63 | 1853 |
%} |
0 | 1854 |
! ! |
1855 |
||
1856 |
!XWorkstation methodsFor:'color stuff'! |
|
1857 |
||
295 | 1858 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1859 |
"allocate a color cell - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1860 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1861 |
|
1862 |
%{ /* NOCONTEXT */ |
|
1863 |
||
1864 |
Display *dpy = myDpy; |
|
555 | 1865 |
int screen = __intVal(__INST(screen)); |
295 | 1866 |
XColor color; |
1867 |
unsigned long dummy; |
|
1868 |
Status ok; |
|
1869 |
||
1870 |
BEGIN_INTERRUPTSBLOCKED |
|
1871 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1872 |
&dummy, 0, &color.pixel, 1); |
|
1873 |
END_INTERRUPTSBLOCKED |
|
1874 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1875 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1876 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1877 |
#endif |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1878 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1879 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1880 |
%}. |
43 | 1881 |
^ nil |
0 | 1882 |
! |
1883 |
||
1884 |
colorNamed:aString |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1885 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1886 |
Dont use this method, colornames are mostly X specific" |
1887 |
||
1888 |
%{ /* NOCONTEXT */ |
|
1889 |
||
1890 |
char *colorname; |
|
1891 |
Display *dpy = myDpy; |
|
1892 |
XColor scolor, ecolor; |
|
555 | 1893 |
int screen = __intVal(__INST(screen)); |
850 | 1894 |
int id; |
54 | 1895 |
Status ok; |
0 | 1896 |
|
150 | 1897 |
if (ISCONNECTED) { |
850 | 1898 |
if (__isString(aString) || __isSymbol(aString)) { |
1899 |
colorname = (char *)_stringVal(aString); |
|
1900 |
||
1901 |
BEGIN_INTERRUPTSBLOCKED |
|
1902 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1903 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1904 |
#ifdef QUICK_TRUE_COLORS |
850 | 1905 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1906 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1907 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1908 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1909 |
RETURN ( __MKSMALLINT(id) ); |
|
1910 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1911 |
#endif |
850 | 1912 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1913 |
} |
|
1914 |
END_INTERRUPTSBLOCKED |
|
1915 |
if (! ok) { |
|
1916 |
RETURN ( nil ); |
|
1917 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1918 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1919 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1920 |
#endif |
850 | 1921 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1922 |
} |
|
0 | 1923 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1924 |
%}. |
43 | 1925 |
self primitiveFailed. |
1926 |
^ nil |
|
0 | 1927 |
! |
1928 |
||
295 | 1929 |
colorRed:redVal green:greenVal blue:blueVal |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1930 |
"allocate a color with rgb values (0..100) - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1931 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1932 |
|
1933 |
|r g b| |
|
1934 |
||
1935 |
r := self percentToXColorValue:redVal. |
|
1936 |
g := self percentToXColorValue:greenVal. |
|
1937 |
b := self percentToXColorValue:blueVal. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1938 |
^ self colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1939 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1940 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1941 |
colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1942 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1943 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1944 |
Display *dpy; |
295 | 1945 |
XColor ecolor; |
555 | 1946 |
int screen = __intVal(__INST(screen)); |
295 | 1947 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1948 |
int id; |
295 | 1949 |
|
1950 |
if (__bothSmallInteger(r, g) |
|
1951 |
&& __isSmallInteger(b) |
|
1952 |
&& ISCONNECTED) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1953 |
ecolor.red = __intVal(r); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1954 |
ecolor.green= __intVal(g); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1955 |
ecolor.blue = __intVal(b); |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1956 |
#ifdef QUICK_TRUE_COLORS |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1957 |
if (__INST(visualType) == @symbol(TrueColor)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1958 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1959 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1960 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1961 |
RETURN ( __MKSMALLINT(id) ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1962 |
} |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1963 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1964 |
dpy = myDpy; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1965 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1966 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1967 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1968 |
if (! ok) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1969 |
RETURN ( nil ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1970 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1971 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1972 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1973 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1974 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1975 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1976 |
%}. |
295 | 1977 |
self primitiveFailed. |
1978 |
^ nil |
|
1979 |
! |
|
1980 |
||
1981 |
freeColor:colorIndex |
|
1982 |
"free a display color when its no longer needed" |
|
0 | 1983 |
|
1984 |
%{ /* NOCONTEXT */ |
|
1985 |
||
1986 |
Display *dpy = myDpy; |
|
295 | 1987 |
unsigned long color; |
555 | 1988 |
int screen = __intVal(__INST(screen)); |
295 | 1989 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1990 |
#ifdef QUICK_TRUE_COLORS |
555 | 1991 |
if (__INST(visualType) == @symbol(TrueColor)) { |
850 | 1992 |
/* no need to do anything on TrueColor displays ... */ |
1993 |
RETURN (self); |
|
295 | 1994 |
} |
1995 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1996 |
|
295 | 1997 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
850 | 1998 |
color = (long) __intVal(colorIndex); |
1999 |
BEGIN_INTERRUPTSBLOCKED |
|
2000 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2001 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2002 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2003 |
#endif |
850 | 2004 |
END_INTERRUPTSBLOCKED |
2005 |
RETURN ( self ); |
|
0 | 2006 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2007 |
%}. |
295 | 2008 |
self primitiveFailed |
2009 |
! |
|
2010 |
||
2011 |
getRGBFrom:index into:aBlock |
|
2012 |
"get rgb components (0..100) of color in map at:index, |
|
2013 |
and evaluate the 3-arg block, aBlock with them" |
|
2014 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2015 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2016 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2017 |
self getScaledRGBFrom:index into:[:r :g :b | |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2018 |
val := aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2019 |
value:(r * 100.0 / 16rFFFF) |
850 | 2020 |
value:(g * 100.0 / 16rFFFF) |
2021 |
value:(b * 100.0 / 16rFFFF) |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2022 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2023 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2024 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2025 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2026 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2027 |
"get rgb components (0..100) of color named colorName, |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2028 |
and evaluate the 3-arg block, aBlock with them" |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2029 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2030 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2031 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
850 | 2032 |
val := aBlock |
2033 |
value:(r * 100.0 / 16rFFFF) |
|
2034 |
value:(g * 100.0 / 16rFFFF) |
|
2035 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2036 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2037 |
^ val |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2038 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2039 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2040 |
getScaledRGBFrom:index into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2041 |
"get rgb components (0 .. 16rFFFF) of color in map at:index, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2042 |
and evaluate the 3-arg block, aBlock with them" |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2043 |
|
295 | 2044 |
|r g b| |
2045 |
%{ |
|
2046 |
Display *dpy = myDpy; |
|
555 | 2047 |
int screen = __intVal(__INST(screen)); |
295 | 2048 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2049 |
int sr, sg, sb; |
295 | 2050 |
int bits, scale, shift; |
2051 |
||
2052 |
if (__isSmallInteger(index)) { |
|
555 | 2053 |
color.pixel = __intVal(index); |
295 | 2054 |
BEGIN_INTERRUPTSBLOCKED |
2055 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2056 |
END_INTERRUPTSBLOCKED |
|
2057 |
||
2058 |
/* |
|
2059 |
* have to compensate for an error in X ?, which does not scale |
|
2060 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2061 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2062 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2063 |
*/ |
|
555 | 2064 |
bits = __intVal(__INST(bitsPerRGB)); |
295 | 2065 |
scale = (1<<bits) - 1; |
2066 |
shift = 16 - bits; |
|
2067 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2068 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2069 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2070 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2071 |
r = __MKSMALLINT(sr); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2072 |
g = __MKSMALLINT(sg); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2073 |
b = __MKSMALLINT(sb); |
295 | 2074 |
} |
2075 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2076 |
^ aBlock value:r value:g value:b |
295 | 2077 |
! |
2078 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2079 |
getScaledRGBFromName:colorName into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2080 |
"get rgb components (0..16rFFFF) of color named colorName, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2081 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2082 |
|
2083 |
|r g b| |
|
2084 |
||
2085 |
displayId isNil ifTrue:[ |
|
2086 |
self pimitiveFailed. |
|
2087 |
^ nil |
|
2088 |
]. |
|
2089 |
%{ |
|
2090 |
Display *dpy = myDpy; |
|
555 | 2091 |
int screen = __intVal(__INST(screen)); |
295 | 2092 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2093 |
int sr, sg, sb; |
295 | 2094 |
double floor(); |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2095 |
int bits, scale, shift; |
295 | 2096 |
|
2097 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
2098 |
BEGIN_INTERRUPTSBLOCKED |
|
2099 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2100 |
(char *)_stringVal(colorName), &color)) { |
|
2101 |
/* |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2102 |
* have to compensate for an error in X ?, which does not scale |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2103 |
* colors correctly if lesser than 16bits are valid in a color, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2104 |
* (for example, color white on a 4bitsPerRGB server will return |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2105 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
295 | 2106 |
*/ |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2107 |
bits = __intVal(__INST(bitsPerRGB)); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2108 |
scale = (1<<bits) - 1; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2109 |
shift = 16 - bits; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2110 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2111 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2112 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2113 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2114 |
r = __MKSMALLINT(sr); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2115 |
g = __MKSMALLINT(sg); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2116 |
b = __MKSMALLINT(sb); |
295 | 2117 |
} |
2118 |
END_INTERRUPTSBLOCKED |
|
2119 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2120 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2121 |
^ aBlock value:r value:g value:b |
295 | 2122 |
! |
2123 |
||
2124 |
listOfAvailableColors |
|
2125 |
"return a list of all available colornames. |
|
2126 |
This should not be used, since colornames are very |
|
2127 |
display-specific (here X-specific)." |
|
2128 |
||
2129 |
|aStream list line index colorName| |
|
2130 |
||
2131 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2132 |
aStream isNil ifTrue:[^ nil]. |
|
2133 |
list := OrderedCollection new. |
|
2134 |
[aStream atEnd] whileFalse:[ |
|
2135 |
line := aStream nextLine. |
|
2136 |
line notNil ifTrue:[ |
|
2137 |
"skip the r/g/b numbers" |
|
2138 |
index := 1. |
|
2139 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2140 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2141 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2142 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2143 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2144 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2145 |
colorName := line copyFrom:index. |
|
2146 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2147 |
list add:colorName |
|
2148 |
] |
|
2149 |
] |
|
2150 |
]. |
|
2151 |
aStream close. |
|
2152 |
^ list sort |
|
2153 |
! |
|
2154 |
||
2155 |
percentToXColorValue:aPercentage |
|
2156 |
"given a color-component value in percent (0..100), return the corresponding |
|
2157 |
x-component value (0..65k) as an integer" |
|
2158 |
||
2159 |
%{ /* NOCONTEXT */ |
|
2160 |
||
2161 |
if (__isSmallInteger(aPercentage)) { |
|
555 | 2162 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2163 |
} |
2164 |
if (__isFloat(aPercentage)) { |
|
555 | 2165 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2166 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2167 |
%}. |
295 | 2168 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2169 |
! |
2170 |
||
892 | 2171 |
setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2172 |
"change color in map at:index to rgb (0..16rFFFF). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2173 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2174 |
|
2175 |
%{ /* NOCONTEXT */ |
|
2176 |
||
2177 |
char *colorname; |
|
2178 |
Display *dpy = myDpy; |
|
2179 |
XColor color; |
|
555 | 2180 |
int screen = __intVal(__INST(screen)); |
0 | 2181 |
int r, g, b; |
2182 |
int ok = 1; |
|
2183 |
||
892 | 2184 |
if (__isSmallInteger(sred)) |
2185 |
r = __intVal(sred); |
|
0 | 2186 |
else ok = 0; |
2187 |
||
892 | 2188 |
if (__isSmallInteger(sgreen)) |
2189 |
g = __intVal(sgreen); |
|
0 | 2190 |
else ok = 0; |
2191 |
||
892 | 2192 |
if (__isSmallInteger(sblue)) |
2193 |
b = __intVal(sblue); |
|
0 | 2194 |
else ok = 0; |
2195 |
||
97 | 2196 |
if (__isSmallInteger(index) && ok) { |
555 | 2197 |
color.pixel = __intVal(index); |
70 | 2198 |
color.red = r; |
2199 |
color.green = g; |
|
2200 |
color.blue = b; |
|
2201 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2202 |
||
2203 |
BEGIN_INTERRUPTSBLOCKED |
|
2204 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2205 |
END_INTERRUPTSBLOCKED |
|
2206 |
RETURN ( self ); |
|
0 | 2207 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2208 |
%}. |
0 | 2209 |
self primitiveFailed |
295 | 2210 |
! ! |
2211 |
||
2212 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2213 |
||
2214 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2215 |
"change a cursors colors" |
|
2216 |
||
2217 |
|fgR fgG fgB bgR bgG bgB| |
|
2218 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2219 |
fgR := fgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2220 |
fgG := fgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2221 |
fgB := fgColor scaledBlue. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2222 |
bgR := bgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2223 |
bgG := bgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2224 |
bgB := bgColor scaledBlue. |
0 | 2225 |
%{ |
295 | 2226 |
XColor fgcolor, bgcolor; |
2227 |
||
2228 |
if (__isExternalAddress(aCursorId) |
|
2229 |
&& __bothSmallInteger(fgG, fgB) |
|
2230 |
&& __bothSmallInteger(bgR, bgG) |
|
2231 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2232 |
||
555 | 2233 |
fgcolor.red = __intVal(fgR); |
2234 |
fgcolor.green= __intVal(fgG); |
|
2235 |
fgcolor.blue = __intVal(fgB); |
|
2236 |
bgcolor.red = __intVal(bgR); |
|
2237 |
bgcolor.green= __intVal(bgG); |
|
2238 |
bgcolor.blue = __intVal(bgB); |
|
70 | 2239 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2240 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2241 |
END_INTERRUPTSBLOCKED |
2242 |
RETURN ( self ); |
|
2243 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2244 |
%}. |
0 | 2245 |
self primitiveFailed |
70 | 2246 |
! |
2247 |
||
295 | 2248 |
createCursorShape:aShape |
2249 |
"create a cursor given a shape-symbol" |
|
2250 |
||
2251 |
|number id| |
|
2252 |
||
2253 |
displayId isNil ifTrue:[ |
|
2254 |
self primitiveFailed. |
|
2255 |
^ nil |
|
2256 |
]. |
|
2257 |
number := self shapeNumberFromSymbol:aShape. |
|
2258 |
%{ |
|
2259 |
Cursor newCursor; |
|
2260 |
||
2261 |
if (__isSmallInteger(number)) { |
|
2262 |
BEGIN_INTERRUPTSBLOCKED |
|
555 | 2263 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2264 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2265 |
if (newCursor) |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2266 |
__cnt_cursor++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2267 |
#endif |
295 | 2268 |
END_INTERRUPTSBLOCKED |
2269 |
if (newCursor != (Cursor)0) { |
|
2270 |
id = __MKOBJ(newCursor); |
|
70 | 2271 |
} |
0 | 2272 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2273 |
%}. |
295 | 2274 |
^ id |
2275 |
! |
|
2276 |
||
2277 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
2278 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2279 |
||
2280 |
|id sourceId maskId| |
|
2281 |
||
2282 |
displayId isNil ifTrue:[ |
|
2283 |
self primitiveFailed. |
|
2284 |
^ nil |
|
2285 |
]. |
|
2286 |
sourceId := sourceForm id. |
|
2287 |
maskId := maskForm id. |
|
2288 |
%{ |
|
2289 |
Cursor newCursor; |
|
2290 |
XColor fgColor, bgColor; |
|
2291 |
||
2292 |
if (__isExternalAddress(sourceId) |
|
2293 |
&& __isExternalAddress(maskId) |
|
2294 |
&& __bothSmallInteger(hx, hy)) { |
|
2295 |
fgColor.red = 0; /* fg is black */ |
|
2296 |
fgColor.green = 0; |
|
2297 |
fgColor.blue = 0; |
|
2298 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2299 |
bgColor.green = 0xFFFF; |
|
2300 |
bgColor.blue = 0xFFFF; |
|
2301 |
||
2302 |
BEGIN_INTERRUPTSBLOCKED |
|
2303 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2304 |
_PixmapVal(sourceId), |
|
2305 |
_PixmapVal(maskId), |
|
555 | 2306 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2307 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2308 |
if (newCursor) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2309 |
__cnt_cursor++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2310 |
#endif |
295 | 2311 |
END_INTERRUPTSBLOCKED |
2312 |
if (newCursor != (Cursor)0) { |
|
2313 |
id = __MKOBJ(newCursor); |
|
70 | 2314 |
} |
0 | 2315 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2316 |
%}. |
295 | 2317 |
^ id |
2318 |
! |
|
2319 |
||
2320 |
destroyCursor:aCursorId |
|
0 | 2321 |
|
2322 |
%{ /* NOCONTEXT */ |
|
2323 |
||
295 | 2324 |
if (ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2325 |
if (__isExternalAddress(aCursorId)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2326 |
Cursor curs = _CursorVal(aCursorId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2327 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2328 |
if (curs) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2329 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2330 |
XFreeCursor(myDpy, curs); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2331 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2332 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2333 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2334 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2335 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2336 |
RETURN ( self ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2337 |
} |
0 | 2338 |
} |
2339 |
%} |
|
2340 |
. |
|
2341 |
self primitiveFailed |
|
295 | 2342 |
! |
2343 |
||
2344 |
shapeNumberFromSymbol:shape |
|
2345 |
"given a shape-symbol, return the corresponding cursor-number" |
|
2346 |
||
2347 |
"this is pure X-knowlegde - but you may easily add more" |
|
2348 |
||
2349 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2350 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2351 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2352 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2353 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2354 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2355 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2356 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2357 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2358 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2359 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2360 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2361 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2362 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2363 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2364 |
((shape == #origin) |
|
2365 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2366 |
((shape == #corner) |
|
2367 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2368 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2369 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2370 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2371 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2372 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2373 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
|
2374 |
^ 0 |
|
0 | 2375 |
! ! |
2376 |
||
2377 |
!XWorkstation methodsFor:'drawing'! |
|
2378 |
||
2379 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2380 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 2381 |
|
2382 |
"do a bit-blt of a compressed FAX image |
|
2383 |
- this needs my private FAX extension" |
|
132 | 2384 |
|
2385 |
%{ /* NOCONTEXT */ |
|
0 | 2386 |
#ifdef FAX |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2387 |
GC gc; |
0 | 2388 |
FAXImage source; |
2389 |
Drawable dest; |
|
2390 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2391 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2392 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2393 |
&& __isExternalAddress(destId) |
97 | 2394 |
&& __bothSmallInteger(scaleX, scaleY) |
2395 |
&& __bothSmallInteger(w, h) |
|
2396 |
&& __bothSmallInteger(srcX, srcY) |
|
2397 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2398 |
gc = _GCVal(aGCId); |
70 | 2399 |
source = (FAXImage) _WindowVal(sourceId); |
2400 |
dest = (Drawable) _WindowVal(destId); |
|
2401 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
555 | 2402 |
__intVal(srcX), __intVal(srcY), |
2403 |
__intVal(w), __intVal(h), |
|
2404 |
__intVal(dstX), __intVal(dstY), |
|
2405 |
__intVal(scaleX), __intVal(scaleY)); |
|
70 | 2406 |
RETURN ( self ); |
0 | 2407 |
} |
2408 |
#endif |
|
118 | 2409 |
%}. |
0 | 2410 |
self primitiveFailed |
2411 |
! |
|
2412 |
||
2413 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2414 |
width:w height:h with:aGCId |
118 | 2415 |
"do a bit-blt; copy bits from the rectangle defined by |
2416 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2417 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2418 |
argument is not integer." |
|
0 | 2419 |
|
2420 |
%{ /* NOCONTEXT */ |
|
2421 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2422 |
GC gc; |
0 | 2423 |
Drawable source, dest; |
2424 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2425 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2426 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2427 |
&& __isExternalAddress(destId) |
97 | 2428 |
&& __bothSmallInteger(w, h) |
2429 |
&& __bothSmallInteger(srcX, srcY) |
|
2430 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2431 |
gc = _GCVal(aGCId); |
70 | 2432 |
source = (Drawable) _WindowVal(sourceId); |
2433 |
dest = (Drawable) _WindowVal(destId); |
|
2434 |
XCopyArea(myDpy, source, dest, gc, |
|
555 | 2435 |
__intVal(srcX), __intVal(srcY), |
2436 |
__intVal(w), __intVal(h), |
|
2437 |
__intVal(dstX), __intVal(dstY)); |
|
70 | 2438 |
RETURN ( self ); |
0 | 2439 |
} |
118 | 2440 |
%}. |
2441 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2442 |
or any non integer coordinate" |
|
2443 |
||
0 | 2444 |
self primitiveFailed |
2445 |
! |
|
2446 |
||
2447 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2448 |
width:w height:h with:aGCId |
118 | 2449 |
"do a bit-blt, but only copy the low-bit plane; |
2450 |
copy bits from the rectangle defined by |
|
2451 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2452 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2453 |
argument is not integer." |
|
0 | 2454 |
|
2455 |
%{ /* NOCONTEXT */ |
|
2456 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2457 |
GC gc; |
0 | 2458 |
Drawable source, dest; |
2459 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2460 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2461 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2462 |
&& __isExternalAddress(destId) |
97 | 2463 |
&& __bothSmallInteger(w, h) |
2464 |
&& __bothSmallInteger(srcX, srcY) |
|
2465 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2466 |
gc = _GCVal(aGCId); |
70 | 2467 |
source = (Drawable) _WindowVal(sourceId); |
2468 |
dest = (Drawable) _WindowVal(destId); |
|
2469 |
XCopyPlane(myDpy, source, dest, gc, |
|
555 | 2470 |
__intVal(srcX), __intVal(srcY), |
2471 |
__intVal(w), __intVal(h), |
|
2472 |
__intVal(dstX), __intVal(dstY), 1); |
|
70 | 2473 |
RETURN ( self ); |
0 | 2474 |
} |
118 | 2475 |
%}. |
2476 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2477 |
or any non integer coordinate" |
|
2478 |
||
0 | 2479 |
self primitiveFailed |
2480 |
! |
|
2481 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2482 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2483 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2484 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2485 |
|
2486 |
%{ /* NOCONTEXT */ |
|
2487 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2488 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2489 |
Window win; |
0 | 2490 |
int w, h, angle1, angle2; |
2491 |
double f; |
|
2492 |
||
97 | 2493 |
if (__isSmallInteger(startAngle)) |
850 | 2494 |
angle1 = __intVal(startAngle) * 64; |
36 | 2495 |
else if (__isFloat(startAngle)) { |
850 | 2496 |
f = __floatVal(startAngle); |
2497 |
angle1 = f * 64; |
|
0 | 2498 |
} |
97 | 2499 |
if (__isSmallInteger(angle)) |
850 | 2500 |
angle2 = __intVal(angle) * 64; |
36 | 2501 |
else if (__isFloat(angle)) { |
850 | 2502 |
f = __floatVal(angle); |
2503 |
angle2 = f * 64; |
|
0 | 2504 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2505 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2506 |
&& __isExternalAddress(aDrawableId) |
97 | 2507 |
&& __bothSmallInteger(x, y) |
2508 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2509 |
win = _WindowVal(aDrawableId); |
2510 |
gc = _GCVal(aGCId); |
|
2511 |
w = __intVal(width); |
|
2512 |
h = __intVal(height); |
|
2513 |
/* |
|
2514 |
* need this check here: some servers simply dump core with bad args |
|
2515 |
*/ |
|
2516 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2517 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2518 |
w, h, angle1, angle2); |
|
2519 |
} |
|
2520 |
RETURN ( self ); |
|
0 | 2521 |
} |
73 | 2522 |
%}. |
2523 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2524 |
self primitiveFailed |
2525 |
! |
|
2526 |
||
295 | 2527 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2528 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2529 |
||
2530 |
%{ /* NOCONTEXT */ |
|
2531 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2532 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2533 |
Window win; |
295 | 2534 |
|
2535 |
if (__isExternalAddress(aGCId) |
|
2536 |
&& __isExternalAddress(aDrawableId) |
|
2537 |
&& __bothSmallInteger(x0, y0) |
|
2538 |
&& __bothSmallInteger(x1, y1)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2539 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2540 |
win = _WindowVal(aDrawableId); |
555 | 2541 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
2542 |
__intVal(x1), __intVal(y1)); |
|
295 | 2543 |
RETURN ( self ); |
2544 |
} |
|
2545 |
%}. |
|
2546 |
"badGC, badDrawable or coordinates not integer" |
|
2547 |
self primitiveFailed |
|
2548 |
! |
|
2549 |
||
2550 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2551 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2552 |
||
2553 |
%{ /* NOCONTEXT */ |
|
2554 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2555 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2556 |
Window win; |
295 | 2557 |
|
2558 |
if (__isExternalAddress(aGCId) |
|
2559 |
&& __isExternalAddress(aDrawableId) |
|
2560 |
&& __bothSmallInteger(x, y)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2561 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2562 |
win = _WindowVal(aDrawableId); |
555 | 2563 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
295 | 2564 |
RETURN ( self ); |
2565 |
} |
|
2566 |
%}. |
|
2567 |
"badGC, badDrawable or x/y not integer" |
|
2568 |
self primitiveFailed |
|
2569 |
! |
|
2570 |
||
2571 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2572 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2573 |
define the polygon. |
|
2574 |
If any coordinate is not integer, an error is triggered." |
|
2575 |
||
2576 |
|numberOfPoints newPoints| |
|
2577 |
||
2578 |
numberOfPoints := aPolygon size. |
|
2579 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2580 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2581 |
Window win; |
295 | 2582 |
OBJ point, x, y; |
2583 |
int i, num; |
|
2584 |
XPoint *points; |
|
2585 |
XPoint qPoints[100]; |
|
377 | 2586 |
int mustFree = 0; |
295 | 2587 |
|
2588 |
if (__isExternalAddress(aGCId) |
|
2589 |
&& __isExternalAddress(aDrawableId) |
|
2590 |
&& __isSmallInteger(numberOfPoints)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2591 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2592 |
win = _WindowVal(aDrawableId); |
555 | 2593 |
num = __intVal(numberOfPoints); |
295 | 2594 |
/* |
2595 |
* avoid a (slow) malloc, if the number of points is small |
|
2596 |
*/ |
|
2597 |
if (num > 100) { |
|
2598 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2599 |
if (! points) goto fail; |
|
377 | 2600 |
mustFree = 1; |
295 | 2601 |
} else |
2602 |
points = qPoints; |
|
2603 |
||
2604 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2605 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2606 |
if (! __isPoint(point)) goto fail; |
2607 |
x = _point_X(point); |
|
2608 |
y = _point_Y(point); |
|
2609 |
if (! __bothSmallInteger(x, y)) |
|
2610 |
goto fail; |
|
555 | 2611 |
points[i].x = __intVal(x); |
2612 |
points[i].y = __intVal(y); |
|
295 | 2613 |
} |
2614 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2615 |
if (mustFree) |
295 | 2616 |
free(points); |
2617 |
RETURN ( self ); |
|
2618 |
} |
|
2619 |
fail: ; |
|
377 | 2620 |
if (mustFree) |
382 | 2621 |
free(points); |
295 | 2622 |
%}. |
2623 |
"badGC, badDrawable or coordinates not integer" |
|
2624 |
self primitiveFailed |
|
2625 |
! |
|
2626 |
||
2627 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2628 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2629 |
||
2630 |
%{ /* NOCONTEXT */ |
|
2631 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2632 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2633 |
Window win; |
295 | 2634 |
int w, h; |
2635 |
||
2636 |
if (__isExternalAddress(aGCId) |
|
2637 |
&& __isExternalAddress(aDrawableId) |
|
2638 |
&& __bothSmallInteger(x, y) |
|
2639 |
&& __bothSmallInteger(width, height)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2640 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2641 |
win = _WindowVal(aDrawableId); |
555 | 2642 |
w = __intVal(width); |
2643 |
h = __intVal(height); |
|
295 | 2644 |
/* |
2645 |
* need this check here: some servers simply dump core with bad args |
|
2646 |
*/ |
|
2647 |
if ((w >= 0) && (h >= 0)) { |
|
555 | 2648 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
295 | 2649 |
} |
2650 |
RETURN ( self ); |
|
2651 |
} |
|
2652 |
%}. |
|
2653 |
"badGC, badDrawable or coordinates not integer" |
|
2654 |
self primitiveFailed |
|
2655 |
! |
|
2656 |
||
2657 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2658 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2659 |
foreground and background characters. |
|
2660 |
If the coordinates are not integers, an error is triggered." |
|
2661 |
||
2662 |
%{ /* NOCONTEXT */ |
|
2663 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2664 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2665 |
Window win; |
295 | 2666 |
unsigned char *cp; |
2667 |
OBJ cls; |
|
2668 |
int i1, i2, l, n; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2669 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2670 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2671 |
int nInstBytes; |
295 | 2672 |
|
2673 |
if (__isExternalAddress(aGCId) |
|
2674 |
&& __isExternalAddress(aDrawableId) |
|
2675 |
&& __isNonNilObject(aString) |
|
2676 |
&& __bothSmallInteger(index1, index2) |
|
2677 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2678 |
gc = _GCVal(aGCId); |
2679 |
win = _WindowVal(aDrawableId); |
|
2680 |
cls = __qClass(aString); |
|
2681 |
||
2682 |
i1 = __intVal(index1) - 1; |
|
2683 |
if (i1 >= 0) { |
|
2684 |
i2 = __intVal(index2) - 1; |
|
2685 |
if (i2 < i1) { |
|
2686 |
RETURN (self); |
|
2687 |
} |
|
2688 |
||
2689 |
cp = _stringVal(aString); |
|
2690 |
l = i2 - i1 + 1; |
|
2691 |
||
2692 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2693 |
n = _stringSize(aString); |
|
2694 |
if (i2 < n) { |
|
2695 |
cp += i1; |
|
2696 |
if (l > 1000) l = 1000; |
|
2697 |
if (opaque == true) |
|
2698 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2699 |
else |
|
2700 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2701 |
RETURN ( self ); |
|
2702 |
} |
|
2703 |
} |
|
2704 |
||
2705 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2706 |
cp += nInstBytes; |
|
2707 |
||
2708 |
if (__isBytes(aString)) { |
|
2709 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2710 |
||
2711 |
if (i2 < n) { |
|
2712 |
cp += i1; |
|
2713 |
if (l > 1000) l = 1000; |
|
2714 |
if (opaque == true) |
|
2715 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2716 |
else |
|
2717 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2718 |
RETURN ( self ); |
|
2719 |
} |
|
2720 |
} |
|
2721 |
||
2722 |
/* TWOBYTESTRINGS */ |
|
2723 |
if (__isWords(aString)) { |
|
2724 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2725 |
||
2726 |
if (i2 < n) { |
|
2727 |
union { |
|
2728 |
char b[2]; |
|
2729 |
unsigned short s; |
|
2730 |
} u; |
|
2731 |
int i; |
|
2732 |
XChar2b *cp2 = (XChar2b *)0; |
|
2733 |
int mustFree = 0; |
|
2734 |
||
2735 |
cp += (i1 * 2); |
|
2736 |
if (l > 1000) l = 1000; |
|
2737 |
||
2738 |
/* |
|
2739 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2740 |
* X expects them MSB first |
|
2741 |
* convert as required |
|
2742 |
*/ |
|
2743 |
||
2744 |
u.s = 0x1234; |
|
2745 |
if (u.b[0] != 0x12) { |
|
2746 |
if (l <= NLOCALBUFFER) { |
|
2747 |
cp2 = xlatebuffer; |
|
2748 |
} else { |
|
2749 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2750 |
mustFree = 1; |
|
2751 |
} |
|
2752 |
for (i=0; i<l; i++) { |
|
2753 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2754 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2755 |
} |
|
2756 |
cp = (char *) cp2; |
|
2757 |
} |
|
2758 |
||
2759 |
if (opaque == true) |
|
2760 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2761 |
else |
|
2762 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2763 |
||
2764 |
if (mustFree) { |
|
2765 |
free(cp2); |
|
2766 |
} |
|
2767 |
||
2768 |
RETURN ( self ); |
|
2769 |
} |
|
2770 |
} |
|
2771 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2772 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2773 |
#undef NLOCALBUFFER |
295 | 2774 |
%}. |
2775 |
"x/y not integer, badGC or drawable, or not a string" |
|
2776 |
self primitiveFailed |
|
2777 |
! |
|
2778 |
||
2779 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2780 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2781 |
foreground and background characters. |
|
2782 |
If the coordinates are not integers, an error is triggered." |
|
2783 |
||
2784 |
%{ /* NOCONTEXT */ |
|
2785 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2786 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2787 |
Window win; |
295 | 2788 |
unsigned char *cp; |
2789 |
int n; |
|
2790 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2791 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2792 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2793 |
int nInstBytes; |
295 | 2794 |
|
2795 |
if (__isExternalAddress(aGCId) |
|
2796 |
&& __isExternalAddress(aDrawableId) |
|
2797 |
&& __isNonNilObject(aString) |
|
2798 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2799 |
gc = _GCVal(aGCId); |
2800 |
win = _WindowVal(aDrawableId); |
|
2801 |
cls = __qClass(aString); |
|
2802 |
||
2803 |
cp = _stringVal(aString); |
|
2804 |
||
2805 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2806 |
n = _stringSize(aString); |
|
2807 |
if (n > 1000) n = 1000; |
|
2808 |
if (opaque == true) |
|
2809 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2810 |
else |
|
2811 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2812 |
RETURN ( self ); |
|
2813 |
} |
|
2814 |
||
2815 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2816 |
cp += nInstBytes; |
|
2817 |
||
2818 |
if (__isBytes(aString)) { |
|
2819 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2820 |
||
2821 |
if (n > 1000) n = 1000; |
|
2822 |
if (opaque == true) |
|
2823 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2824 |
else |
|
2825 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2826 |
RETURN ( self ); |
|
2827 |
} |
|
2828 |
||
2829 |
/* TWOBYTESTRINGS */ |
|
2830 |
if (__isWords(aString)) { |
|
2831 |
union { |
|
2832 |
char b[2]; |
|
2833 |
unsigned short s; |
|
2834 |
} u; |
|
2835 |
int i; |
|
2836 |
XChar2b *cp2; |
|
2837 |
int mustFree = 0; |
|
2838 |
||
2839 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2840 |
if (n > 1000) n = 1000; |
|
2841 |
||
2842 |
/* |
|
2843 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2844 |
* X expects them MSB first |
|
2845 |
* convert as required |
|
2846 |
*/ |
|
2847 |
||
2848 |
u.s = 0x1234; |
|
2849 |
if (u.b[0] != 0x12) { |
|
2850 |
if (n <= NLOCALBUFFER) { |
|
2851 |
cp2 = xlatebuffer; |
|
2852 |
} else { |
|
2853 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2854 |
mustFree = 1; |
|
2855 |
} |
|
2856 |
||
2857 |
for (i=0; i<n; i++) { |
|
2858 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2859 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2860 |
} |
|
2861 |
cp = (char *) cp2; |
|
2862 |
} |
|
2863 |
||
2864 |
if (opaque == true) |
|
2865 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2866 |
else |
|
2867 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2868 |
||
2869 |
||
2870 |
if (mustFree) { |
|
2871 |
free(cp2); |
|
2872 |
} |
|
2873 |
||
2874 |
RETURN ( self ); |
|
2875 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2876 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2877 |
#undef NLOCALBUFFER |
295 | 2878 |
%}. |
2879 |
"x/y not integer, badGC or drawable, or not a string" |
|
2880 |
self primitiveFailed |
|
2881 |
! |
|
2882 |
||
2883 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2884 |
width:imageWidth height:imageHeight |
|
2885 |
x:srcx y:srcy |
|
2886 |
into:aDrawableId |
|
2887 |
x:dstx y:dsty |
|
2888 |
width:w height:h |
|
2889 |
with:aGCId |
|
2890 |
||
2891 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2892 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2893 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2894 |
depth and pixel-units to be different. |
|
2895 |
It has to be checked elsewhere, that the server can do it with the given |
|
2896 |
depth - otherwise, primitive failure will be signalled. |
|
2897 |
Also it is assumed, that the colormap is setup correctly and the |
|
2898 |
colors are allocated - otherwise the colors may be wrong." |
|
2899 |
||
2900 |
" |
|
2901 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2902 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2903 |
" |
|
2904 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2905 |
width:imageWidth height:imageHeight |
|
2906 |
x:srcx y:srcy |
|
2907 |
into:aDrawableId |
|
2908 |
x:dstx y:dsty |
|
2909 |
width:w height:h |
|
2910 |
with:aGCId) |
|
2911 |
ifFalse:[ |
|
2912 |
" |
|
2913 |
also happens, if a segmentation violation occurs in the |
|
2914 |
XPutImage ... |
|
2915 |
" |
|
2916 |
self primitiveFailed |
|
2917 |
]. |
|
2918 |
! |
|
2919 |
||
2920 |
drawBits:imageBits depth:imageDepth |
|
2921 |
width:imageWidth height:imageHeight |
|
2922 |
x:srcx y:srcy |
|
2923 |
into:aDrawableId |
|
2924 |
x:dstx y:dsty |
|
2925 |
width:w height:h |
|
2926 |
with:aGCId |
|
2927 |
||
2928 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2929 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2930 |
Individual source pixels must have imageDepth bits. |
|
2931 |
It has to be checked elsewhere, that the server can do it with the given |
|
2932 |
depth - otherwise, primitive failure will be signalled. |
|
2933 |
Also it is assumed, that the colormap is setup correctly and the |
|
2934 |
colors are allocated - otherwise the colors may be wrong." |
|
2935 |
||
2936 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2937 |
width:imageWidth height:imageHeight |
|
2938 |
x:srcx y:srcy |
|
2939 |
into:aDrawableId |
|
2940 |
x:dstx y:dsty |
|
2941 |
width:w height:h |
|
2942 |
with:aGCId |
|
2943 |
||
2944 |
! |
|
2945 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2946 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
850 | 2947 |
in:aDrawableId with:aGCId |
90 | 2948 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2949 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2950 |
|
2951 |
%{ /* NOCONTEXT */ |
|
2952 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2953 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2954 |
Window win; |
0 | 2955 |
int w, h, angle1, angle2; |
2956 |
double f; |
|
2957 |
||
97 | 2958 |
if (__isSmallInteger(startAngle)) |
850 | 2959 |
angle1 = __intVal(startAngle) * 64; |
36 | 2960 |
else if (__isFloat(startAngle)) { |
850 | 2961 |
f = __floatVal(startAngle); |
2962 |
angle1 = f * 64; |
|
0 | 2963 |
} |
97 | 2964 |
if (__isSmallInteger(angle)) |
850 | 2965 |
angle2 = __intVal(angle) * 64; |
36 | 2966 |
else if (__isFloat(angle)) { |
850 | 2967 |
f = __floatVal(angle); |
2968 |
angle2 = f * 64; |
|
0 | 2969 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2970 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2971 |
&& __isExternalAddress(aDrawableId) |
97 | 2972 |
&& __bothSmallInteger(x, y) |
2973 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2974 |
gc = _GCVal(aGCId); |
2975 |
win = _WindowVal(aDrawableId); |
|
2976 |
w = __intVal(width); |
|
2977 |
h = __intVal(height); |
|
2978 |
/* |
|
2979 |
* need this check here: some servers simply dump core with bad args |
|
2980 |
*/ |
|
2981 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2982 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2983 |
w, h, angle1, angle2); |
|
2984 |
} |
|
2985 |
RETURN ( self ); |
|
0 | 2986 |
} |
73 | 2987 |
%}. |
2988 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2989 |
self primitiveFailed |
2990 |
! |
|
2991 |
||
2992 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2993 |
"fill a polygon given by its points. |
2994 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2995 |
|
2996 |
|numberOfPoints| |
|
0 | 2997 |
|
2998 |
numberOfPoints := aPolygon size. |
|
2999 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3000 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3001 |
Window win; |
73 | 3002 |
OBJ point, x, y; |
3003 |
int i, num; |
|
3004 |
XPoint *points; |
|
3005 |
XPoint qPoints[100]; |
|
377 | 3006 |
int mustFree = 0; |
73 | 3007 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3008 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3009 |
&& __isExternalAddress(aDrawableId) |
97 | 3010 |
&& __isSmallInteger(numberOfPoints)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3011 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3012 |
win = _WindowVal(aDrawableId); |
555 | 3013 |
num = __intVal(numberOfPoints); |
73 | 3014 |
if (num < 3) { |
70 | 3015 |
RETURN ( self ); |
3016 |
} |
|
73 | 3017 |
/* |
3018 |
* avoid (slow) malloc, if not many points |
|
3019 |
*/ |
|
96 | 3020 |
if (num > 100) { |
73 | 3021 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 3022 |
if (! points) goto fail; |
377 | 3023 |
mustFree = 1; |
96 | 3024 |
} else |
73 | 3025 |
points = qPoints; |
3026 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3027 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 3028 |
if (! __isPoint(point)) goto fail; |
3029 |
x = _point_X(point); |
|
3030 |
y = _point_Y(point); |
|
97 | 3031 |
if (! __bothSmallInteger(x, y)) |
73 | 3032 |
goto fail; |
555 | 3033 |
points[i].x = __intVal(x); |
3034 |
points[i].y = __intVal(y); |
|
73 | 3035 |
} |
3036 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 3037 |
if (mustFree) |
73 | 3038 |
free(points); |
3039 |
RETURN ( self ); |
|
377 | 3040 |
|
0 | 3041 |
fail: ; |
382 | 3042 |
if (mustFree) |
3043 |
free(points); |
|
0 | 3044 |
} |
73 | 3045 |
%}. |
3046 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3047 |
self primitiveFailed |
3048 |
! |
|
3049 |
||
295 | 3050 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3051 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3052 |
||
3053 |
%{ /* NOCONTEXT */ |
|
3054 |
||
3055 |
int w, h; |
|
3056 |
||
3057 |
if (__isExternalAddress(aGCId) |
|
3058 |
&& __isExternalAddress(aDrawableId) |
|
3059 |
&& __bothSmallInteger(x, y) |
|
3060 |
&& __bothSmallInteger(width, height)) { |
|
555 | 3061 |
w = __intVal(width); |
3062 |
h = __intVal(height); |
|
295 | 3063 |
/* |
3064 |
* need this check here: some servers simply dump core with bad args |
|
3065 |
*/ |
|
3066 |
if ((w >= 0) && (h >= 0)) { |
|
3067 |
XFillRectangle(myDpy, |
|
3068 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
555 | 3069 |
__intVal(x), __intVal(y), w, h); |
295 | 3070 |
} |
3071 |
RETURN ( self ); |
|
3072 |
} |
|
3073 |
%}. |
|
3074 |
"badGC, badDrawable or coordinates not integer" |
|
3075 |
self primitiveFailed |
|
43 | 3076 |
! |
3077 |
||
3078 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 3079 |
width:imageWidth height:imageHeight |
3080 |
x:srcx y:srcy |
|
3081 |
into:aDrawableId |
|
3082 |
x:dstx y:dsty |
|
3083 |
width:w height:h |
|
3084 |
with:aGCId |
|
0 | 3085 |
|
132 | 3086 |
"since XPutImage may allocate huge amount of stack space |
3087 |
(some implementations use alloca), this must run with unlimited stack." |
|
3088 |
||
12 | 3089 |
%{ /* UNLIMITEDSTACK */ |
0 | 3090 |
|
43 | 3091 |
/* |
3092 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3093 |
* XPutImage |
|
3094 |
*/ |
|
3095 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3096 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3097 |
Window win; |
43 | 3098 |
XImage image; |
377 | 3099 |
int imgWdth; |
43 | 3100 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3101 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3102 |
&& __isExternalAddress(aDrawableId) |
97 | 3103 |
&& __bothSmallInteger(srcx, srcy) |
3104 |
&& __bothSmallInteger(dstx, dsty) |
|
3105 |
&& __bothSmallInteger(w, h) |
|
3106 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3107 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3108 |
&& __isByteArray(imageBits)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3109 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3110 |
win = _WindowVal(aDrawableId); |
811 | 3111 |
if (! gc || !win) |
3112 |
goto fail; |
|
46 | 3113 |
#ifdef ARGDEBUG |
70 | 3114 |
printf("args ok\n"); |
46 | 3115 |
#endif |
555 | 3116 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3117 |
image.width = imgWdth = __intVal(imageWidth); |
|
3118 |
image.height = __intVal(imageHeight); |
|
70 | 3119 |
image.xoffset = 0; |
3120 |
image.format = ZPixmap; |
|
3121 |
image.byte_order = MSBFirst; |
|
3122 |
image.bitmap_unit = 8; |
|
3123 |
image.bitmap_bit_order = MSBFirst; |
|
3124 |
image.bitmap_pad = 8; |
|
555 | 3125 |
image.depth = __intVal(imageDepth); |
3126 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
70 | 3127 |
switch (image.bits_per_pixel) { |
3128 |
case 1: |
|
377 | 3129 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 3130 |
break; |
3131 |
case 2: |
|
377 | 3132 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 3133 |
break; |
3134 |
case 4: |
|
377 | 3135 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 3136 |
break; |
3137 |
case 8: |
|
377 | 3138 |
image.bytes_per_line = imgWdth; |
70 | 3139 |
break; |
3140 |
case 16: |
|
377 | 3141 |
image.bytes_per_line = imgWdth*2; |
70 | 3142 |
break; |
3143 |
case 24: |
|
377 | 3144 |
image.bytes_per_line = imgWdth*3; |
70 | 3145 |
break; |
193 | 3146 |
case 32: |
377 | 3147 |
image.bytes_per_line = imgWdth*4; |
193 | 3148 |
break; |
70 | 3149 |
default: |
46 | 3150 |
#ifdef ARGDEBUG |
70 | 3151 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3152 |
#endif |
70 | 3153 |
goto fail; |
3154 |
} |
|
3155 |
image.red_mask = 0xFFFF; |
|
3156 |
image.green_mask = 0xFFFF; |
|
3157 |
image.blue_mask = 0xFFFF; |
|
555 | 3158 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
3159 |
__intVal(dstx), __intVal(dsty), |
|
3160 |
__intVal(w), __intVal(h)); |
|
70 | 3161 |
RETURN ( true ); |
43 | 3162 |
} |
46 | 3163 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3164 |
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
|
3165 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3166 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3167 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3168 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3169 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3170 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3171 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3172 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3173 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3174 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3175 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3176 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3177 |
#endif |
3178 |
||
0 | 3179 |
fail: ; |
3180 |
%} |
|
3181 |
. |
|
12 | 3182 |
^ false |
0 | 3183 |
! ! |
3184 |
||
86 | 3185 |
!XWorkstation methodsFor:'event handling'! |
0 | 3186 |
|
3187 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3188 |
"central event handling method: |
|
54 | 3189 |
get next event and send appropriate message to the sensor or view. |
0 | 3190 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3191 |
otherwise only events for the view with given id are processed. |
3192 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3193 |
handled." |
|
3194 |
||
54 | 3195 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3196 |
AbortSignal catch:[ |
83 | 3197 |
self dispatchLastEvent. |
3198 |
] |
|
54 | 3199 |
]. |
12 | 3200 |
! |
3201 |
||
295 | 3202 |
dispatchExposeEventFor:aViewIdOrNil |
3203 |
"get next expose event and send appropriate message to the sensor or view. |
|
3204 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3205 |
otherwise only events for the view with given id are processed." |
|
3206 |
||
3207 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3208 |
! |
3209 |
||
3210 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3211 |
|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
|
3212 |
eventType| |
12 | 3213 |
|
3214 |
%{ /* STACK: 8000 */ |
|
3215 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3216 |
|
3217 |
Display *dpy = myDpy; |
|
135 | 3218 |
OBJ eB; |
3219 |
XEvent *ev; |
|
3220 |
||
3221 |
# define ae ((XAnyEvent *)ev) |
|
3222 |
# define ee ((XExposeEvent *)ev) |
|
3223 |
# define ke ((XKeyPressedEvent *)ev) |
|
3224 |
# define be ((XButtonPressedEvent *)ev) |
|
3225 |
# define ce ((XConfigureEvent *)ev) |
|
3226 |
# define me ((XMotionEvent *)ev) |
|
3227 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3228 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3229 |
# define de ((XDestroyWindowEvent *)ev) |
|
3230 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3231 |
# define mape ((XMappingEvent *)ev) |
135 | 3232 |
|
0 | 3233 |
KeySym keySym; |
3234 |
unsigned char buffer[10]; |
|
3235 |
int i, nchars; |
|
3236 |
char *keySymString; |
|
3237 |
char keySymStringBuffer[32]; |
|
3238 |
static unsigned multiClickTime = 0; |
|
3239 |
unsigned nextMultiClickTime; |
|
150 | 3240 |
OBJ upDown; |
115 | 3241 |
|
3242 |
struct inlineCache *ipS; |
|
0 | 3243 |
static struct inlineCache vid = _ILC1; |
12 | 3244 |
|
3245 |
static struct inlineCache expS = _ILC5; |
|
3246 |
static struct inlineCache gexpS = _ILC5; |
|
3247 |
static struct inlineCache nexpS = _ILC1; |
|
3248 |
static struct inlineCache motS = _ILC4; |
|
3249 |
static struct inlineCache bpS = _ILC4; |
|
3250 |
static struct inlineCache bmpS = _ILC4; |
|
3251 |
static struct inlineCache bspS = _ILC4; |
|
3252 |
static struct inlineCache brS = _ILC4; |
|
3253 |
static struct inlineCache focInS = _ILC1; |
|
3254 |
static struct inlineCache focOutS = _ILC1; |
|
3255 |
static struct inlineCache peS = _ILC4; |
|
3256 |
static struct inlineCache plS = _ILC2; |
|
54 | 3257 |
static struct inlineCache termS = _ILC1; |
3258 |
static struct inlineCache savtermS = _ILC1; |
|
3259 |
static struct inlineCache destrS = _ILC1; |
|
3260 |
static struct inlineCache unmapS = _ILC1; |
|
3261 |
static struct inlineCache mapS = _ILC1; |
|
3262 |
static struct inlineCache confS = _ILC5; |
|
70 | 3263 |
static struct inlineCache coveredS = _ILC2; |
12 | 3264 |
|
3265 |
static struct inlineCache keymap = _ILC0; |
|
3266 |
static struct inlineCache created = _ILC0; |
|
3267 |
static struct inlineCache mapReq = _ILC0; |
|
3268 |
static struct inlineCache repar = _ILC0; |
|
3269 |
static struct inlineCache confReq = _ILC0; |
|
3270 |
static struct inlineCache resReq = _ILC0; |
|
3271 |
static struct inlineCache prop = _ILC0; |
|
129 | 3272 |
static struct inlineCache selClear = _ILC1; |
90 | 3273 |
static struct inlineCache selReq = _ILC4; |
3274 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3275 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3276 |
static struct inlineCache mapping = _ILC2; |
70 | 3277 |
static struct inlineCache vis = _ILC1; |
12 | 3278 |
|
3279 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3280 |
static struct inlineCache skrS = _ILC4; |
12 | 3281 |
|
555 | 3282 |
eB = __INST(eventBuffer); |
135 | 3283 |
if (__isByteArray(eB)) { |
555 | 3284 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3285 |
} else { |
3286 |
printf("DISPLAY: no eventBuffer\n"); |
|
3287 |
RETURN (false); |
|
3288 |
} |
|
3289 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3290 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3291 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3292 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3293 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3294 |
RETURN (nil); |
12 | 3295 |
} |
3296 |
||
3297 |
/* |
|
3298 |
* key, button and pointer events are sent to the sensor, |
|
3299 |
* or (if there is none) to the delegate. |
|
3300 |
* or (if there is none) to the view. |
|
26 | 3301 |
* |
3302 |
* expose events are sent to the sensor, |
|
3303 |
* or (if there is none) to the view |
|
3304 |
* |
|
12 | 3305 |
* sensor and delegate get view as additional argument |
115 | 3306 |
* all of this has been taken out of here to corresponding methods |
3307 |
* in DeviceWorkstation. |
|
12 | 3308 |
*/ |
90 | 3309 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3310 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3311 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3312 |
#endif |
135 | 3313 |
switch (ev->type) { |
70 | 3314 |
case KeyRelease: |
115 | 3315 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3316 |
ipS = &skrS; |
150 | 3317 |
upDown = false; |
70 | 3318 |
goto keyPressAndRelease; |
3319 |
||
3320 |
case KeyPress: |
|
115 | 3321 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3322 |
ipS = &skpS; |
150 | 3323 |
upDown = true; |
3324 |
/* FALL INTO */ |
|
70 | 3325 |
|
3326 |
keyPressAndRelease: |
|
555 | 3327 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
3328 |
__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
|
3329 |
#ifdef OLD |
555 | 3330 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3331 |
__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
|
3332 |
#else |
555 | 3333 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3334 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3335 |
#endif |
555 | 3336 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3337 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
70 | 3338 |
|
3339 |
arg = nil; |
|
3340 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3341 |
if (nchars |
|
3342 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3343 |
|| (buffer[0] >= 0x80))) { |
|
3344 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3345 |
keySymString = NULL; |
|
3346 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3347 |
#ifdef OLD |
150 | 3348 |
switch (keySym) { |
3349 |
case XK_Control_L: |
|
3350 |
case XK_Control_R: |
|
555 | 3351 |
__INST(ctrlDown) = upDown; |
150 | 3352 |
break; |
3353 |
case XK_Shift_L: |
|
3354 |
case XK_Shift_R: |
|
555 | 3355 |
__INST(shiftDown) = upDown; |
150 | 3356 |
break; |
3357 |
case XK_Meta_L: |
|
3358 |
case XK_Meta_R: |
|
555 | 3359 |
__INST(metaDown) = upDown; |
150 | 3360 |
break; |
3361 |
case XK_Alt_L: |
|
3362 |
case XK_Alt_R: |
|
555 | 3363 |
__INST(altDown) = upDown; |
150 | 3364 |
break; |
3365 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3366 |
#endif |
150 | 3367 |
|
70 | 3368 |
keySymString = XKeysymToString(keySym); |
3369 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3370 |
#ifdef OLD |
70 | 3371 |
if (keySymString[0] == 'D') { |
3372 |
/* |
|
3373 |
* remove underscore, dont want it in symbols |
|
3374 |
*/ |
|
3375 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3376 |
keySymString = "DeleteLine"; |
|
3377 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3378 |
keySymString = "DeleteWord"; |
|
3379 |
} |
|
3380 |
} |
|
3381 |
/* |
|
3382 |
* make names compatible |
|
3383 |
*/ |
|
3384 |
if (strcmp(keySymString, "Down") == 0) { |
|
3385 |
keySymString = "CursorDown"; |
|
3386 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3387 |
keySymString = "CursorUp"; |
|
3388 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3389 |
keySymString = "CursorLeft"; |
|
3390 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3391 |
keySymString = "CursorRight"; |
|
3392 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3393 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3394 |
#else |
350 | 3395 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3396 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3397 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3398 |
#endif |
70 | 3399 |
} |
3400 |
} |
|
3401 |
||
3402 |
if (arg == nil) { |
|
3403 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3404 |
break; |
|
3405 |
} |
|
3406 |
||
115 | 3407 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3408 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3409 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3410 |
__MKSMALLINT(ke->y), |
115 | 3411 |
theView); |
70 | 3412 |
break; |
3413 |
||
3414 |
case ButtonPress: |
|
555 | 3415 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
3416 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3417 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3418 |
||
3419 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3420 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
70 | 3421 |
else |
3422 |
nextMultiClickTime = 0; |
|
3423 |
||
3424 |
if (multiClickTime) { |
|
3425 |
if (be->time < multiClickTime) { |
|
3426 |
multiClickTime = nextMultiClickTime; |
|
3427 |
ipS = &bmpS; |
|
3428 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3429 |
goto sendButtonEvent; |
|
3430 |
break; |
|
3431 |
} |
|
3432 |
} |
|
3433 |
multiClickTime = nextMultiClickTime; |
|
3434 |
if (be->state & ShiftMask) { |
|
3435 |
ipS = &bspS; |
|
3436 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3437 |
goto sendButtonEvent; |
|
3438 |
} |
|
3439 |
ipS = &bpS; |
|
3440 |
symS = @symbol(buttonPress:x:y:view:); |
|
3441 |
goto sendButtonEvent; |
|
200 | 3442 |
|
70 | 3443 |
/* NOT REACHED */ |
3444 |
||
3445 |
case ButtonRelease: |
|
555 | 3446 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
3447 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3448 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
70 | 3449 |
ipS = &brS; |
3450 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3451 |
/* fall into */ |
|
3452 |
||
3453 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3454 |
butt = __MKSMALLINT(be->button); |
12 | 3455 |
#ifdef NOTDEF |
70 | 3456 |
/* |
3457 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3458 |
*/ |
|
555 | 3459 |
if (__INST(metaDown) == true) |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3460 |
butt = __MKSMALLINT(2); |
70 | 3461 |
else |
0 | 3462 |
#endif |
555 | 3463 |
butt = __AT_(__INST(buttonTranslation), butt); |
200 | 3464 |
|
12 | 3465 |
|
115 | 3466 |
(*(*ipS).ilc_func)(self, |
3467 |
symS |
|
3468 |
COMMA_CON, nil, ipS, |
|
3469 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3470 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3471 |
__MKSMALLINT(ke->y), |
115 | 3472 |
theView); |
70 | 3473 |
break; |
3474 |
||
3475 |
case MotionNotify: |
|
555 | 3476 |
if (__INST(motionEventCompression) != false) { |
135 | 3477 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3478 |
} |
3479 |
||
555 | 3480 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
3481 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3482 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3483 |
#ifdef OLD |
555 | 3484 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3485 |
__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
|
3486 |
#else |
555 | 3487 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3488 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3489 |
#endif |
555 | 3490 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3491 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
150 | 3492 |
|
115 | 3493 |
(*motS.ilc_func)(self, |
3494 |
@symbol(buttonMotion:x:y:view:) |
|
3495 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3496 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3497 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3498 |
__MKSMALLINT(me->y), |
115 | 3499 |
theView); |
70 | 3500 |
break; |
3501 |
||
3502 |
case FocusIn: |
|
115 | 3503 |
(*focInS.ilc_func)(self, |
3504 |
@symbol(focusInView:) |
|
3505 |
COMMA_CON, nil, &focInS, |
|
3506 |
theView); |
|
70 | 3507 |
break; |
3508 |
||
3509 |
case FocusOut: |
|
115 | 3510 |
(*focOutS.ilc_func)(self, |
3511 |
@symbol(focusOutView:) |
|
3512 |
COMMA_CON, nil, &focOutS, |
|
3513 |
theView); |
|
70 | 3514 |
break; |
3515 |
||
3516 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3517 |
#ifdef OLD |
555 | 3518 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3519 |
__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
|
3520 |
#else |
555 | 3521 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3522 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3523 |
#endif |
555 | 3524 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3525 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
150 | 3526 |
|
115 | 3527 |
(*peS.ilc_func)(self, |
3528 |
@symbol(pointerEnter:x:y:view:) |
|
3529 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3530 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3531 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3532 |
__MKSMALLINT(ewe->y), |
115 | 3533 |
theView); |
70 | 3534 |
break; |
3535 |
||
3536 |
case LeaveNotify: |
|
115 | 3537 |
(*plS.ilc_func)(self, |
3538 |
@symbol(pointerLeave:view:) |
|
3539 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3540 |
__MKSMALLINT(lwe->state), |
115 | 3541 |
theView); |
70 | 3542 |
break; |
3543 |
||
3544 |
case GraphicsExpose: |
|
115 | 3545 |
(*gexpS.ilc_func)(self, |
3546 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3547 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3548 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3549 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3550 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3551 |
__MKSMALLINT(ee->height), |
115 | 3552 |
theView); |
3553 |
||
3554 |
if (ee->count != 0) { |
|
70 | 3555 |
break; |
3556 |
} |
|
115 | 3557 |
/* fall into */ |
3558 |
||
3559 |
case NoExpose: |
|
3560 |
(*nexpS.ilc_func)(self, |
|
3561 |
@symbol(noExposeView:) |
|
3562 |
COMMA_CON, nil, &nexpS, |
|
3563 |
theView); |
|
3564 |
break; |
|
3565 |
||
3566 |
case Expose: |
|
3567 |
(*expS.ilc_func)(self, |
|
3568 |
@symbol(exposeX:y:width:height:view:) |
|
3569 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3570 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3571 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3572 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3573 |
__MKSMALLINT(ee->height), |
115 | 3574 |
theView); |
70 | 3575 |
break; |
3576 |
||
3577 |
case ConfigureNotify: |
|
3578 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3579 |
siblingID = __MKOBJ(ce->above); |
70 | 3580 |
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
|
3581 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3582 |
} |
3583 |
||
115 | 3584 |
(*confS.ilc_func)(self, |
3585 |
@symbol(configureX:y:width:height:view:) |
|
3586 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3587 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3588 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3589 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3590 |
__MKSMALLINT(ce->height), |
115 | 3591 |
theView); |
70 | 3592 |
if (sibling != nil) { |
115 | 3593 |
(*coveredS.ilc_func)(self, |
3594 |
@symbol(coveredBy:view:) |
|
3595 |
COMMA_CON, nil, &coveredS, |
|
3596 |
theView, |
|
3597 |
sibling); |
|
70 | 3598 |
} |
3599 |
break; |
|
3600 |
||
3601 |
case ClientMessage: |
|
555 | 3602 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
3603 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3604 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
115 | 3605 |
(*termS.ilc_func)(self, |
3606 |
@symbol(terminateView:) |
|
3607 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3608 |
break; |
3609 |
} |
|
555 | 3610 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
115 | 3611 |
(*savtermS.ilc_func)(self, |
3612 |
@symbol(saveAndTerminateView:) |
|
3613 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3614 |
break; |
3615 |
} |
|
3616 |
} |
|
3617 |
break; |
|
3618 |
||
3619 |
case DestroyNotify: |
|
115 | 3620 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3621 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3622 |
break; |
3623 |
||
3624 |
case UnmapNotify: |
|
115 | 3625 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3626 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3627 |
break; |
3628 |
||
3629 |
case MapNotify: |
|
115 | 3630 |
(*mapS.ilc_func)(self, |
3631 |
@symbol(mappedView:) |
|
3632 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3633 |
break; |
3634 |
||
3635 |
case KeymapNotify: |
|
115 | 3636 |
(*keymap.ilc_func)(theView, |
3637 |
@symbol(keyMapChange) |
|
3638 |
COMMA_CON, nil, &keymap); |
|
70 | 3639 |
break; |
3640 |
||
3641 |
case VisibilityNotify: |
|
3642 |
switch (ve->state) { |
|
3643 |
case VisibilityUnobscured: |
|
3644 |
arg = @symbol(unobscured); |
|
3645 |
break; |
|
3646 |
case VisibilityPartiallyObscured: |
|
3647 |
arg = @symbol(partiallyObscured); |
|
3648 |
break; |
|
3649 |
case VisibilityFullyObscured: |
|
3650 |
arg = @symbol(fullyObscured); |
|
3651 |
break; |
|
3652 |
} |
|
3653 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3654 |
break; |
|
3655 |
||
3656 |
case CreateNotify: |
|
3657 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3658 |
break; |
|
3659 |
||
3660 |
case MapRequest: |
|
3661 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3662 |
break; |
|
3663 |
||
3664 |
case ReparentNotify: |
|
3665 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3666 |
break; |
|
3667 |
||
3668 |
case ConfigureRequest: |
|
3669 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3670 |
break; |
|
3671 |
||
3672 |
case GravityNotify: |
|
3673 |
case ResizeRequest: |
|
3674 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3675 |
break; |
|
3676 |
||
3677 |
case CirculateNotify: |
|
3678 |
case CirculateRequest: |
|
3679 |
break; |
|
3680 |
||
3681 |
case PropertyNotify: |
|
115 | 3682 |
(*prop.ilc_func)(theView, |
3683 |
@symbol(propertyChange) |
|
3684 |
COMMA_CON, nil, &prop); |
|
70 | 3685 |
break; |
3686 |
||
3687 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3688 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3689 |
(*selClear.ilc_func)(theView, |
129 | 3690 |
@symbol(selectionClear:) |
3691 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3692 |
selectionID); |
70 | 3693 |
break; |
3694 |
||
90 | 3695 |
case SelectionNotify: |
3696 |
/* |
|
3697 |
* returned selection value (answer from SelectionRequest) |
|
3698 |
*/ |
|
129 | 3699 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3700 |
ev->xselection.property, ev->xselection.target, |
3701 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3702 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3703 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3704 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3705 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3706 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3707 |
(*selNotify.ilc_func)(theView, |
3708 |
@symbol(selectionNotify:target:selection:from:) |
|
3709 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3710 |
propertyID, targetID, selectionID, requestorID); |
70 | 3711 |
break; |
3712 |
||
90 | 3713 |
case SelectionRequest: |
129 | 3714 |
/* |
3715 |
* someone wants the selection |
|
3716 |
*/ |
|
3717 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3718 |
ev->xselectionrequest.property, |
3719 |
ev->xselectionrequest.target, |
|
3720 |
ev->xselectionrequest.selection, |
|
3721 |
ev->xselectionrequest.requestor)); |
|
129 | 3722 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3723 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3724 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3725 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3726 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3727 |
(*selReq.ilc_func)(theView, |
3728 |
@symbol(selectionRequest:target:selection:from:) |
|
3729 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3730 |
propertyID, targetID, selectionID, requestorID); |
70 | 3731 |
break; |
3732 |
||
3733 |
case ColormapNotify: |
|
115 | 3734 |
(*colormap.ilc_func)(theView, |
3735 |
@symbol(colorMapChange) |
|
3736 |
COMMA_CON, nil, &colormap); |
|
70 | 3737 |
break; |
3738 |
||
3739 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3740 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3741 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3742 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3743 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3744 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3745 |
arg = @symbol(mappingKeyboard); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3746 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3747 |
case MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3748 |
arg = @symbol(mappingPointer); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3749 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3750 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3751 |
arg = nil; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3752 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3753 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3754 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3755 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3756 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3757 |
break; |
0 | 3758 |
} |
135 | 3759 |
#undef ae |
0 | 3760 |
#undef ee |
3761 |
#undef ke |
|
3762 |
#undef be |
|
3763 |
#undef ce |
|
3764 |
#undef me |
|
3765 |
#undef ewe |
|
3766 |
#undef lwe |
|
3767 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3768 |
#undef mape |
0 | 3769 |
%} |
3770 |
. |
|
3771 |
^ true |
|
3772 |
! |
|
3773 |
||
295 | 3774 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3775 |
"central event handling method for modal operation. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3776 |
(i.e. this is now only used in the modal debugger) |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3777 |
This code is somewhat special, since X has a concept of graphic |
295 | 3778 |
expose events (which are sent after a bitblt). After such a bitblt, |
3779 |
we only handle exposes until the graphicsExpose arrives. |
|
3780 |
Other systems may not need such a kludge" |
|
3781 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3782 |
"interested in exposes only ?" |
295 | 3783 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3784 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3785 |
self dispatchExposeEventFor:dispatchingExpose |
3786 |
]. |
|
3787 |
^ self |
|
3788 |
]. |
|
3789 |
||
3790 |
"no, general dispatch" |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3791 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3792 |
self dispatchEventFor:nil withMask:nil |
3793 |
] |
|
3794 |
! |
|
3795 |
||
81 | 3796 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3797 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3798 |
events matching the mask are thrown away regardless of which |
|
3799 |
view they are for. Otherwise, only matching events for that |
|
3800 |
view are flushed." |
|
0 | 3801 |
|
3802 |
%{ /* NOCONTEXT */ |
|
3803 |
||
3804 |
Display *dpy = myDpy; |
|
3805 |
XEvent ev; |
|
3806 |
Window win; |
|
3807 |
||
97 | 3808 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3809 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3810 |
win = _WindowVal(aWindowIdOrNil); |
555 | 3811 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
81 | 3812 |
} else { |
555 | 3813 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
81 | 3814 |
} |
70 | 3815 |
RETURN ( self ); |
0 | 3816 |
} |
3817 |
%} |
|
3818 |
. |
|
3819 |
self primitiveFailed |
|
3820 |
! |
|
3821 |
||
295 | 3822 |
eventMaskFor:anEventSymbol |
3823 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3824 |
||
3825 |
%{ /* NOCONTEXT */ |
|
3826 |
||
3827 |
int m = 0; |
|
3828 |
||
3829 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3830 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3831 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3832 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3833 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3834 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3835 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3836 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3837 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3838 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3839 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3840 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3841 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3842 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3843 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3844 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3845 |
RETURN (__MKSMALLINT(m)); |
295 | 3846 |
%} |
3847 |
! |
|
3848 |
||
12 | 3849 |
eventPending |
310 | 3850 |
"return true, if any event is pending. |
3851 |
This looks for both the internal queue and the display connection." |
|
12 | 3852 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3853 |
ConservativeSyncing == true ifTrue:[self sync]. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3854 |
|
12 | 3855 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3856 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3857 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3858 |
^ self eventPendingWithSync:false |
0 | 3859 |
! |
3860 |
||
295 | 3861 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3862 |
"return true, if a specific event is pending" |
|
3863 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3864 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3865 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3866 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3867 |
eventPendingWithSync:doSync |
7 | 3868 |
"return true, if any event is pending. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3869 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3870 |
before checking." |
0 | 3871 |
|
12 | 3872 |
%{ /* UNLIMITEDSTACK */ |
0 | 3873 |
|
3874 |
Display *dpy = myDpy; |
|
3875 |
||
150 | 3876 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3877 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3878 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3879 |
} |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3880 |
if (XPending(dpy)) { |
150 | 3881 |
RETURN (true); |
3882 |
} |
|
3883 |
} |
|
3884 |
RETURN ( false ); |
|
0 | 3885 |
%} |
3886 |
! |
|
3887 |
||
341 | 3888 |
eventQueued |
3889 |
"return true, if any event is queued" |
|
3890 |
||
3891 |
dispatchingExpose notNil ifTrue:[ |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3892 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3893 |
]. |
3894 |
^ self eventQueuedAlready |
|
3895 |
||
3896 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3897 |
! |
|
3898 |
||
3899 |
eventQueuedAlready |
|
3900 |
"return true, if any event is queued internally. |
|
3901 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3902 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3903 |
the display connection)." |
|
3904 |
||
3905 |
%{ /* UNLIMITEDSTACK */ |
|
3906 |
||
3907 |
if (ISCONNECTED) { |
|
3908 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3909 |
RETURN (true); |
|
3910 |
} |
|
3911 |
} |
|
3912 |
RETURN ( false ); |
|
3913 |
%} |
|
3914 |
! |
|
3915 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3916 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3917 |
"return true, if any of the masked events is pending" |
3918 |
||
3919 |
%{ /* UNLIMITEDSTACK */ |
|
3920 |
||
3921 |
Display *dpy = myDpy; |
|
3922 |
XEvent ev; |
|
3923 |
Window win; |
|
3924 |
int thereIsOne; |
|
3925 |
||
3926 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3927 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3928 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3929 |
} |
295 | 3930 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3931 |
win = _WindowVal(aWindowIdOrNil); |
|
555 | 3932 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
295 | 3933 |
} else { |
555 | 3934 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
295 | 3935 |
} |
3936 |
if (thereIsOne) { |
|
3937 |
XPutBackEvent(dpy, &ev); |
|
3938 |
RETURN ( true ); |
|
3939 |
} |
|
3940 |
} |
|
3941 |
RETURN ( false ); |
|
3942 |
%} |
|
3943 |
! |
|
3944 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3945 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3946 |
"return true, if any expose event is pending for a specific view, |
3947 |
or any view (if the arg is nil). |
|
3948 |
This is an X specific, only required after a scroll operation." |
|
7 | 3949 |
|
12 | 3950 |
%{ /* UNLIMITEDSTACK */ |
7 | 3951 |
|
3952 |
Display *dpy = myDpy; |
|
3953 |
XEvent ev; |
|
3954 |
Window win; |
|
81 | 3955 |
int thereIsOne; |
3956 |
||
150 | 3957 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3958 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3959 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3960 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3961 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3962 |
win = _WindowVal(aWindowIdOrNil); |
3963 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3964 |
} else { |
|
3965 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3966 |
} |
|
3967 |
if (thereIsOne) { |
|
3968 |
XPutBackEvent(dpy, &ev); |
|
3969 |
RETURN ( true ); |
|
3970 |
} |
|
81 | 3971 |
} |
3972 |
RETURN ( false ); |
|
3973 |
%} |
|
3974 |
! |
|
3975 |
||
295 | 3976 |
getEventFor:aViewIdOrNil withMask:eventMask |
3977 |
"read next event - put into local eventBuffer. |
|
3978 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3979 |
otherwise only events for that specific view will be fetched. |
|
3980 |
Returns true, if there was an event, false otherwise. |
|
3981 |
This method may block - so you better check for pending events |
|
3982 |
before calling for it. |
|
3983 |
||
3984 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3985 |
handle method to allow unlimitedstack here. |
|
3986 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3987 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3988 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3989 |
display connections. |
|
3990 |
" |
|
81 | 3991 |
|
3992 |
%{ /* UNLIMITEDSTACK */ |
|
3993 |
||
3994 |
Display *dpy = myDpy; |
|
295 | 3995 |
Window win, wWanted; |
3996 |
int evMask; |
|
3997 |
OBJ eB; |
|
3998 |
XEvent *ev; |
|
3999 |
||
4000 |
if (! ISCONNECTED) { |
|
4001 |
RETURN (false); |
|
4002 |
} |
|
4003 |
||
555 | 4004 |
eB = __INST(eventBuffer); |
295 | 4005 |
if (__isByteArray(eB)) { |
555 | 4006 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4007 |
} else { |
4008 |
printf("DISPLAY: no eventBuffer\n"); |
|
4009 |
RETURN (false); |
|
4010 |
} |
|
4011 |
ev->type = 0; |
|
4012 |
||
4013 |
if (__isSmallInteger(eventMask)) { |
|
555 | 4014 |
evMask = __intVal(eventMask); |
295 | 4015 |
} else { |
4016 |
evMask = ~0; |
|
4017 |
} |
|
4018 |
||
4019 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
4020 |
wWanted = _WindowVal(aViewIdOrNil); |
|
4021 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 4022 |
RETURN ( true ); |
4023 |
} |
|
295 | 4024 |
} else { |
4025 |
if (evMask == ~0) { |
|
4026 |
XNextEvent(dpy, ev); |
|
4027 |
RETURN (true); |
|
4028 |
} |
|
4029 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
4030 |
RETURN (true); |
|
4031 |
} |
|
4032 |
} |
|
4033 |
%}. |
|
4034 |
^ false |
|
4035 |
! |
|
4036 |
||
4037 |
handleAllEvents |
|
4038 |
"from now on, handle any kind of event" |
|
4039 |
||
4040 |
dispatchingExpose := nil |
|
4041 |
! |
|
4042 |
||
4043 |
handleExposeOnlyFor:aView |
|
4044 |
"from now on, handle expose events only" |
|
4045 |
||
4046 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4047 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4048 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4049 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4050 |
"One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4051 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4052 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4053 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4054 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4055 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4056 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4057 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4058 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4059 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4060 |
! |
4061 |
||
4062 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4063 |
"tell X that we are only interested in events from aMask, which |
295 | 4064 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4065 |
||
4066 |
%{ /* NOCONTEXT */ |
|
4067 |
||
4068 |
int mask; |
|
4069 |
||
4070 |
if (__isExternalAddress(aWindowId) |
|
4071 |
&& __isSmallInteger(aMask)) { |
|
555 | 4072 |
mask = __intVal(aMask); |
295 | 4073 |
|
4074 |
#ifdef OLD |
|
4075 |
/* these may not be disabled */ |
|
4076 |
mask |= ExposureMask | StructureNotifyMask | |
|
4077 |
KeyPressMask | KeyReleaseMask | |
|
4078 |
EnterWindowMask | LeaveWindowMask | |
|
4079 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
4080 |
#endif |
|
4081 |
||
4082 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
4083 |
RETURN ( self ); |
|
4084 |
} |
|
4085 |
%} |
|
4086 |
. |
|
4087 |
self primitiveFailed |
|
4088 |
! |
|
4089 |
||
4090 |
startDispatch |
|
4091 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
4092 |
||
4093 |
dispatching ifTrue:[^ self]. |
|
4094 |
dispatchingExpose := nil. |
|
4095 |
super startDispatch |
|
0 | 4096 |
! ! |
295 | 4097 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4098 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4099 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4100 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4101 |
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4102 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4103 |
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4104 |
for key events, it can be either a symbol (as listen in X's keySyms) |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4105 |
or a numeric keysym code. If state is nil, the modifier bits (shift & control) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4106 |
are computed from the keyboardMap - if non-nil, these are passed as modifierbits. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4107 |
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4108 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4109 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4110 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4111 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4112 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4113 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4114 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4115 |
if (__isSmallInteger(stateMask)) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4116 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4117 |
} else { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4118 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4119 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4120 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4121 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4122 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4123 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4124 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4125 |
XEvent ev; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4126 |
Window target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4127 |
Status result; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4128 |
KeySym keySym, *syms; |
555 | 4129 |
int screen = __intVal(__INST(screen)); |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4130 |
char s[2]; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4131 |
int nSyms; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4132 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4133 |
if ((typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4134 |
|| (typeSymbol == @symbol(keyRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4135 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4136 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4137 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4138 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4139 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4140 |
s[1] = '\0'; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4141 |
keySym = XStringToKeysym(s); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4142 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4143 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4144 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4145 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4146 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4147 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4148 |
if (stateMask == nil) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4149 |
/* |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4150 |
* get the modifier from the keySym |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4151 |
*/ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4152 |
nSyms = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4153 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4154 |
if (syms) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4155 |
int i; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4156 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4157 |
for (i=0; i<nSyms; i++) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4158 |
if (syms[i] == keySym) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4159 |
#ifdef MODIFIERDEBUG |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4160 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4161 |
#endif |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4162 |
if (i) state = (1 << (i-1)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4163 |
break; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4164 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4165 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4166 |
XFree(syms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4167 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4168 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4169 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4170 |
if ((typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4171 |
|| (typeSymbol == @symbol(buttonRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4172 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4173 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4174 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4175 |
ev.xbutton.button = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4176 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4177 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4178 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4179 |
RETURN (false); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4180 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4181 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4182 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4183 |
if (typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4184 |
ev.xany.type = KeyPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4185 |
else if (typeSymbol == @symbol(keyRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4186 |
ev.xany.type = KeyRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4187 |
else if (typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4188 |
ev.xany.type = ButtonPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4189 |
else if (typeSymbol == @symbol(buttonRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4190 |
ev.xany.type = ButtonRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4191 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4192 |
if (__isExternalAddress(targetId)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4193 |
target = _WindowVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4194 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4195 |
target = (Window) __longIntVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4196 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4197 |
ev.xkey.window = target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4198 |
ev.xkey.same_screen = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4199 |
ev.xkey.subwindow = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4200 |
ev.xkey.root = RootWindow(myDpy, screen); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4201 |
ev.xkey.x = __intVal(xPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4202 |
ev.xkey.y = __intVal(yPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4203 |
ev.xkey.state = state; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4204 |
ev.xkey.time = CurrentTime; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4205 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4206 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4207 |
if ((result == BadValue) || (result == BadWindow)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4208 |
DPRINTF(("bad status\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4209 |
RETURN ( false ) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4210 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4211 |
RETURN (true) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4212 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4213 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4214 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4215 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4216 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4217 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4218 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4219 |
"send input to some other view, by simulating keyPress/keyRelease |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4220 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4221 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4222 |
Notice: not all alien views allow this kind of synthetic input; |
850 | 4223 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4224 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4225 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4226 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4227 |
aCharacterOrString isString ifTrue:[ |
850 | 4228 |
aCharacterOrString do:[:char | |
4229 |
self simulateKeyboardInput:char inViewId:viewId |
|
4230 |
]. |
|
4231 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4232 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4233 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4234 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4235 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4236 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4237 |
(aCharacterOrString == Character cr) ifTrue:[ |
850 | 4238 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4239 |
] ifFalse:[ |
850 | 4240 |
(aCharacterOrString == Character tab) ifTrue:[ |
4241 |
code := #Tab |
|
4242 |
] ifFalse:[ |
|
4243 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4244 |
code := #Escape |
|
4245 |
] |
|
4246 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4247 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4248 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4249 |
control ifTrue:[ |
850 | 4250 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4251 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4252 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4253 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4254 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4255 |
"/ (sendKeyOrButtonevent should be able to figure out things itself) |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4256 |
"/ however, on some linux systems it seems to not work correctly. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4257 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4258 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4259 |
code isNumber ifTrue:[ |
850 | 4260 |
code >= $A asciiValue ifTrue:[ |
4261 |
code <= $Z asciiValue ifTrue:[ |
|
4262 |
state := self shiftMask |
|
4263 |
] |
|
4264 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4265 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4266 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4267 |
self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4268 |
self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4269 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4270 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4271 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4272 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4273 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4274 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4275 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4276 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4277 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4278 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4279 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4280 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4281 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4282 |
|
295 | 4283 |
!XWorkstation methodsFor:'font stuff'! |
4284 |
||
4285 |
ascentOf:aFontId |
|
4286 |
"the normal ascent" |
|
4287 |
||
4288 |
%{ /* NOCONTEXT */ |
|
4289 |
||
4290 |
XFontStruct *f; |
|
4291 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4292 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4293 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4294 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4295 |
RETURN ( __MKSMALLINT(f->ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4296 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4297 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4298 |
%}. |
295 | 4299 |
self primitiveFailed. |
4300 |
^ nil |
|
4301 |
! |
|
4302 |
||
4303 |
createFontFor:aFontName |
|
4304 |
"a basic method for X-font allocation; this method allows |
|
4305 |
any font to be aquired (even those not conforming to |
|
4306 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4307 |
||
4308 |
%{ /* UNLIMITEDSTACK */ |
|
4309 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4310 |
||
4311 |
XFontStruct *newFont; |
|
4312 |
||
4313 |
if (ISCONNECTED) { |
|
4314 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4315 |
BEGIN_INTERRUPTSBLOCKED |
|
4316 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4317 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4318 |
if (newFont) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4319 |
__cnt_font++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4320 |
#endif |
295 | 4321 |
END_INTERRUPTSBLOCKED |
4322 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4323 |
} |
|
4324 |
} |
|
4325 |
%}. |
|
4326 |
^ nil |
|
4327 |
! |
|
4328 |
||
4329 |
decomposeXFontName:aString into:aBlock |
|
4330 |
"extract family, face, style and size from an |
|
4331 |
X-font name |
|
4332 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4333 |
evaluate aBlock with these" |
|
4334 |
||
4335 |
|origin family face style moreStyle skip fheight size |
|
4336 |
resX resY x1 x2 coding start end | |
|
4337 |
||
4338 |
aString isNil ifTrue:[^ false]. |
|
4339 |
(aString startsWith:'-') ifFalse:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4340 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4341 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4342 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4343 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4344 |
end := aString indexOf:$- startingAt:1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4345 |
family := aString copyFrom:1 to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4346 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4347 |
end := aString indexOf:$- startingAt:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4348 |
style := aString copyFrom:start to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4349 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4350 |
size := aString copyFrom:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4351 |
size := (Number readFromString:size onError:[^false]). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4352 |
aBlock value:family value:nil value:style value:size value:nil. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4353 |
^ true. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4354 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4355 |
('*-[0-9]*' match:aString) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4356 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4357 |
something like lucidasans-24 |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4358 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4359 |
end := aString indexOf:$- startingAt:1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4360 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4361 |
family := aString copyFrom:1 to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4362 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4363 |
size := aString copyFrom:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4364 |
size := (Number readFromString:size onError:[^false]). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4365 |
aBlock value:family value:nil value:nil value:size value:nil. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4366 |
^ true. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4367 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4368 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4369 |
^ true. |
295 | 4370 |
]. |
4371 |
||
4372 |
end := aString indexOf:$- startingAt:2. |
|
4373 |
(end == 0) ifTrue:[^ false]. |
|
4374 |
origin := aString copyFrom:2 to:(end - 1). |
|
4375 |
||
4376 |
start := end + 1. |
|
4377 |
end := aString indexOf:$- startingAt:start. |
|
4378 |
(end == 0) ifTrue:[^ false]. |
|
4379 |
family := aString copyFrom:start to:(end - 1). |
|
4380 |
||
4381 |
start := end + 1. |
|
4382 |
end := aString indexOf:$- startingAt:start. |
|
4383 |
(end == 0) ifTrue:[^ false]. |
|
4384 |
face := aString copyFrom:start to:(end - 1). |
|
4385 |
||
4386 |
start := end + 1. |
|
4387 |
end := aString indexOf:$- startingAt:start. |
|
4388 |
(end == 0) ifTrue:[^ false]. |
|
4389 |
style := aString copyFrom:start to:(end - 1). |
|
4390 |
(style = 'o') ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4391 |
style := 'oblique' |
295 | 4392 |
] ifFalse:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4393 |
(style = 'i') ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4394 |
style := 'italic' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4395 |
] ifFalse:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4396 |
(style = 'r') ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4397 |
style := 'roman' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4398 |
] |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4399 |
] |
295 | 4400 |
]. |
4401 |
||
4402 |
start := end + 1. |
|
4403 |
end := aString indexOf:$- startingAt:start. |
|
4404 |
(end == 0) ifTrue:[^ false]. |
|
4405 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4406 |
||
4407 |
start := end + 1. |
|
4408 |
end := aString indexOf:$- startingAt:start. |
|
4409 |
(end == 0) ifTrue:[^ false]. |
|
4410 |
skip := aString copyFrom:start to:(end - 1). |
|
4411 |
||
4412 |
start := end + 1. |
|
4413 |
end := aString indexOf:$- startingAt:start. |
|
4414 |
(end == 0) ifTrue:[^ false]. |
|
4415 |
fheight := aString copyFrom:start to:(end - 1). |
|
4416 |
||
4417 |
start := end + 1. |
|
4418 |
end := aString indexOf:$- startingAt:start. |
|
4419 |
(end == 0) ifTrue:[^ false]. |
|
4420 |
size := aString copyFrom:start to:(end - 1). |
|
4421 |
size := (Number readFromString:size) / 10. |
|
4422 |
||
4423 |
start := end + 1. |
|
4424 |
end := aString indexOf:$- startingAt:start. |
|
4425 |
(end == 0) ifTrue:[^ false]. |
|
4426 |
resX := aString copyFrom:start to:(end - 1). |
|
4427 |
||
4428 |
start := end + 1. |
|
4429 |
end := aString indexOf:$- startingAt:start. |
|
4430 |
(end == 0) ifTrue:[^ false]. |
|
4431 |
resY := aString copyFrom:start to:(end - 1). |
|
4432 |
||
4433 |
start := end + 1. |
|
4434 |
end := aString indexOf:$- startingAt:start. |
|
4435 |
(end == 0) ifTrue:[^ false]. |
|
4436 |
x1 := aString copyFrom:start to:(end - 1). |
|
4437 |
||
4438 |
start := end + 1. |
|
4439 |
end := aString indexOf:$- startingAt:start. |
|
4440 |
(end == 0) ifTrue:[^ false]. |
|
4441 |
x2 := aString copyFrom:start to:(end - 1). |
|
4442 |
||
4443 |
start := end + 1. |
|
4444 |
end := aString indexOf:$- startingAt:start. |
|
4445 |
(end == 0) ifTrue:[^ false]. |
|
4446 |
coding := aString copyFrom:start to:(end - 1). |
|
4447 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4448 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4449 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4450 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4451 |
|
295 | 4452 |
aBlock value:family value:face value:style value:size value:coding. |
4453 |
^ true |
|
4454 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4455 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 4456 |
! |
4457 |
||
4458 |
descentOf:aFontId |
|
4459 |
"the normal descent" |
|
4460 |
||
4461 |
%{ /* NOCONTEXT */ |
|
4462 |
||
4463 |
XFontStruct *f; |
|
4464 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4465 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4466 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4467 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4468 |
RETURN ( __MKSMALLINT(f->descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4469 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4470 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4471 |
%}. |
295 | 4472 |
self primitiveFailed. |
4473 |
^ nil |
|
4474 |
! |
|
4475 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4476 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4477 |
"the fonts encoding - if the font does not provide that info, |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4478 |
return nil (and assume #ascii, which is a subset of #iso8859)." |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4479 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4480 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4481 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4482 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4483 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4484 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4485 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4486 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4487 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4488 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4489 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4490 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4491 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4492 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4493 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4494 |
if (ISCONNECTED) { |
850 | 4495 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4496 |
|
850 | 4497 |
f = _FontVal(aFontId); |
4498 |
if (f) { |
|
4499 |
n = f->n_properties; |
|
4500 |
prop = f->properties; |
|
4501 |
if (prop) { |
|
4502 |
while (n--) { |
|
4503 |
cp = XGetAtomName(myDpy, prop->name); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4504 |
#ifdef SUPERDEBUG |
850 | 4505 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4506 |
#endif |
850 | 4507 |
if (prop->name == XA_FULL_NAME) { |
4508 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4509 |
if (cp) { |
|
4510 |
fullName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4511 |
#ifdef SUPERDEBUG |
850 | 4512 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4513 |
#endif |
850 | 4514 |
} |
4515 |
} |
|
4516 |
if (prop->name == fontAtom) { |
|
4517 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4518 |
if (cp) { |
|
4519 |
fontName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4520 |
#ifdef SUPERDEBUG |
850 | 4521 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4522 |
#endif |
850 | 4523 |
} |
4524 |
} |
|
4525 |
if (prop->name == encodingAtom) { |
|
4526 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4527 |
if (cp) { |
|
4528 |
encoding = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4529 |
#ifdef SUPERDEBUG |
850 | 4530 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4531 |
#endif |
850 | 4532 |
} |
4533 |
} |
|
4534 |
if (prop->name == registryAtom) { |
|
4535 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4536 |
if (cp) { |
|
4537 |
registry = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4538 |
#ifdef SUPERDEBUG |
850 | 4539 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4540 |
#endif |
850 | 4541 |
} |
4542 |
} |
|
4543 |
if (prop->name == charSetCollAtom) { |
|
4544 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4545 |
if (cp) { |
|
4546 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4547 |
#ifdef SUPERDEBUG |
850 | 4548 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4549 |
#endif |
850 | 4550 |
} |
4551 |
} |
|
4552 |
prop++; |
|
4553 |
} |
|
4554 |
} |
|
4555 |
} |
|
4556 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4557 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4558 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4559 |
^ self |
850 | 4560 |
extractEncodingFromRegistry:registry |
4561 |
encoding:encoding |
|
4562 |
charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4563 |
! |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4564 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4565 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4566 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4567 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4568 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4569 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4570 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
850 | 4571 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4572 |
] ifFalse:[ |
850 | 4573 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4574 |
enc := encoding asLowercase asSymbol |
|
4575 |
] ifFalse:[ |
|
4576 |
charSets := charSetCollections. |
|
4577 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
4578 |
charSets := charSets asUppercase asCollectionOfWords. |
|
4579 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
4580 |
enc := #iso8859 |
|
4581 |
] ifFalse:[ |
|
4582 |
(charSets includes:'ISO8859') ifTrue:[ |
|
4583 |
enc := #iso8859 |
|
4584 |
] ifFalse:[ |
|
4585 |
(charSets includes:'ASCII') ifTrue:[ |
|
4586 |
enc := #ascii |
|
4587 |
] ifFalse:[ |
|
4588 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
4589 |
enc := #iso8859 |
|
4590 |
] |
|
4591 |
] |
|
4592 |
] |
|
4593 |
] |
|
4594 |
] |
|
4595 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4596 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4597 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4598 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4599 |
"Created: 17.4.1996 / 14:57:06 / cg" |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4600 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4601 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4602 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4603 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4604 |
"flush the cached list of all available fonts on this display. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4605 |
Required if new fonts have been added on the display server." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4606 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4607 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4608 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4609 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4610 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4611 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4612 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4613 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4614 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4615 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4616 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4617 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4618 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4619 |
"the fonts fullName - this is very device specific and should only be |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4620 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4621 |
If the display/font do not provide that info, return nil." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4622 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4623 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4624 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4625 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4626 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4627 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4628 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4629 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4630 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4631 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4632 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4633 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4634 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4635 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4636 |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4637 |
f = _FontVal(aFontId); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4638 |
if (f) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4639 |
n = f->n_properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4640 |
prop = f->properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4641 |
if (prop) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4642 |
while (n--) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4643 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4644 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4645 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4646 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4647 |
if (prop->name == XA_FULL_NAME) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4648 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4649 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4650 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4651 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4652 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4653 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4654 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4655 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4656 |
if (prop->name == fontAtom) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4657 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4658 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4659 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4660 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4661 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4662 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4663 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4664 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4665 |
prop++; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4666 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4667 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4668 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4669 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4670 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4671 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4672 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4673 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4674 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4675 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4676 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4677 |
|
295 | 4678 |
getAvailableFontsMatching:pattern |
4679 |
"return an Array filled with font names matching aPattern" |
|
4680 |
||
4681 |
%{ /* UNLIMITEDSTACK */ |
|
4682 |
||
4683 |
int nnames = 1500; |
|
4684 |
int available = nnames + 1; |
|
4685 |
char **fonts; |
|
4686 |
OBJ arr, str; |
|
4687 |
int i; |
|
4688 |
||
4689 |
if (ISCONNECTED) { |
|
4690 |
if (__isString(pattern)) { |
|
4691 |
for (;;) { |
|
4692 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4693 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4694 |
XFreeFontNames(fonts); |
|
4695 |
nnames = available * 2; |
|
4696 |
} |
|
4697 |
if (fonts == NULL) { |
|
4698 |
RETURN ( nil ); |
|
4699 |
} |
|
4700 |
/* |
|
4701 |
* now, that we know the number of font names, |
|
4702 |
* create the array ... |
|
4703 |
*/ |
|
4704 |
arr = __ARRAY_NEW_INT(available); |
|
4705 |
if (! arr) { |
|
4706 |
RETURN (nil); |
|
4707 |
} |
|
4708 |
/* |
|
4709 |
* ... and fill it |
|
4710 |
*/ |
|
4711 |
for (i=0; i<available; i++) { |
|
350 | 4712 |
__PROTECT__(arr); |
295 | 4713 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4714 |
__UNPROTECT__(arr); |
295 | 4715 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4716 |
} |
|
4717 |
RETURN (arr); |
|
4718 |
} |
|
4719 |
} |
|
4720 |
%}. |
|
4721 |
^ nil |
|
4722 |
! |
|
4723 |
||
4724 |
getDefaultFont |
|
4725 |
"return a default font id - used when class Font cannot |
|
4726 |
find anything usable" |
|
4727 |
||
4728 |
^ self createFontFor:'fixed' |
|
4729 |
! |
|
4730 |
||
4731 |
getFontWithFamily:familyString face:faceString |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4732 |
style:styleArgString size:sizeArg encoding:encodingSym |
295 | 4733 |
|
4734 |
"try to get the specified font, if not available, try next smaller |
|
4735 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4736 |
as family and the other parameters as nil. For example, the cursor font |
|
4737 |
can be aquired that way." |
|
4738 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4739 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4740 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4741 |
styleString := styleArgString. |
295 | 4742 |
|
4743 |
"special: if face is nil, allow access to X-fonts" |
|
4744 |
faceString isNil ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4745 |
sizeArg notNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4746 |
theName := familyString , '-' , sizeArg printString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4747 |
] ifFalse:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4748 |
theName := familyString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4749 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4750 |
theName isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4751 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4752 |
mhmh - fall back to the default font |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4753 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4754 |
theName := 'fixed' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4755 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4756 |
theId := self createFontFor:theName. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4757 |
theId isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4758 |
theId := self getDefaultFont |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4759 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4760 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4761 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4762 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4763 |
"/ spacing other than 'normal' is contained as last component |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4764 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4765 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4766 |
((styleString endsWith:'-narrow') |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4767 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4768 |
|i| |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4769 |
i := styleString lastIndexOf:$-. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4770 |
spacing := styleString copyFrom:(i+1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4771 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4772 |
] ifFalse:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4773 |
spacing := 'normal'. |
295 | 4774 |
]. |
4775 |
||
4776 |
xlatedStyle := styleString. |
|
4777 |
xlatedStyle notNil ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4778 |
xlatedStyle := xlatedStyle first asString |
295 | 4779 |
]. |
4780 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4781 |
id := self |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4782 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4783 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4784 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4785 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4786 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4787 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4788 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4789 |
registry:encodingSym |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4790 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4791 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4792 |
id isNil ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4793 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4794 |
"/ too stupid: encodings come in both cases |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4795 |
"/ and X does not ignore case |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4796 |
"/ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4797 |
id := self |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4798 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4799 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4800 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4801 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4802 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4803 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4804 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4805 |
registry:encodingSym asUppercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4806 |
encoding:'*'. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4807 |
id isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4808 |
id := self |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4809 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4810 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4811 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4812 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4813 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4814 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4815 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4816 |
registry:encodingSym asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4817 |
encoding:'*'. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4818 |
] |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4819 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4820 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4821 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4822 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4823 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4824 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
295 | 4825 |
! |
4826 |
||
4827 |
getFontWithFoundry:foundry family:family weight:weight |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4828 |
slant:slant spacing:spc pixelSize:pSize size:size |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4829 |
registry:registry encoding:encoding |
295 | 4830 |
|
4831 |
"get the specified font, if not available, return nil. |
|
4832 |
This is the new font creation method - all others will be changed to |
|
4833 |
use this entry. |
|
4834 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4835 |
||
4836 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4837 |
family: 'helvetica' 'courier' 'times' ... |
|
4838 |
weight: 'bold' 'medium' 'demi' ... |
|
4839 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4840 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4841 |
pixelSize: 16,18 ... usually left empty |
|
4842 |
size: size in point (1/72th of an inch) |
|
4843 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4844 |
encoding: vendor specific encoding (usually '*') |
295 | 4845 |
" |
4846 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4847 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4848 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4849 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4850 |
id| |
295 | 4851 |
|
4852 |
"this works only on 'Release >= 3' - X-servers" |
|
4853 |
"name is: |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4854 |
-foundry-family -weight -slant- |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4855 |
sony helvetica bold r |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4856 |
adobe courier medium i |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4857 |
msic fixed o |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4858 |
... ... |
295 | 4859 |
" |
4860 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4861 |
size isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4862 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4863 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4864 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4865 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4866 |
foundry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4867 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4868 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4869 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4870 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4871 |
family isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4872 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4873 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4874 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4875 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4876 |
weight isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4877 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4878 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4879 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4880 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4881 |
slant isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4882 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4883 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4884 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4885 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4886 |
spc isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4887 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4888 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4889 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4890 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4891 |
pSize isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4892 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4893 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4894 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4895 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4896 |
registry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4897 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4898 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4899 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4900 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4901 |
encoding isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4902 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4903 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4904 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4905 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4906 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4907 |
theName := ('-' , foundryMatch, |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4908 |
'-' , familyMatch, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4909 |
'-' , weightMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4910 |
'-' , slantMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4911 |
'-' , spcMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4912 |
'-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4913 |
'-' , pSizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4914 |
'-' , sizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4915 |
'-*-*-*-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4916 |
'-' , registryMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4917 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4918 |
|
697 | 4919 |
"/ Transcript showCR:theName; endEntry. |
295 | 4920 |
|
4921 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4922 |
|
295 | 4923 |
|
4924 |
" |
|
4925 |
Display getFontWithFoundry:'*' |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4926 |
family:'courier' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4927 |
weight:'medium' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4928 |
slant:'r' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4929 |
spacing:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4930 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4931 |
size:13 |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4932 |
registry:'iso8859' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4933 |
encoding:'*' |
295 | 4934 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4935 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4936 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4937 |
! |
4938 |
||
4939 |
listOfAvailableFonts |
|
4940 |
"return a list with all available fonts on this display. |
|
4941 |
Since this takes a long time, keep the result of the query for the |
|
4942 |
next time. The elements of the returned collection are instances of |
|
4943 |
FontDescription." |
|
4944 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4945 |
|"stream aName fntDescr" names| |
295 | 4946 |
|
4947 |
listOfXFonts isNil ifTrue:[ |
|
4948 |
"/ |
|
4949 |
"/ old code; using a pipe to xlsfonts |
|
4950 |
"/ |
|
4951 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4952 |
"/ stream isNil ifTrue:[^ nil]. |
|
4953 |
"/ listOfXFonts := OrderedCollection new. |
|
4954 |
"/ [stream atEnd] whileFalse:[ |
|
4955 |
"/ aName := stream nextLine. |
|
4956 |
"/ aName notNil ifTrue:[ |
|
4957 |
"/ self decomposeXFontName:aName into: |
|
4958 |
"/ [:family :face :style :size :coding | |
|
4959 |
"/ family notNil ifTrue:[ |
|
4960 |
"/ fntDescr := FontDescription |
|
4961 |
"/ family:family |
|
4962 |
"/ face:face |
|
4963 |
"/ style:style |
|
4964 |
"/ size:size |
|
4965 |
"/ encoding:coding. |
|
4966 |
"/ listOfXFonts add:fntDescr |
|
4967 |
"/ ] |
|
4968 |
"/ ] |
|
4969 |
"/ ] |
|
4970 |
"/ ]. |
|
4971 |
"/ stream close. |
|
4972 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4973 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4974 |
"/ listOfXFonts := nil |
|
4975 |
"/ ] ifFalse:[ |
|
4976 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4977 |
"/ ]. |
|
4978 |
||
850 | 4979 |
"/ |
4980 |
"/ new code: |
|
4981 |
"/ use new primitive to get font names; |
|
4982 |
"/ this is much faster, and also works on systems where |
|
4983 |
"/ a) xlsfonts is broken (sco) |
|
4984 |
"/ b) xlsfonts is not available (aix) |
|
4985 |
"/ |
|
4986 |
names := self getAvailableFontsMatching:'*'. |
|
4987 |
names isNil ifTrue:[ |
|
4988 |
"no names returned ..." |
|
4989 |
^ nil |
|
4990 |
]. |
|
4991 |
listOfXFonts := names collect:[:aName | |
|
4992 |
|fntDescr| |
|
4993 |
||
4994 |
(self decomposeXFontName:aName into: |
|
4995 |
[:family :face :style :size :coding | |
|
4996 |
family notNil ifTrue:[ |
|
4997 |
fntDescr := FontDescription |
|
4998 |
family:family |
|
4999 |
face:face |
|
5000 |
style:style |
|
5001 |
size:size |
|
5002 |
encoding:coding. |
|
5003 |
] ifFalse:[ |
|
5004 |
fntDescr := FontDescription |
|
5005 |
name:aName |
|
5006 |
] |
|
5007 |
] |
|
5008 |
) ifFalse:[ |
|
5009 |
fntDescr := FontDescription name:aName. |
|
5010 |
]. |
|
5011 |
fntDescr |
|
5012 |
]. |
|
295 | 5013 |
|
5014 |
]. |
|
5015 |
^ listOfXFonts |
|
5016 |
||
5017 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5018 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5019 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5020 |
Display getAvailableFontsMatching:'*'. |
295 | 5021 |
" |
5022 |
||
5023 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5024 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5025 |
! |
5026 |
||
5027 |
maxAscentOf:aFontId |
|
5028 |
"the max ascent" |
|
5029 |
||
5030 |
%{ /* NOCONTEXT */ |
|
5031 |
||
5032 |
XFontStruct *f; |
|
5033 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5034 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5035 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5036 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5037 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5038 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5039 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5040 |
%}. |
295 | 5041 |
self primitiveFailed. |
5042 |
^ nil |
|
5043 |
! |
|
5044 |
||
5045 |
maxDescentOf:aFontId |
|
5046 |
"the max descent" |
|
5047 |
||
5048 |
%{ /* NOCONTEXT */ |
|
5049 |
||
5050 |
XFontStruct *f; |
|
5051 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5052 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5053 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5054 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5055 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5056 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5057 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5058 |
%}. |
295 | 5059 |
self primitiveFailed. |
5060 |
^ nil |
|
5061 |
! |
|
5062 |
||
5063 |
maxWidthOfFont:aFontId |
|
5064 |
"the width of the widest character" |
|
5065 |
||
5066 |
%{ /* NOCONTEXT */ |
|
5067 |
||
5068 |
XFontStruct *f; |
|
5069 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5070 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5071 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5072 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5073 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5074 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5075 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5076 |
%}. |
295 | 5077 |
self primitiveFailed. |
5078 |
^ nil |
|
5079 |
! |
|
5080 |
||
5081 |
minWidthOfFont:aFontId |
|
5082 |
||
5083 |
%{ /* NOCONTEXT */ |
|
5084 |
||
5085 |
XFontStruct *f; |
|
5086 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5087 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5088 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5089 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5090 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5091 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5092 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5093 |
%}. |
295 | 5094 |
self primitiveFailed. |
5095 |
^ nil |
|
5096 |
! |
|
5097 |
||
5098 |
releaseFont:aFontId |
|
5099 |
||
5100 |
%{ /* NOCONTEXT */ |
|
5101 |
||
5102 |
XFontStruct *f; |
|
5103 |
||
5104 |
if (ISCONNECTED) { |
|
5105 |
if (__isExternalAddress(aFontId)) { |
|
5106 |
f = _FontVal(aFontId); |
|
5107 |
BEGIN_INTERRUPTSBLOCKED |
|
5108 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5109 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
5110 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5111 |
#endif |
295 | 5112 |
END_INTERRUPTSBLOCKED |
5113 |
RETURN ( self ); |
|
5114 |
} |
|
5115 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5116 |
%}. |
295 | 5117 |
self primitiveFailed |
5118 |
! |
|
5119 |
||
466 | 5120 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5121 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5122 |
on this display. |
|
5123 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5124 |
||
5125 |
|sizes| |
|
5126 |
||
466 | 5127 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5128 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5129 |
"special: in X11R5 and above, size 0 means: |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5130 |
there are scaled versions in all sizes available" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5131 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5132 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
295 | 5133 |
]. |
5134 |
^ sizes |
|
5135 |
||
5136 |
" |
|
5137 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5138 |
" |
|
466 | 5139 |
|
5140 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5141 |
! |
5142 |
||
5143 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
5144 |
||
5145 |
%{ /* NOCONTEXT */ |
|
5146 |
||
5147 |
XFontStruct *f; |
|
5148 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5149 |
int len, n, i1, i2, l; |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5150 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5151 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5152 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5153 |
int nInstBytes; |
295 | 5154 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5155 |
if (ISCONNECTED) { |
850 | 5156 |
if (__bothSmallInteger(index1, index2) |
5157 |
&& __isExternalAddress(aFontId) |
|
5158 |
&& __isNonNilObject(aString)) { |
|
5159 |
f = _FontVal(aFontId); |
|
5160 |
i1 = __intVal(index1) - 1; |
|
5161 |
cls = __qClass(aString); |
|
5162 |
||
5163 |
if (i1 >= 0) { |
|
5164 |
i2 = __intVal(index2) - 1; |
|
5165 |
if (i2 < i1) { |
|
5166 |
RETURN (self); |
|
5167 |
} |
|
5168 |
||
5169 |
cp = (char *) _stringVal(aString); |
|
5170 |
l = i2 - i1 + 1; |
|
5171 |
||
5172 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5173 |
n = _stringSize(aString); |
|
5174 |
if (i2 < n) { |
|
5175 |
cp += i1; |
|
5176 |
BEGIN_INTERRUPTSBLOCKED |
|
5177 |
len = XTextWidth(f, cp, l); |
|
5178 |
END_INTERRUPTSBLOCKED |
|
5179 |
RETURN ( __MKSMALLINT(len) ); |
|
5180 |
} |
|
5181 |
} |
|
5182 |
||
5183 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5184 |
cp += nInstBytes; |
|
5185 |
||
5186 |
if (__isBytes(aString)) { |
|
5187 |
n = __byteArraySize(aString) - nInstBytes; |
|
5188 |
if (i2 < n) { |
|
5189 |
cp += i1; |
|
5190 |
BEGIN_INTERRUPTSBLOCKED |
|
5191 |
len = XTextWidth(f, cp, l); |
|
5192 |
END_INTERRUPTSBLOCKED |
|
5193 |
RETURN ( __MKSMALLINT(len) ); |
|
5194 |
} |
|
5195 |
} |
|
5196 |
||
5197 |
/* TWOBYTESTRINGS */ |
|
5198 |
if (__isWords(aString)) { |
|
5199 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5200 |
||
5201 |
if (i2 < n) { |
|
5202 |
union { |
|
5203 |
char b[2]; |
|
5204 |
unsigned short s; |
|
5205 |
} u; |
|
5206 |
int i; |
|
5207 |
XChar2b *cp2 = (XChar2b *)0; |
|
5208 |
int mustFree = 0; |
|
5209 |
||
5210 |
cp += (i1 * 2); |
|
5211 |
if (l > 1000) l = 1000; |
|
5212 |
||
5213 |
/* |
|
5214 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5215 |
* X expects them MSB first |
|
5216 |
* convert as required |
|
5217 |
*/ |
|
5218 |
||
5219 |
u.s = 0x1234; |
|
5220 |
if (u.b[0] != 0x12) { |
|
5221 |
if (l <= NLOCALBUFFER) { |
|
5222 |
cp2 = xlatebuffer; |
|
5223 |
} else { |
|
5224 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5225 |
mustFree = 1; |
|
5226 |
} |
|
5227 |
for (i=0; i<l; i++) { |
|
5228 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5229 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5230 |
} |
|
5231 |
cp = (char *) cp2; |
|
5232 |
} |
|
5233 |
BEGIN_INTERRUPTSBLOCKED |
|
5234 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
5235 |
END_INTERRUPTSBLOCKED |
|
5236 |
||
5237 |
if (mustFree) { |
|
5238 |
free(cp2); |
|
5239 |
} |
|
5240 |
||
5241 |
RETURN ( __MKSMALLINT(len) ); |
|
5242 |
} |
|
5243 |
} |
|
5244 |
} |
|
5245 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5246 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5247 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5248 |
%}. |
295 | 5249 |
self primitiveFailed. |
5250 |
^ nil |
|
5251 |
! |
|
5252 |
||
5253 |
widthOf:aString inFont:aFontId |
|
5254 |
||
5255 |
%{ /* NOCONTEXT */ |
|
5256 |
||
5257 |
XFontStruct *f; |
|
5258 |
char *cp; |
|
5259 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5260 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5261 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5262 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5263 |
int nInstBytes; |
295 | 5264 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5265 |
if (ISCONNECTED) { |
850 | 5266 |
if (__isExternalAddress(aFontId) |
5267 |
&& __isNonNilObject(aString)) { |
|
5268 |
f = _FontVal(aFontId); |
|
5269 |
cls = __qClass(aString); |
|
5270 |
||
5271 |
cp = (char *)_stringVal(aString); |
|
5272 |
||
5273 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5274 |
n = _stringSize(aString); |
|
5275 |
BEGIN_INTERRUPTSBLOCKED |
|
5276 |
len = XTextWidth(f, cp, n); |
|
5277 |
END_INTERRUPTSBLOCKED |
|
5278 |
RETURN ( __MKSMALLINT(len) ); |
|
5279 |
} |
|
5280 |
||
5281 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5282 |
cp += nInstBytes; |
|
5283 |
||
5284 |
if (__isBytes(aString)) { |
|
5285 |
n = __byteArraySize(aString) - nInstBytes; |
|
5286 |
||
5287 |
BEGIN_INTERRUPTSBLOCKED |
|
5288 |
len = XTextWidth(f, cp, n); |
|
5289 |
END_INTERRUPTSBLOCKED |
|
5290 |
RETURN ( __MKSMALLINT(len) ); |
|
5291 |
} |
|
5292 |
||
5293 |
/* TWOBYTESTRINGS */ |
|
5294 |
if (__isWords(aString)) { |
|
5295 |
union { |
|
5296 |
char b[2]; |
|
5297 |
unsigned short s; |
|
5298 |
} u; |
|
5299 |
int i; |
|
5300 |
XChar2b *cp2; |
|
5301 |
int mustFree = 0; |
|
5302 |
||
5303 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5304 |
if (n > 1000) n = 1000; |
|
5305 |
||
5306 |
/* |
|
5307 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5308 |
* X expects them MSB first |
|
5309 |
* convert as required |
|
5310 |
*/ |
|
5311 |
||
5312 |
u.s = 0x1234; |
|
5313 |
if (u.b[0] != 0x12) { |
|
5314 |
if (n <= NLOCALBUFFER) { |
|
5315 |
cp2 = xlatebuffer; |
|
5316 |
} else { |
|
5317 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
5318 |
mustFree = 1; |
|
5319 |
} |
|
5320 |
||
5321 |
for (i=0; i<n; i++) { |
|
5322 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5323 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5324 |
} |
|
5325 |
cp = (char *) cp2; |
|
5326 |
} |
|
5327 |
||
5328 |
BEGIN_INTERRUPTSBLOCKED |
|
5329 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
5330 |
END_INTERRUPTSBLOCKED |
|
5331 |
||
5332 |
if (mustFree) { |
|
5333 |
free(cp2); |
|
5334 |
} |
|
5335 |
||
5336 |
RETURN ( __MKSMALLINT(len) ); |
|
5337 |
} |
|
5338 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5339 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5340 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5341 |
%}. |
295 | 5342 |
self primitiveFailed. |
5343 |
^ nil |
|
5344 |
! ! |
|
5345 |
||
5346 |
!XWorkstation methodsFor:'grabbing '! |
|
5347 |
||
5348 |
allowEvents:mode |
|
5349 |
%{ /* NOCONTEXT */ |
|
5350 |
||
5351 |
int _mode, ok = 1; |
|
5352 |
||
5353 |
if (mode == @symbol(asyncPointer)) |
|
5354 |
_mode = AsyncPointer; |
|
5355 |
else if (mode == @symbol(syncPointer)) |
|
5356 |
_mode = SyncPointer; |
|
5357 |
else if (mode == @symbol(asyncKeyboard)) |
|
5358 |
_mode = AsyncKeyboard; |
|
5359 |
else if (mode == @symbol(syncKeyboard)) |
|
5360 |
_mode = SyncKeyboard; |
|
5361 |
else if (mode == @symbol(syncBoth)) |
|
5362 |
_mode = SyncBoth; |
|
5363 |
else if (mode == @symbol(asyncBoth)) |
|
5364 |
_mode = AsyncBoth; |
|
5365 |
else if (mode == @symbol(replayPointer)) |
|
5366 |
_mode = ReplayPointer; |
|
5367 |
else if (mode == @symbol(replayKeyboard)) |
|
5368 |
_mode = ReplayKeyboard; |
|
5369 |
else |
|
5370 |
ok = 0; |
|
5371 |
||
5372 |
if (ok) { |
|
5373 |
BEGIN_INTERRUPTSBLOCKED |
|
5374 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5375 |
END_INTERRUPTSBLOCKED |
|
5376 |
RETURN (self); |
|
5377 |
} |
|
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5378 |
%}. |
295 | 5379 |
self primitiveFailed |
5380 |
! |
|
5381 |
||
5382 |
grabKeyboardIn:aWindowId |
|
5383 |
"grab the keyboard" |
|
5384 |
||
5385 |
%{ /* NOCONTEXT */ |
|
5386 |
int result, ok; |
|
5387 |
||
5388 |
if (__isExternalAddress(aWindowId)) { |
|
5389 |
BEGIN_INTERRUPTSBLOCKED |
|
5390 |
result = XGrabKeyboard(myDpy, |
|
5391 |
_WindowVal(aWindowId), |
|
5392 |
True /* False */, |
|
5393 |
GrabModeAsync, |
|
5394 |
GrabModeAsync, |
|
5395 |
CurrentTime); |
|
5396 |
END_INTERRUPTSBLOCKED |
|
5397 |
ok = 0; |
|
5398 |
switch(result) { |
|
5399 |
case AlreadyGrabbed: |
|
5400 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5401 |
break; |
|
5402 |
case GrabNotViewable: |
|
5403 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5404 |
break; |
|
5405 |
case GrabInvalidTime: |
|
5406 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5407 |
break; |
|
5408 |
case GrabFrozen: |
|
5409 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5410 |
break; |
|
5411 |
default: |
|
5412 |
ok = 1; |
|
5413 |
break; |
|
5414 |
} |
|
5415 |
if (! ok) { |
|
5416 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5417 |
RETURN (false); |
|
5418 |
} |
|
5419 |
||
5420 |
RETURN ( true ); |
|
5421 |
} |
|
5422 |
%} |
|
5423 |
. |
|
5424 |
self primitiveFailed |
|
5425 |
! |
|
5426 |
||
5427 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5428 |
"grap the pointer - return true if ok" |
|
5429 |
||
5430 |
%{ /* NOCONTEXT */ |
|
5431 |
||
5432 |
int result, ok; |
|
5433 |
Window confineWin; |
|
5434 |
Cursor curs; |
|
5435 |
int pointer_mode, keyboard_mode; |
|
5436 |
||
5437 |
if (__isExternalAddress(aWindowId)) { |
|
5438 |
if (__isExternalAddress(confineId)) |
|
5439 |
confineWin = _WindowVal(confineId); |
|
5440 |
else |
|
5441 |
confineWin = (Window) None; |
|
5442 |
||
5443 |
if (__isExternalAddress(aCursorId)) |
|
5444 |
curs = _CursorVal(aCursorId); |
|
5445 |
else |
|
5446 |
curs = (Cursor) None; |
|
5447 |
||
5448 |
if (pMode == @symbol(sync)) |
|
5449 |
pointer_mode = GrabModeSync; |
|
5450 |
else |
|
5451 |
pointer_mode = GrabModeAsync; |
|
5452 |
||
5453 |
if (kMode == @symbol(sync)) |
|
5454 |
keyboard_mode = GrabModeSync; |
|
5455 |
else |
|
5456 |
keyboard_mode = GrabModeAsync; |
|
5457 |
||
5458 |
BEGIN_INTERRUPTSBLOCKED |
|
5459 |
result = XGrabPointer(myDpy, |
|
5460 |
_WindowVal(aWindowId), |
|
5461 |
False, |
|
5462 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5463 |
pointer_mode, keyboard_mode, |
|
5464 |
confineWin, |
|
5465 |
curs, |
|
5466 |
CurrentTime); |
|
5467 |
END_INTERRUPTSBLOCKED |
|
5468 |
||
5469 |
ok = 0; |
|
5470 |
switch (result) { |
|
5471 |
case AlreadyGrabbed: |
|
5472 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5473 |
break; |
|
5474 |
case GrabNotViewable: |
|
5475 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5476 |
break; |
|
5477 |
case GrabInvalidTime: |
|
5478 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5479 |
break; |
|
5480 |
case GrabFrozen: |
|
5481 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5482 |
break; |
|
5483 |
default: |
|
5484 |
ok = 1; |
|
5485 |
break; |
|
5486 |
} |
|
5487 |
||
5488 |
if (! ok) { |
|
5489 |
XUngrabPointer(myDpy, CurrentTime); |
|
5490 |
RETURN (false); |
|
5491 |
} |
|
5492 |
RETURN ( true ); |
|
5493 |
} |
|
5494 |
%} |
|
5495 |
. |
|
5496 |
self primitiveFailed |
|
5497 |
! |
|
5498 |
||
5499 |
ungrabKeyboard |
|
5500 |
"release the keyboard" |
|
5501 |
||
5502 |
%{ /* NOCONTEXT */ |
|
5503 |
||
5504 |
if (ISCONNECTED) { |
|
5505 |
BEGIN_INTERRUPTSBLOCKED |
|
5506 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5507 |
XSync(myDpy, 0); |
|
5508 |
END_INTERRUPTSBLOCKED |
|
5509 |
} |
|
5510 |
%}. |
|
5511 |
activeKeyboardGrab := nil |
|
5512 |
! |
|
5513 |
||
5514 |
ungrabPointer |
|
5515 |
"release the pointer" |
|
5516 |
||
5517 |
%{ /* NOCONTEXT */ |
|
5518 |
||
5519 |
if (ISCONNECTED) { |
|
5520 |
BEGIN_INTERRUPTSBLOCKED |
|
5521 |
XUngrabPointer(myDpy, CurrentTime); |
|
5522 |
XSync(myDpy, 0); |
|
5523 |
END_INTERRUPTSBLOCKED |
|
5524 |
} |
|
5525 |
%}. |
|
5526 |
activePointerGrab := nil |
|
5527 |
! ! |
|
5528 |
||
5529 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5530 |
||
5531 |
noClipIn:aGCId |
|
5532 |
"disable clipping rectangle" |
|
5533 |
||
5534 |
%{ /* NOCONTEXT */ |
|
5535 |
||
5536 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5537 |
GC gc; |
295 | 5538 |
|
5539 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5540 |
gc = _GCVal(aGCId); |
295 | 5541 |
gcv.clip_mask = None; |
5542 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5543 |
RETURN ( self ); |
|
5544 |
} |
|
5545 |
%}. |
|
5546 |
self primitiveFailed |
|
5547 |
! |
|
5548 |
||
5549 |
setBackground:bgColorIndex in:aGCId |
|
5550 |
"set background color to be drawn with" |
|
5551 |
||
5552 |
%{ /* NOCONTEXT */ |
|
5553 |
||
5554 |
if (__isExternalAddress(aGCId) |
|
5555 |
&& __isSmallInteger(bgColorIndex)) { |
|
555 | 5556 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
295 | 5557 |
RETURN ( self ); |
5558 |
} |
|
5559 |
%}. |
|
5560 |
self primitiveFailed |
|
5561 |
! |
|
5562 |
||
5563 |
setBitmapMask:aBitmapId in:aGCId |
|
5564 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5565 |
||
5566 |
%{ /* NOCONTEXT */ |
|
5567 |
||
5568 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5569 |
GC gc; |
295 | 5570 |
Pixmap bitmap; |
5571 |
||
5572 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5573 |
gc = _GCVal(aGCId); |
295 | 5574 |
if (__isExternalAddress(aBitmapId)) { |
5575 |
bitmap = _PixmapVal(aBitmapId); |
|
5576 |
XSetStipple(dpy, gc, bitmap); |
|
5577 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5578 |
RETURN ( self ); |
|
5579 |
} |
|
5580 |
if (aBitmapId == nil) { |
|
5581 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5582 |
RETURN ( self ); |
|
5583 |
} |
|
5584 |
} |
|
5585 |
%}. |
|
5586 |
self primitiveFailed |
|
5587 |
! |
|
5588 |
||
5589 |
setClipByChildren:aBool in:aGCId |
|
5590 |
"enable/disable drawing into child views" |
|
5591 |
||
5592 |
%{ /* NOCONTEXT */ |
|
5593 |
||
5594 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5595 |
GC gc; |
295 | 5596 |
|
5597 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5598 |
gc = _GCVal(aGCId); |
295 | 5599 |
if (aBool == true) |
5600 |
gcv.subwindow_mode = ClipByChildren; |
|
5601 |
else |
|
5602 |
gcv.subwindow_mode = IncludeInferiors; |
|
5603 |
||
5604 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5605 |
RETURN ( self ); |
|
5606 |
} |
|
5607 |
%}. |
|
5608 |
self primitiveFailed |
|
5609 |
! |
|
5610 |
||
5611 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5612 |
"clip to a rectangle" |
|
5613 |
||
5614 |
%{ /* NOCONTEXT */ |
|
5615 |
||
5616 |
XRectangle r; |
|
5617 |
||
5618 |
if (__isExternalAddress(aGCId) |
|
5619 |
&& __bothSmallInteger(clipX, clipY) |
|
5620 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
555 | 5621 |
r.x = __intVal(clipX); |
5622 |
r.y = __intVal(clipY); |
|
5623 |
r.width = __intVal(clipWidth); |
|
5624 |
r.height = __intVal(clipHeight); |
|
295 | 5625 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
5626 |
RETURN ( self ); |
|
5627 |
} |
|
5628 |
%}. |
|
5629 |
self primitiveFailed |
|
5630 |
! |
|
5631 |
||
788 | 5632 |
setDashes:dashList dashOffset:offset in:aGCId |
5633 |
"set line attributes" |
|
5634 |
||
5635 |
%{ /* NOCONTEXT */ |
|
5636 |
||
5637 |
if (__isExternalAddress(aGCId) |
|
5638 |
&& __isSmallInteger(offset) |
|
5639 |
&& __isByteArray(dashList)) { |
|
850 | 5640 |
XSetDashes(myDpy, _GCVal(aGCId), |
5641 |
__intVal(offset), |
|
5642 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
5643 |
__byteArraySize(dashList)); |
|
5644 |
RETURN ( self ); |
|
788 | 5645 |
} |
5646 |
bad: ; |
|
5647 |
%}. |
|
5648 |
" |
|
5649 |
either aGCId is invalid, |
|
5650 |
and/or dashList is not a byteArray |
|
5651 |
and/or offset is not a smallInteger |
|
5652 |
" |
|
5653 |
self primitiveFailed |
|
5654 |
! |
|
5655 |
||
295 | 5656 |
setFont:aFontId in:aGCId |
5657 |
"set font to be drawn in" |
|
5658 |
||
5659 |
%{ /* NOCONTEXT */ |
|
5660 |
||
5661 |
XFontStruct *f; |
|
5662 |
||
5663 |
if (__isExternalAddress(aFontId) |
|
5664 |
&& __isExternalAddress(aGCId)) { |
|
5665 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5666 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5667 |
RETURN ( self ); |
|
5668 |
} |
|
5669 |
%}. |
|
5670 |
" |
|
5671 |
aGCId and/or aFontId are invalid |
|
5672 |
" |
|
5673 |
self primitiveFailed |
|
5674 |
! |
|
5675 |
||
5676 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5677 |
"set foreground and background colors to be drawn with" |
|
5678 |
||
5679 |
%{ /* NOCONTEXT */ |
|
5680 |
||
5681 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5682 |
GC gc; |
295 | 5683 |
|
5684 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5685 |
&& __isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5686 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5687 |
|
555 | 5688 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
5689 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
295 | 5690 |
RETURN ( self ); |
5691 |
} |
|
5692 |
%}. |
|
5693 |
self primitiveFailed |
|
5694 |
! |
|
5695 |
||
5696 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5697 |
"set foreground and background colors to be drawn with using mask or |
|
5698 |
solid (if aBitmapId is nil)" |
|
5699 |
||
5700 |
%{ /* NOCONTEXT */ |
|
5701 |
||
5702 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5703 |
GC gc; |
295 | 5704 |
|
5705 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5706 |
gc = _GCVal(aGCId); |
295 | 5707 |
if (__isSmallInteger(fgColor)) |
555 | 5708 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5709 |
if (__isSmallInteger(bgColor)) |
555 | 5710 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5711 |
|
5712 |
if (__isExternalAddress(aBitmapId)) { |
|
5713 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5714 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5715 |
RETURN ( self ); |
|
5716 |
} |
|
5717 |
if (aBitmapId == nil) { |
|
5718 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5719 |
RETURN ( self ); |
|
5720 |
} |
|
5721 |
} |
|
5722 |
%}. |
|
5723 |
self primitiveFailed |
|
5724 |
! |
|
5725 |
||
5726 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5727 |
"set foreground and background colors to be drawn with using mask or |
|
5728 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5729 |
||
5730 |
%{ /* NOCONTEXT */ |
|
5731 |
||
5732 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5733 |
GC gc; |
295 | 5734 |
|
5735 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5736 |
gc = _GCVal(aGCId); |
295 | 5737 |
if (__isSmallInteger(lw)) { |
555 | 5738 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
295 | 5739 |
LineSolid, CapNotLast, JoinMiter); |
5740 |
} |
|
5741 |
if (__isSmallInteger(fgColor)) |
|
555 | 5742 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5743 |
if (__isSmallInteger(bgColor)) |
555 | 5744 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5745 |
|
5746 |
if (__isExternalAddress(aBitmapId)) { |
|
5747 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5748 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5749 |
RETURN ( self ); |
|
5750 |
} |
|
5751 |
if (aBitmapId == nil) { |
|
5752 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5753 |
RETURN ( self ); |
|
5754 |
} |
|
5755 |
} |
|
5756 |
%}. |
|
5757 |
self primitiveFailed |
|
5758 |
! |
|
5759 |
||
5760 |
setForeground:fgColorIndex in:aGCId |
|
5761 |
"set foreground color to be drawn with" |
|
5762 |
||
5763 |
%{ /* NOCONTEXT */ |
|
5764 |
||
5765 |
if (__isExternalAddress(aGCId) |
|
5766 |
&& __isSmallInteger(fgColorIndex)) { |
|
555 | 5767 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
295 | 5768 |
RETURN ( self ); |
5769 |
} |
|
5770 |
%}. |
|
5771 |
self primitiveFailed |
|
5772 |
! |
|
5773 |
||
5774 |
setFunction:aFunctionSymbol in:aGCId |
|
5775 |
"set alu function to be drawn with" |
|
5776 |
||
5777 |
%{ /* NOCONTEXT */ |
|
5778 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5779 |
GC gc; |
295 | 5780 |
int fun = -1; |
5781 |
||
5782 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5783 |
gc = _GCVal(aGCId); |
295 | 5784 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5785 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5786 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5787 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5788 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5789 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5790 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5791 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5792 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5793 |
if (fun != -1) { |
|
5794 |
XSetFunction(myDpy, gc, fun); |
|
5795 |
RETURN ( self ); |
|
5796 |
} |
|
5797 |
} |
|
5798 |
%}. |
|
5799 |
" |
|
5800 |
either aGCId is not an integer, or an invalid symbol |
|
5801 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5802 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5803 |
" |
|
5804 |
self primitiveFailed |
|
5805 |
! |
|
5806 |
||
5807 |
setGraphicsExposures:aBoolean in:aGCId |
|
5808 |
"set or clear the graphics exposures flag" |
|
5809 |
||
5810 |
%{ /* NOCONTEXT */ |
|
5811 |
||
5812 |
if (__isExternalAddress(aGCId)) { |
|
5813 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5814 |
RETURN ( self ); |
|
5815 |
} |
|
5816 |
%} |
|
5817 |
. |
|
5818 |
self primitiveFailed |
|
5819 |
! |
|
5820 |
||
5821 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5822 |
"set line attributes" |
|
5823 |
||
5824 |
%{ /* NOCONTEXT */ |
|
5825 |
||
5826 |
int x_style, x_cap, x_join; |
|
5827 |
||
5828 |
if (__isExternalAddress(aGCId) |
|
5829 |
&& __isSmallInteger(aNumber)) { |
|
5830 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5831 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5832 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5833 |
else goto bad; |
|
5834 |
||
5835 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5836 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5837 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5838 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5839 |
else goto bad; |
|
5840 |
||
5841 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5842 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5843 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5844 |
else goto bad; |
|
5845 |
||
5846 |
XSetLineAttributes(myDpy, |
|
555 | 5847 |
_GCVal(aGCId), __intVal(aNumber), |
295 | 5848 |
x_style, x_cap, x_join); |
5849 |
RETURN ( self ); |
|
5850 |
} |
|
5851 |
bad: ; |
|
5852 |
%}. |
|
5853 |
" |
|
5854 |
either aGCId is invalid, |
|
5855 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5856 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5857 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5858 |
" |
|
5859 |
self primitiveFailed |
|
5860 |
! |
|
5861 |
||
5862 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5863 |
"set the mask origin" |
|
5864 |
||
5865 |
%{ /* NOCONTEXT */ |
|
5866 |
||
5867 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
555 | 5868 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
295 | 5869 |
RETURN ( self ); |
5870 |
} |
|
5871 |
%}. |
|
5872 |
self primitiveFailed |
|
5873 |
! |
|
5874 |
||
5875 |
setPixmapMask:aPixmapId in:aGCId |
|
5876 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5877 |
||
5878 |
%{ /* NOCONTEXT */ |
|
5879 |
||
5880 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5881 |
GC gc; |
295 | 5882 |
Pixmap pixmap; |
5883 |
||
5884 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5885 |
gc = _GCVal(aGCId); |
295 | 5886 |
if (__isExternalAddress(aPixmapId)) { |
5887 |
pixmap = _PixmapVal(aPixmapId); |
|
5888 |
XSetTile(dpy, gc, pixmap); |
|
5889 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5890 |
RETURN ( self ); |
|
5891 |
} |
|
5892 |
if (aPixmapId == nil) { |
|
5893 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5894 |
RETURN ( self ); |
|
5895 |
} |
|
5896 |
} |
|
5897 |
%}. |
|
5898 |
self primitiveFailed |
|
5899 |
! ! |
|
5900 |
||
5901 |
!XWorkstation methodsFor:'initialize / release'! |
|
5902 |
||
5903 |
close |
|
5904 |
"close down the connection to the X-server" |
|
5905 |
||
5906 |
%{ /* NOCONTEXT */ |
|
5907 |
||
5908 |
if (ISCONNECTED) { |
|
5909 |
BEGIN_INTERRUPTSBLOCKED |
|
5910 |
XCloseDisplay(myDpy); |
|
555 | 5911 |
__INST(displayId) = nil; |
295 | 5912 |
END_INTERRUPTSBLOCKED |
5913 |
} |
|
5914 |
%} |
|
5915 |
! |
|
5916 |
||
5917 |
initializeDefaultValues |
|
5918 |
buttonTranslation := ButtonTranslation. |
|
5919 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5920 |
||
5921 |
self initializeModifierMappings |
|
5922 |
! |
|
5923 |
||
5924 |
initializeEventBuffer |
|
5925 |
|sz| |
|
5926 |
||
5927 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5928 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5929 |
%}. |
5930 |
eventBuffer isNil ifTrue:[ |
|
5931 |
eventBuffer := ByteArray new:sz. |
|
5932 |
]. |
|
5933 |
! |
|
5934 |
||
5935 |
initializeFor:aDisplayName |
|
5936 |
"initialize the receiver for a connection to an X-Server; |
|
5937 |
the argument, aDisplayName may be nil (for the default server from |
|
5938 |
DISPLAY-variable or command line argument) or the name of the server |
|
5939 |
as hostname:number" |
|
5940 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5941 |
|dpyName index arguments| |
295 | 5942 |
|
5943 |
dpyName := aDisplayName. |
|
5944 |
dpyName isNil ifTrue:[ |
|
5945 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5946 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5947 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5948 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5949 |
dpyName := arguments at:index+1 |
295 | 5950 |
] |
5951 |
] |
|
5952 |
]. |
|
5953 |
%{ |
|
5954 |
int scr; |
|
5955 |
Display *dpy; |
|
5956 |
Visual *visual; |
|
5957 |
XVisualInfo viproto; |
|
5958 |
XVisualInfo *vip; /* retured info */ |
|
5959 |
int maxRGBDepth; |
|
5960 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5961 |
int rgbVisualID; |
|
5962 |
int nvi, i; |
|
5963 |
int shapeEventBase, shapeErrorBase; |
|
5964 |
int shmEventBase, shmErrorBase; |
|
5965 |
int faxEventBase, faxErrorBase; |
|
5966 |
char *type, *nm; |
|
5967 |
int dummy; |
|
5968 |
OBJ dpyID; |
|
5969 |
||
555 | 5970 |
if (__INST(displayId) != nil) { |
295 | 5971 |
/* |
5972 |
* already connected - you bad guy try to |
|
5973 |
* trick me manually ? |
|
5974 |
*/ |
|
5975 |
RETURN ( self ); |
|
5976 |
} |
|
5977 |
||
5978 |
BEGIN_INTERRUPTSBLOCKED |
|
5979 |
||
5980 |
if (__isString(dpyName)) |
|
5981 |
nm = (char *)_stringVal(dpyName); |
|
5982 |
else { |
|
5983 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5984 |
nm = NULL; |
|
5985 |
} |
|
5986 |
dpy = XOpenDisplay(nm); |
|
5987 |
||
5988 |
if (dpy) { |
|
555 | 5989 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 5990 |
|
5991 |
#ifdef SUPERDEBUG |
|
5992 |
XSynchronize(dpy, 1); |
|
5993 |
#endif |
|
5994 |
||
5995 |
XSetErrorHandler(__XErrorHandler__); |
|
5996 |
} |
|
5997 |
||
5998 |
END_INTERRUPTSBLOCKED |
|
5999 |
%}. |
|
6000 |
displayId isNil ifTrue:[ |
|
6001 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
6002 |
^ nil |
|
6003 |
]. |
|
6004 |
||
6005 |
dispatching := false. |
|
6006 |
dispatchingExpose := false. |
|
6007 |
isSlow := false. |
|
6008 |
shiftDown := false. |
|
6009 |
ctrlDown := false. |
|
6010 |
metaDown := false. |
|
6011 |
altDown := false. |
|
6012 |
motionEventCompression := true. |
|
6013 |
buttonsPressed := 0. |
|
6014 |
displayName := dpyName. |
|
6015 |
||
6016 |
protocolsAtom := nil. |
|
6017 |
deleteWindowAtom := nil. |
|
6018 |
saveYourselfAtom := nil. |
|
6019 |
quitAppAtom := nil. |
|
6020 |
||
6021 |
self initializeScreenProperties. |
|
6022 |
||
6023 |
self initializeDefaultValues. |
|
6024 |
self initializeEventBuffer. |
|
6025 |
self initializeSpecialFlags. |
|
6026 |
self initializeKeyboardMap. |
|
6027 |
||
6028 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
6029 |
! |
|
6030 |
||
6031 |
initializeModifierMappings |
|
6032 |
|map mod| |
|
6033 |
||
6034 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6035 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6036 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6037 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6038 |
||
6039 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6040 |
altModifierMask := metaModifierMask := nil. |
|
6041 |
||
6042 |
map := self modifierMapping. |
|
342 | 6043 |
map isNil ifTrue:[ |
6044 |
"/ |
|
6045 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6046 |
"/ setup some reasonable default. If that is not sufficient, |
|
6047 |
"/ you have to change things from your display.rc file. |
|
6048 |
"/ |
|
6049 |
altModifierMask := self modifier1Mask. |
|
6050 |
metaModifierMask := self modifier2Mask. |
|
6051 |
||
6052 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6053 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6054 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6055 |
altModifiers := #(Alt_R Alt). |
|
6056 |
] ifFalse:[ |
|
6057 |
altModifierMask := 0. |
|
374 | 6058 |
metaModifierMask := 0. |
6059 |
||
6060 |
mod := map at:1. |
|
6061 |
mod notNil ifTrue:[ |
|
342 | 6062 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 6063 |
]. |
6064 |
mod := map at:3. |
|
6065 |
mod notNil ifTrue:[ |
|
342 | 6066 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 6067 |
]. |
6068 |
mod := map at:4. |
|
6069 |
mod notNil ifTrue:[ |
|
342 | 6070 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
6071 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 6072 |
]. |
6073 |
mod := map at:5. |
|
6074 |
mod notNil ifTrue:[ |
|
342 | 6075 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
6076 |
altModifierMask := 1 bitShift:(5-1). |
|
6077 |
] |
|
295 | 6078 |
]. |
6079 |
||
6080 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6081 |
! |
|
6082 |
||
6083 |
initializeScreenProperties |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6084 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6085 |
|
295 | 6086 |
%{ /* NOCONTEXT */ |
6087 |
||
6088 |
Display *dpy = myDpy; |
|
6089 |
int scr; |
|
6090 |
Visual *visual; |
|
6091 |
XVisualInfo viproto; |
|
6092 |
XVisualInfo *vip; /* retured info */ |
|
6093 |
int maxRGBDepth; |
|
6094 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6095 |
int rgbVisualID; |
|
6096 |
int nvi, i; |
|
6097 |
int shapeEventBase, shapeErrorBase; |
|
6098 |
int shmEventBase, shmErrorBase; |
|
6099 |
int faxEventBase, faxErrorBase; |
|
6100 |
char *type, *nm; |
|
6101 |
int dummy; |
|
6102 |
int mask, shift, nBits; |
|
6103 |
||
6104 |
if (ISCONNECTED) { |
|
850 | 6105 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
6106 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6107 |
||
6108 |
BEGIN_INTERRUPTSBLOCKED |
|
6109 |
||
6110 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6111 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6112 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6113 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6114 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6115 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6116 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6117 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6118 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6119 |
|
6120 |
#ifdef SHAPE |
|
850 | 6121 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
6122 |
__INST(hasShapeExtension) = true; |
|
6123 |
else |
|
295 | 6124 |
#endif |
850 | 6125 |
__INST(hasShapeExtension) = false; |
295 | 6126 |
|
6127 |
#ifdef SHM |
|
850 | 6128 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
6129 |
__INST(hasShmExtension) = true; |
|
6130 |
else |
|
295 | 6131 |
#endif |
850 | 6132 |
__INST(hasShmExtension) = false; |
295 | 6133 |
|
6134 |
#ifdef FAX |
|
850 | 6135 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
6136 |
__INST(hasFaxExtension) = true; |
|
6137 |
else |
|
295 | 6138 |
#endif |
850 | 6139 |
__INST(hasFaxExtension) = false; |
295 | 6140 |
|
6141 |
#ifdef DPS |
|
850 | 6142 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6143 |
__INST(hasDPSExtension) = true; |
|
6144 |
else |
|
295 | 6145 |
#endif |
850 | 6146 |
__INST(hasDPSExtension) = false; |
295 | 6147 |
|
6148 |
#ifdef XVIDEO |
|
850 | 6149 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6150 |
__INST(hasXVideoExtension) = true; |
|
6151 |
else |
|
295 | 6152 |
#endif |
850 | 6153 |
__INST(hasXVideoExtension) = false; |
295 | 6154 |
|
6155 |
#ifdef MBUF |
|
850 | 6156 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6157 |
__INST(hasMbufExtension) = true; |
|
6158 |
else |
|
295 | 6159 |
#endif |
850 | 6160 |
__INST(hasMbufExtension) = false; |
295 | 6161 |
|
6162 |
#ifdef PEX5 |
|
850 | 6163 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6164 |
__INST(hasPEXExtension) = true; |
|
6165 |
else |
|
295 | 6166 |
#endif |
850 | 6167 |
__INST(hasPEXExtension) = false; |
295 | 6168 |
|
6169 |
#ifdef XIE |
|
850 | 6170 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6171 |
__INST(hasImageExtension) = true; |
|
6172 |
else |
|
295 | 6173 |
#endif |
850 | 6174 |
__INST(hasImageExtension) = false; |
295 | 6175 |
|
6176 |
#ifdef XI |
|
850 | 6177 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6178 |
__INST(hasInputExtension) = true; |
|
6179 |
else |
|
295 | 6180 |
#endif |
850 | 6181 |
__INST(hasInputExtension) = false; |
6182 |
||
6183 |
/* |
|
6184 |
* look for RGB visual |
|
6185 |
*/ |
|
6186 |
nvi = 0; |
|
6187 |
viproto.screen = scr; |
|
6188 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6189 |
maxRGBDepth = 0; |
|
6190 |
for (i = 0; i < nvi; i++) { |
|
6191 |
switch (vip[i].class) { |
|
6192 |
case TrueColor: |
|
6193 |
if (vip[i].depth > maxRGBDepth) { |
|
6194 |
maxRGBDepth = vip[i].depth; |
|
6195 |
rgbRedMask = vip[i].red_mask; |
|
6196 |
rgbGreenMask = vip[i].green_mask; |
|
6197 |
rgbBlueMask = vip[i].blue_mask; |
|
6198 |
rgbVisualID = vip[i].visualid; |
|
6199 |
} |
|
6200 |
break; |
|
6201 |
} |
|
6202 |
} |
|
6203 |
if (vip) XFree ((char *) vip); |
|
6204 |
||
6205 |
if (maxRGBDepth) { |
|
6206 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6207 |
} |
|
6208 |
||
6209 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6210 |
__INST(monitorType) = @symbol(unknown); |
|
6211 |
__INST(hasColors) = true; |
|
6212 |
__INST(hasGreyscales) = true; |
|
6213 |
switch (visual->class) { |
|
6214 |
case StaticGray: |
|
6215 |
__INST(visualType) = @symbol(StaticGray); |
|
6216 |
__INST(hasColors) = false; |
|
6217 |
__INST(monitorType) = @symbol(monochrome); |
|
6218 |
break; |
|
6219 |
case GrayScale: |
|
6220 |
__INST(visualType) = @symbol(GrayScale); |
|
6221 |
__INST(hasColors) = false; |
|
6222 |
__INST(monitorType) = @symbol(monochrome); |
|
6223 |
break; |
|
6224 |
case StaticColor: |
|
6225 |
__INST(visualType) = @symbol(StaticColor); |
|
6226 |
break; |
|
6227 |
case PseudoColor: |
|
6228 |
__INST(visualType) = @symbol(PseudoColor); |
|
6229 |
break; |
|
6230 |
case TrueColor: |
|
6231 |
__INST(visualType) = @symbol(TrueColor); |
|
6232 |
break; |
|
6233 |
case DirectColor: |
|
6234 |
__INST(visualType) = @symbol(DirectColor); |
|
6235 |
break; |
|
6236 |
} |
|
6237 |
if (DisplayCells(dpy, scr) == 2) { |
|
6238 |
__INST(hasColors) = false; |
|
6239 |
__INST(hasGreyscales) = false; |
|
6240 |
__INST(monitorType) = @symbol(monochrome); |
|
6241 |
} |
|
6242 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
6243 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6244 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6245 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
6246 |
switch (visual->class) { |
|
6247 |
case TrueColor: |
|
6248 |
/* extract number of bits and shift counts */ |
|
6249 |
mask = visual->red_mask; |
|
6250 |
shift = 0; |
|
6251 |
while (mask && ((mask & 1) == 0)) { |
|
6252 |
mask >>= 1; |
|
6253 |
shift++; |
|
6254 |
} |
|
6255 |
__INST(redShift) = __MKSMALLINT(shift); |
|
6256 |
nBits = 0; |
|
6257 |
while (mask) { |
|
6258 |
mask >>= 1; |
|
6259 |
nBits++; |
|
6260 |
} |
|
6261 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
6262 |
||
6263 |
mask = visual->green_mask; |
|
6264 |
shift = 0; |
|
6265 |
while (mask && ((mask & 1) == 0)) { |
|
6266 |
mask >>= 1; |
|
6267 |
shift++; |
|
6268 |
} |
|
6269 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
6270 |
nBits = 0; |
|
6271 |
while (mask) { |
|
6272 |
mask >>= 1; |
|
6273 |
nBits++; |
|
6274 |
} |
|
6275 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
6276 |
||
6277 |
mask = visual->blue_mask; |
|
6278 |
shift = 0; |
|
6279 |
while (mask && ((mask & 1) == 0)) { |
|
6280 |
mask >>= 1; |
|
6281 |
shift++; |
|
6282 |
} |
|
6283 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
6284 |
nBits = 0; |
|
6285 |
while (mask) { |
|
6286 |
mask >>= 1; |
|
6287 |
nBits++; |
|
6288 |
} |
|
6289 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
6290 |
break; |
|
6291 |
} |
|
295 | 6292 |
|
6293 |
#ifndef XA_PRIMARY |
|
850 | 6294 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6295 |
#else |
850 | 6296 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6297 |
#endif |
6298 |
#ifndef XA_SECONDARY |
|
850 | 6299 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6300 |
#else |
850 | 6301 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6302 |
#endif |
6303 |
#ifndef XA_CUT_BUFFER0 |
|
850 | 6304 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6305 |
#else |
850 | 6306 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6307 |
#endif |
6308 |
#ifndef XA_STRING |
|
850 | 6309 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6310 |
#else |
850 | 6311 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6312 |
#endif |
6313 |
#ifndef XA_LENGTH |
|
850 | 6314 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6315 |
#else |
850 | 6316 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6317 |
#endif |
6318 |
||
850 | 6319 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6320 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6321 |
%}. |
295 | 6322 |
! |
6323 |
||
6324 |
initializeSpecialFlags |
|
6325 |
"perform additional special server implementation flags" |
|
6326 |
||
6327 |
"/ |
|
6328 |
"/ assume we have it ... (should check) |
|
6329 |
"/ |
|
6330 |
hasSaveUnder := true. |
|
6331 |
ignoreBackingStore := false. |
|
6332 |
||
6333 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
6334 |
"/ |
|
6335 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6336 |
"/ which does not correctly handle saveUnder |
|
6337 |
"/ |
|
6338 |
hasSaveUnder := false. |
|
6339 |
]. |
|
6340 |
! |
|
6341 |
||
6342 |
reinitialize |
|
6343 |
virtualRootId := rootId := nil. |
|
6344 |
super reinitialize. |
|
6345 |
dispatchingExpose := nil |
|
6346 |
! ! |
|
6347 |
||
6348 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6349 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6350 |
altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6351 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6352 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6353 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6354 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6355 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6356 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6357 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6358 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6359 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6360 |
|
341 | 6361 |
altModifierMask:aSmallInteger |
6362 |
"define which key takes the role of an alt-key. |
|
6363 |
By default, this is X's modifier1, which is the ALT key on |
|
6364 |
most keyboards. However, there may be exceptions to this, |
|
6365 |
and the setting can be changed with: |
|
6366 |
Display altModifierMask:(Display modifier2Mask) |
|
6367 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
6368 |
" |
|
6369 |
||
6370 |
altModifierMask := aSmallInteger |
|
6371 |
! |
|
6372 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6373 |
metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6374 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6375 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6376 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6377 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6378 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6379 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6380 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6381 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6382 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6383 |
|
341 | 6384 |
metaModifierMask:aSmallInteger |
6385 |
"define which key takes the role of a meta key. |
|
6386 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6387 |
most keyboards (if present at all). |
|
6388 |
However, there may be exceptions to this, and the setting can |
|
6389 |
be changed with: |
|
6390 |
Display metaModifierMask:(Display modifier1Mask) |
|
6391 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
6392 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6393 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6394 |
all the time. On those, you should disable the meta key by setting |
|
6395 |
the mask to 0. |
|
6396 |
" |
|
6397 |
||
6398 |
metaModifierMask := aSmallInteger |
|
6399 |
! |
|
6400 |
||
6401 |
modifier1Mask |
|
6402 |
"return the Xlib mask bit for the 1st modifier key. |
|
6403 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6404 |
this could be used." |
|
6405 |
||
6406 |
%{ /* NOCONTEXT */ |
|
6407 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6408 |
%} |
|
6409 |
! |
|
6410 |
||
6411 |
modifier2Mask |
|
6412 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6413 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6414 |
this could be used." |
|
6415 |
||
6416 |
%{ /* NOCONTEXT */ |
|
6417 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6418 |
%} |
|
6419 |
! |
|
6420 |
||
6421 |
modifierMapping |
|
6422 |
"Get the Modifier Mapping. |
|
6423 |
We return an array of arrays of keycodes" |
|
6424 |
||
6425 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6426 |
||
6427 |
%{ |
|
6428 |
Display *dpy = myDpy; |
|
6429 |
XModifierKeymap *modmap; |
|
6430 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6431 |
||
6432 |
if (ISCONNECTED) { |
|
6433 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6434 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6435 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6436 |
if (modifierKeyMap != nil) { |
|
6437 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6438 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6439 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6440 |
} |
|
6441 |
XFreeModifiermap(modmap); |
|
6442 |
} |
|
6443 |
} |
|
6444 |
%}. |
|
6445 |
||
6446 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6447 |
||
6448 |
ret := Array new:8. |
|
6449 |
nextKey := 1. |
|
6450 |
1 to:8 do:[ :i | |
|
6451 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6452 |
|mod| |
|
6453 |
||
6454 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6455 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6456 |
key ~= 0 ifTrue:[ |
|
6457 |
mod add:key |
|
6458 |
]. |
|
6459 |
]. |
|
6460 |
ret at:i put:mod. |
|
6461 |
]. |
|
6462 |
nextKey := nextKey+maxKeyPerMod. |
|
6463 |
]. |
|
6464 |
||
6465 |
^ ret |
|
6466 |
||
6467 |
" |
|
6468 |
Display modifierMapping |
|
6469 |
" |
|
6470 |
! |
|
6471 |
||
6472 |
stringFromKeycode:code |
|
6473 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6474 |
||
6475 |
|str| |
|
6476 |
||
6477 |
%{ |
|
6478 |
Display *dpy = myDpy; |
|
6479 |
KeySym keysym; |
|
6480 |
char *keystring; |
|
6481 |
||
6482 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6483 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6484 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6485 |
str = __MKSTRING(keystring); |
|
6486 |
} |
|
6487 |
%}. |
|
6488 |
^ str |
|
6489 |
||
6490 |
" |
|
6491 |
Display stringFromKeycode:28 |
|
6492 |
" |
|
6493 |
! |
|
6494 |
||
295 | 6495 |
translateKey:untranslatedKey |
6496 |
"Return the key translated via the translation table. |
|
6497 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6498 |
which gets further processed in the superclasses translation method." |
|
6499 |
||
6500 |
|key| |
|
6501 |
||
6502 |
(key := untranslatedKey) isString ifTrue:[ |
|
6503 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6504 |
key := key asSymbol. |
|
6505 |
]. |
|
6506 |
^ super translateKey:key |
|
6507 |
! ! |
|
6508 |
||
6509 |
!XWorkstation methodsFor:'misc'! |
|
6510 |
||
6511 |
beep |
|
6512 |
"output an audible beep or bell" |
|
6513 |
||
6514 |
self beep:50 |
|
6515 |
! |
|
6516 |
||
6517 |
beep:volumeInPercent |
|
6518 |
"output an audible beep" |
|
6519 |
%{ |
|
6520 |
int volume; |
|
6521 |
||
6522 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6523 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
555 | 6524 |
volume = __intVal(volumeInPercent) * 2 - 100; |
295 | 6525 |
if (volume < -100) volume = -100; |
6526 |
else if (volume > 100) volume = 100; |
|
6527 |
BEGIN_INTERRUPTSBLOCKED |
|
6528 |
XBell(myDpy, volume); |
|
6529 |
END_INTERRUPTSBLOCKED |
|
6530 |
} |
|
6531 |
%} |
|
6532 |
! |
|
6533 |
||
6534 |
buffered |
|
6535 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6536 |
This is the default anyway. |
6537 |
See #unBuffered for additional info." |
|
295 | 6538 |
|
6539 |
%{ /* NOCONTEXT */ |
|
6540 |
||
6541 |
if (ISCONNECTED) { |
|
6542 |
BEGIN_INTERRUPTSBLOCKED |
|
6543 |
XSynchronize(myDpy, 0); |
|
6544 |
END_INTERRUPTSBLOCKED |
|
6545 |
} |
|
6546 |
%} |
|
374 | 6547 |
" |
6548 |
Display buffered |
|
6549 |
" |
|
295 | 6550 |
! |
6551 |
||
6552 |
flush |
|
6553 |
"send all buffered drawing to the display. |
|
6554 |
This may be required to make certain, that all previous operations |
|
6555 |
are really sent to the display before continuing. For example, |
|
6556 |
after a cursor-change with a followup long computation. |
|
374 | 6557 |
(otherwise, the cursor change request may still be in the output buffer) |
6558 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6559 |
|
6560 |
%{ /* NOCONTEXT */ |
|
6561 |
||
6562 |
if (ISCONNECTED) { |
|
6563 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6564 |
XFlush(myDpy); |
6565 |
END_INTERRUPTSBLOCKED |
|
6566 |
} |
|
6567 |
%} |
|
6568 |
! |
|
6569 |
||
295 | 6570 |
flushDpsContext:aDPSContext |
6571 |
||
6572 |
%{ /* NOCONTEXT */ |
|
6573 |
#ifdef DPS |
|
6574 |
if (__isExternalAddress(aDPSContext)) { |
|
6575 |
BEGIN_INTERRUPTSBLOCKED |
|
6576 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6577 |
END_INTERRUPTSBLOCKED |
|
6578 |
RETURN ( self ); |
|
6579 |
} |
|
6580 |
#endif |
|
374 | 6581 |
%}. |
295 | 6582 |
self primitiveFailed |
6583 |
! |
|
6584 |
||
6585 |
refreshKeyboardMapping:eB |
|
6586 |
%{ |
|
6587 |
XMappingEvent *ev; |
|
6588 |
||
6589 |
if (__isByteArray(eB)) { |
|
555 | 6590 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 6591 |
XRefreshKeyboardMapping(ev); |
6592 |
} |
|
6593 |
%} |
|
6594 |
! |
|
6595 |
||
6596 |
setInputFocusTo:aWindowId |
|
6597 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6598 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6599 |
! |
|
6600 |
||
6601 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6602 |
"set the focus to the view as defined by aWindowId. |
|
6603 |
Passing nil set the focus to no window and lets the display discard all |
|
6604 |
input until a new focus is set. |
|
6605 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6606 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6607 |
given to the parent view, the root view or no view." |
|
6608 |
||
6609 |
%{ /* NOCONTEXT */ |
|
6610 |
int arg; |
|
6611 |
Window focusWindow; |
|
6612 |
||
6613 |
if (ISCONNECTED) { |
|
6614 |
if (__isExternalAddress(aWindowId)) { |
|
6615 |
focusWindow = _WindowVal(aWindowId); |
|
6616 |
} else { |
|
6617 |
focusWindow = None; |
|
6618 |
} |
|
6619 |
if (revertSymbol == @symbol(parent)) |
|
6620 |
arg = RevertToParent; |
|
6621 |
else if (revertSymbol == @symbol(root)) |
|
6622 |
arg = RevertToPointerRoot; |
|
6623 |
else |
|
6624 |
arg = RevertToNone; |
|
6625 |
||
6626 |
BEGIN_INTERRUPTSBLOCKED |
|
6627 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6628 |
END_INTERRUPTSBLOCKED |
|
6629 |
RETURN ( self ); |
|
6630 |
} |
|
6631 |
%}. |
|
6632 |
self primitiveFailed |
|
6633 |
! |
|
6634 |
||
341 | 6635 |
sync |
6636 |
"send all buffered drawing to the display AND wait until the display |
|
6637 |
has finished drawing it. |
|
6638 |
This is almost never needed, except if you are about to read previously |
|
374 | 6639 |
drawn pixels back from the display screen, or you want to wait for a beep |
6640 |
to be finished. See also #flush." |
|
341 | 6641 |
|
6642 |
%{ /* NOCONTEXT */ |
|
6643 |
||
6644 |
if (ISCONNECTED) { |
|
6645 |
BEGIN_INTERRUPTSBLOCKED |
|
6646 |
XSync(myDpy, 0); |
|
6647 |
END_INTERRUPTSBLOCKED |
|
6648 |
} |
|
6649 |
%} |
|
6650 |
! |
|
6651 |
||
295 | 6652 |
unBuffered |
374 | 6653 |
"make all drawing be sent immediately to the display. |
6654 |
This makes all graphics synchronous and turns off any buffering |
|
6655 |
(i.e. each individual draw-request is sent immediately without |
|
6656 |
packing multiple requests into a larger message buffer). |
|
6657 |
Be prepared, that this slows down graphics considerably. |
|
6658 |
However, it allows display errors to be handled immediately and |
|
6659 |
may be useful if you get Xdisplay errors and want to find the request |
|
6660 |
which was responsiblefor it. See also #buffered." |
|
295 | 6661 |
|
6662 |
%{ /* NOCONTEXT */ |
|
6663 |
||
6664 |
if (ISCONNECTED) { |
|
6665 |
BEGIN_INTERRUPTSBLOCKED |
|
6666 |
XSynchronize(myDpy, 1); |
|
6667 |
END_INTERRUPTSBLOCKED |
|
6668 |
} |
|
6669 |
%} |
|
6670 |
"Display unbuffered" |
|
6671 |
! ! |
|
6672 |
||
6673 |
!XWorkstation methodsFor:'pointer queries '! |
|
6674 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6675 |
anyButtonStateMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6676 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6677 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6678 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6679 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6680 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6681 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6682 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6683 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6684 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6685 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6686 |
|
295 | 6687 |
buttonStates |
6688 |
"return an integer representing the state of the pointer buttons; |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6689 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6690 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6691 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 6692 |
|
6693 |
%{ /* NOCONTEXT*/ |
|
6694 |
Display *dpy = myDpy; |
|
6695 |
Window w; |
|
555 | 6696 |
int screen = __intVal(__INST(screen)); |
295 | 6697 |
Window rootRet, childRet; |
6698 |
int rootX, rootY, winX, winY; |
|
6699 |
unsigned int mask; |
|
6700 |
||
6701 |
BEGIN_INTERRUPTSBLOCKED |
|
6702 |
#ifdef VIRTUAL_ROOT |
|
6703 |
w = getRootWindow(myDpy, screen); |
|
6704 |
#else |
|
6705 |
w = RootWindow(dpy, screen); |
|
6706 |
#endif |
|
6707 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
850 | 6708 |
&rootX, &rootY, |
6709 |
&winX, &winY, |
|
6710 |
&mask); |
|
295 | 6711 |
END_INTERRUPTSBLOCKED |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6712 |
RETURN (__MKSMALLINT(mask)); |
295 | 6713 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6714 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6715 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6716 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6717 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6718 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6719 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6720 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6721 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6722 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6723 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6724 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6725 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6726 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6727 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6728 |
" |
295 | 6729 |
! |
6730 |
||
6731 |
leftButtonStateMask |
|
6732 |
"return an integer for masking out the left button from a |
|
6733 |
buttonStates value" |
|
6734 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6735 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6736 |
|
295 | 6737 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6738 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6739 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 6740 |
! |
6741 |
||
6742 |
middleButtonStateMask |
|
6743 |
"return an integer for masking out the middle button from a |
|
6744 |
buttonStates value" |
|
6745 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6746 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6747 |
|
295 | 6748 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6749 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6750 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 6751 |
! |
6752 |
||
6753 |
pointerPosition |
|
6754 |
"return the current pointer position in root-window coordinates" |
|
6755 |
||
6756 |
|xpos ypos| |
|
6757 |
||
6758 |
%{ |
|
6759 |
Display *dpy = myDpy; |
|
6760 |
Window w; |
|
555 | 6761 |
int screen = __intVal(__INST(screen)); |
295 | 6762 |
Window rootRet, childRet; |
6763 |
int rootX, rootY, winX, winY; |
|
6764 |
unsigned int mask; |
|
6765 |
||
6766 |
BEGIN_INTERRUPTSBLOCKED |
|
6767 |
#ifdef VIRTUAL_ROOT |
|
6768 |
w = getRootWindow(myDpy, screen); |
|
6769 |
#else |
|
6770 |
w = RootWindow(dpy, screen); |
|
6771 |
#endif |
|
6772 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6773 |
&rootX, &rootY, |
|
6774 |
&winX, &winY, |
|
6775 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6776 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6777 |
ypos = __MKSMALLINT(rootY); |
295 | 6778 |
END_INTERRUPTSBLOCKED |
6779 |
%} |
|
6780 |
. |
|
6781 |
^ xpos @ ypos |
|
6782 |
! |
|
6783 |
||
6784 |
rightButtonStateMask |
|
6785 |
"return an integer for masking out the right button from a |
|
6786 |
buttonStates value" |
|
6787 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6788 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6789 |
|
295 | 6790 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6791 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6792 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 6793 |
! |
6794 |
||
6795 |
rootPositionOfLastEvent |
|
6796 |
"return the position in root-window coordinates |
|
6797 |
of the last button, key or pointer event" |
|
6798 |
||
6799 |
^ eventRootX @ eventRootY |
|
6800 |
! ! |
|
6801 |
||
6802 |
!XWorkstation methodsFor:'resources'! |
|
6803 |
||
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6804 |
atomIDOf:aStringOrSymbol |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6805 |
"return an Atoms ID; dont create if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6806 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6807 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6808 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6809 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6810 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6811 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6812 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6813 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6814 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6815 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6816 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6817 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6818 |
atomIDOf:aStringOrSymbol create:create |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6819 |
"return an Atoms ID; if create is true, create it if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6820 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6821 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6822 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6823 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6824 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6825 |
if (ISCONNECTED) { |
850 | 6826 |
if (__isString(aStringOrSymbol) |
6827 |
|| __isSymbol(aStringOrSymbol)) { |
|
6828 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
6829 |
(create == true) ? False : True); |
|
6830 |
if (prop == None) { |
|
6831 |
RETURN (nil); |
|
6832 |
} |
|
6833 |
RETURN ( __MKATOMOBJ(prop) ); |
|
6834 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6835 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6836 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6837 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6838 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6839 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6840 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6841 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6842 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6843 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6844 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6845 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6846 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6847 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6848 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6849 |
atomIDOfCUTBUFFER0 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6850 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6851 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6852 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6853 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6854 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6855 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6856 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6857 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6858 |
atomIDOfLENGTH |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6859 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6860 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6861 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6862 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6863 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6864 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6865 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6866 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6867 |
atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6868 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6869 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6870 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6871 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6872 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6873 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6874 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6875 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6876 |
atomIDOfSECONDARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6877 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6878 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6879 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6880 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6881 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6882 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6883 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6884 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6885 |
atomIDOfSTRING |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6886 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6887 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6888 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6889 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6890 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6891 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6892 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6893 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6894 |
atomName:anAtomID |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6895 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6896 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6897 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6898 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6899 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6900 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6901 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6902 |
if (ISCONNECTED) { |
850 | 6903 |
if (__isAtomID(anAtomID)) { |
6904 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
6905 |
if (name == 0) { |
|
6906 |
RETURN (nil); |
|
6907 |
} |
|
6908 |
str = __MKSTRING(name COMMA_CON); |
|
6909 |
XFree(name); |
|
6910 |
RETURN ( str ); |
|
6911 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6912 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6913 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6914 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6915 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6916 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6917 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6918 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6919 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6920 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6921 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6922 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6923 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6924 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6925 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6926 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6927 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6928 |
|
295 | 6929 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6930 |
"access the displays resource database for a default value |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6931 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6932 |
This is highly X specific and currently not used. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6933 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6934 |
Notice: |
850 | 6935 |
we do not plan to use X's resources for ST/X's defaults, |
6936 |
styles or resources. This would make porting of applications |
|
6937 |
to different platforms much more difficult (Windows has no resource |
|
6938 |
database). If you stay within ST/X's resource files, these can be |
|
6939 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6940 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6941 |
This method is provided for special applications which want to access |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6942 |
existing X resources and are not planned to be ever ported to other |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6943 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6944 |
|
295 | 6945 |
%{ |
6946 |
char *rslt; |
|
6947 |
||
6948 |
if ((__isString(name) || __isSymbol(name)) |
|
6949 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6950 |
&& ISCONNECTED) { |
|
850 | 6951 |
BEGIN_INTERRUPTSBLOCKED |
6952 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
6953 |
(char *)_stringVal(name)); |
|
6954 |
END_INTERRUPTSBLOCKED |
|
6955 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6956 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6957 |
%}. |
295 | 6958 |
self primitiveFailed. |
6959 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6960 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6961 |
"if your ~/.Xdefaults contains an entry such as: |
850 | 6962 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6963 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6964 |
|
850 | 6965 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6966 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6967 |
if your ~/.Xdefaults contains an entry such as: |
850 | 6968 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6969 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6970 |
|
850 | 6971 |
Display getResource:'beNiceToColormap' class:'any' |
6972 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6973 |
" |
295 | 6974 |
! ! |
6975 |
||
6976 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6977 |
||
6978 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6979 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6980 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6981 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6982 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6983 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6984 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6985 |
|rawInfo info| |
295 | 6986 |
|
6987 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6988 |
self primitiveFailed. |
|
6989 |
^ nil |
|
6990 |
]. |
|
6991 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6992 |
rawInfo := Array new:8. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6993 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6994 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6995 |
"3 -> bytes_per_line" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6996 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6997 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6998 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6999 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7000 |
"8 -> bits_per_pixel" |
295 | 7001 |
|
7002 |
"/ had to extract the getPixel call into a separate method, to specify |
|
7003 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
7004 |
"/ of temporary stack space |
|
7005 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7006 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7007 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7008 |
info at:#bitOrder put:(rawInfo at:1). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7009 |
info at:#depth put:(rawInfo at:2). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7010 |
info at:#bytesPerLine put:(rawInfo at:3). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7011 |
info at:#byteOrder put:(rawInfo at:4). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7012 |
info at:#format put:(rawInfo at:5). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7013 |
info at:#bitmapUnit put:(rawInfo at:6). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7014 |
info at:#bitmapPad put:(rawInfo at:7). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7015 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 7016 |
^ info |
7017 |
]. |
|
7018 |
" |
|
7019 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
7020 |
or is too small to hold the bits |
|
7021 |
" |
|
7022 |
^ self primitiveFailed |
|
7023 |
! |
|
7024 |
||
7025 |
getPixelX:x y:y from:aDrawableId |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
7026 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left. |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
7027 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 7028 |
|
7029 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
7030 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7031 |
Window win; |
295 | 7032 |
XImage *img; |
7033 |
int ret; |
|
7034 |
int xpos, ypos; |
|
7035 |
||
7036 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
850 | 7037 |
win = _WindowVal(aDrawableId); |
7038 |
xpos = __intVal(x); |
|
7039 |
ypos = __intVal(y); |
|
7040 |
if ((xpos < 0) || (ypos < 0)) { |
|
7041 |
RETURN ( __MKSMALLINT(0) ); |
|
7042 |
} |
|
7043 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
7044 |
if (img != 0) { |
|
7045 |
ret = XGetPixel(img, 0, 0); |
|
7046 |
XDestroyImage(img); |
|
7047 |
RETURN ( __MKSMALLINT(ret) ); |
|
7048 |
} |
|
295 | 7049 |
} |
7050 |
%}. |
|
7051 |
^ nil |
|
7052 |
! |
|
7053 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7054 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 7055 |
"since XGetImage may allocate huge amount of stack space |
7056 |
(some implementations use alloca), this must run with unlimited stack." |
|
7057 |
||
7058 |
%{ /* UNLIMITEDSTACK */ |
|
7059 |
||
7060 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7061 |
Window win; |
295 | 7062 |
XImage *image = (XImage *)0; |
7063 |
int pad, bytes_per_line, numBytes; |
|
7064 |
||
7065 |
if (__isExternalAddress(aDrawableId) |
|
7066 |
&& __bothSmallInteger(srcx, srcy) |
|
7067 |
&& __bothSmallInteger(w, h) |
|
7068 |
&& __isArray(info) |
|
7069 |
&& __isByteArray(imageBits)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7070 |
win = _WindowVal(aDrawableId); |
555 | 7071 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
7072 |
__intVal(w), __intVal(h), |
|
295 | 7073 |
(unsigned)AllPlanes, ZPixmap); |
7074 |
||
378 | 7075 |
if (! image) { |
7076 |
RETURN ( false ); |
|
7077 |
} |
|
7078 |
||
295 | 7079 |
pad = image->bitmap_pad; |
7080 |
#ifdef SUPERDEBUG |
|
7081 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
7082 |
#endif |
|
7083 |
switch (image->depth) { |
|
7084 |
case 1: |
|
7085 |
case 2: |
|
7086 |
case 4: |
|
7087 |
case 8: |
|
7088 |
case 16: |
|
7089 |
case 24: |
|
7090 |
case 32: |
|
7091 |
numBytes = image->bytes_per_line * image->height; |
|
7092 |
break; |
|
7093 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7094 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7095 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7096 |
numBytes = image->bytes_per_line * image->height; |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7097 |
break; |
295 | 7098 |
} |
7099 |
||
7100 |
#ifdef SUPERDEBUG |
|
555 | 7101 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 7102 |
#endif |
7103 |
||
555 | 7104 |
if (numBytes > __byteArraySize(imageBits)) { |
295 | 7105 |
/* imageBits too small */ |
378 | 7106 |
printf("provided byteArray too small\n"); |
295 | 7107 |
goto fail; |
7108 |
} |
|
7109 |
if (image->bitmap_bit_order == MSBFirst) |
|
555 | 7110 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
295 | 7111 |
else |
555 | 7112 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
7113 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
7114 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
295 | 7115 |
if (image->byte_order == MSBFirst) |
555 | 7116 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
295 | 7117 |
else |
555 | 7118 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7119 |
if (image->format == XYBitmap) |
555 | 7120 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7121 |
else if (image->format == XYPixmap) |
555 | 7122 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7123 |
else if (image->format == ZPixmap) |
555 | 7124 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7125 |
|
555 | 7126 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
7127 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
7128 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
7129 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
295 | 7130 |
XDestroyImage(image); |
7131 |
RETURN ( true ); |
|
7132 |
} |
|
7133 |
fail: |
|
7134 |
if (image) { |
|
7135 |
XDestroyImage(image); |
|
7136 |
} |
|
7137 |
%}. |
|
7138 |
^ false |
|
7139 |
! ! |
|
7140 |
||
7141 |
!XWorkstation methodsFor:'selections'! |
|
7142 |
||
7143 |
getObjectProperty:propertyID from:aWindowID |
|
7144 |
"get an object property; return object or nil" |
|
7145 |
||
7146 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7147 |
type == stringAtom ifTrue:[ |
|
7148 |
^ value |
|
7149 |
]. |
|
7150 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7151 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7152 |
] |
|
7153 |
]. |
|
7154 |
^ nil |
|
7155 |
! |
|
7156 |
||
7157 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7158 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7159 |
||
7160 |
|val typeID cls| |
|
7161 |
||
7162 |
cls := ByteArray. |
|
7163 |
%{ |
|
7164 |
Display *dpy = myDpy; |
|
7165 |
Window window; |
|
7166 |
Atom property; |
|
7167 |
char *cp, *cp2; |
|
7168 |
Atom actual_type; |
|
7169 |
int actual_format,i; |
|
7170 |
unsigned long nitems, bytes_after, nread; |
|
7171 |
unsigned char *data; |
|
7172 |
int ok = 1; |
|
7173 |
# define PROP_SIZE 2048 |
|
7174 |
||
7175 |
if (__isAtomID(propertyID)) { |
|
7176 |
property = _AtomVal(propertyID); |
|
7177 |
if (__isExternalAddress(aWindowID)) { |
|
7178 |
window = _WindowVal(aWindowID); |
|
7179 |
} else { |
|
7180 |
window = DefaultRootWindow(dpy); |
|
7181 |
} |
|
7182 |
||
7183 |
nread = 0; |
|
7184 |
cp = 0; |
|
7185 |
/* |
|
7186 |
fprintf(stderr, "getProperty: "); |
|
7187 |
*/ |
|
7188 |
do { |
|
7189 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7190 |
AnyPropertyType,&actual_type,&actual_format, |
|
7191 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7192 |
!= Success) { |
|
7193 |
ok = 0; |
|
7194 |
break; |
|
7195 |
} |
|
7196 |
typeID = __MKATOMOBJ(actual_type); |
|
7197 |
if (! cp) { |
|
7198 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7199 |
} else { |
|
7200 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7201 |
cp2 = cp + nread; |
|
7202 |
} |
|
7203 |
if (! cp) goto fail; |
|
7204 |
||
7205 |
nread += nitems; |
|
7206 |
bcopy(data, cp2, nitems); |
|
7207 |
XFree(data); |
|
7208 |
/* |
|
7209 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7210 |
*/ |
|
7211 |
} while (bytes_after > 0); |
|
7212 |
/* |
|
7213 |
fprintf(stderr, "\n"); |
|
7214 |
*/ |
|
7215 |
||
7216 |
if (ok) { |
|
7217 |
if (actual_type == XA_STRING) { |
|
7218 |
cp[nread] = '\0'; |
|
7219 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
7220 |
} else { |
|
7221 |
val = __new(nread + OHDR_SIZE); |
|
7222 |
val->o_class = cls; |
|
555 | 7223 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
295 | 7224 |
} |
7225 |
} |
|
7226 |
if (cp) |
|
7227 |
free(cp); |
|
7228 |
} |
|
7229 |
fail: ; |
|
7230 |
%}. |
|
7231 |
typeID isNil ifTrue:[ |
|
7232 |
^ false |
|
7233 |
]. |
|
7234 |
aTwoArgBlock value:typeID value:val. |
|
7235 |
^ true |
|
7236 |
! |
|
7237 |
||
7238 |
getSelectionFor:drawableId |
|
7239 |
"get the object selection - either immediate, or asynchronous. |
|
7240 |
Returns nil, if async request is on its way" |
|
7241 |
||
7242 |
|selProp sel| |
|
7243 |
||
7244 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7245 |
"no primary selection - use cut buffer" |
|
7246 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7247 |
^ sel |
|
7248 |
]. |
|
7249 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7250 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7251 |
^ nil |
|
7252 |
! |
|
7253 |
||
7254 |
getSelectionOwnerOf:selectionAtomID |
|
7255 |
"get the owner of a selection" |
|
7256 |
||
7257 |
%{ /* NOCONTEXT */ |
|
7258 |
Display *dpy = myDpy; |
|
7259 |
Atom selection; |
|
7260 |
Window window; |
|
7261 |
||
7262 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
7263 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7264 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
7265 |
} |
|
7266 |
%}. |
|
7267 |
self primitiveFailed. |
|
7268 |
^ nil |
|
7269 |
! |
|
7270 |
||
7271 |
getTextProperty:propertyID from:aWindowID |
|
7272 |
"get a text property; return string or nil" |
|
7273 |
||
7274 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7275 |
type == stringAtom ifTrue:[ |
|
7276 |
^ value |
|
7277 |
] |
|
7278 |
]. |
|
7279 |
^ nil |
|
7280 |
! |
|
7281 |
||
7282 |
getTextSelectionFor:drawableId |
|
7283 |
"get the text selection - either immediate, or asynchronous. |
|
7284 |
Returns nil, if async request is on its way" |
|
7285 |
||
7286 |
|selProp sel| |
|
7287 |
||
7288 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7289 |
"no primary selection - use cut buffer" |
|
7290 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7291 |
^ sel |
|
7292 |
]. |
|
7293 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7294 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7295 |
^ nil |
|
7296 |
! |
|
7297 |
||
7298 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
7299 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7300 |
will later receive a SelectionNotify event for it." |
|
7301 |
||
7302 |
^ self requestSelection:selectionID |
|
7303 |
property:propertyID |
|
7304 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7305 |
for:aWindowId |
|
7306 |
! |
|
7307 |
||
7308 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
7309 |
"ask the server to send us the selection - the view with id aWindowID |
|
7310 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7311 |
with the selections value)." |
|
7312 |
||
7313 |
%{ /* NOCONTEXT */ |
|
7314 |
Display *dpy = myDpy; |
|
7315 |
Atom sel_prop; |
|
7316 |
char *cp; |
|
7317 |
||
7318 |
if (__isExternalAddress(aWindowId) |
|
7319 |
&& ISCONNECTED |
|
7320 |
&& __isSmallInteger(typeID) |
|
7321 |
&& __isAtomID(selectionID)) { |
|
7322 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7323 |
/* |
|
7324 |
* no owner of primary selection |
|
7325 |
*/ |
|
7326 |
RETURN (false); |
|
7327 |
} |
|
7328 |
/* |
|
7329 |
* PRIMARY selection |
|
7330 |
*/ |
|
7331 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7332 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7333 |
RETURN (true); |
|
7334 |
} |
|
7335 |
%}. |
|
7336 |
self primitiveFailed. |
|
7337 |
^ false |
|
7338 |
||
7339 |
" |
|
7340 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
7341 |
property:(Display atomIDOf:'VT_SELECTION') |
|
7342 |
for:0 |
|
7343 |
" |
|
7344 |
! |
|
7345 |
||
7346 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
7347 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7348 |
will later receive a SelectionNotify event for it." |
|
7349 |
||
7350 |
^ self requestSelection:selectionID |
|
7351 |
property:propertyID |
|
7352 |
type:stringAtom |
|
7353 |
for:aWindowId |
|
7354 |
! |
|
7355 |
||
7356 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
7357 |
"send aString back from a SelectionRequest" |
|
7358 |
||
7359 |
self |
|
7360 |
sendSelection:something |
|
7361 |
selection:primaryAtom |
|
7362 |
property:propertyID |
|
7363 |
target:targetID |
|
7364 |
from:windowID |
|
7365 |
to:requestorID |
|
7366 |
! |
|
7367 |
||
7368 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7369 |
"send aString back from a SelectionRequest" |
|
7370 |
||
7371 |
self |
|
7372 |
setProperty:propertyID |
|
7373 |
type:targetID |
|
7374 |
value:something |
|
7375 |
for:requestorID. |
|
7376 |
self |
|
7377 |
sendSelectionNotifySelection:selectionID |
|
7378 |
property:propertyID |
|
7379 |
target:targetID |
|
7380 |
from:requestorID |
|
7381 |
to:requestorID. |
|
7382 |
! |
|
7383 |
||
7384 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7385 |
"send a selectionNotify back from a SelectionRequest" |
|
7386 |
||
7387 |
%{ /* NOCONTEXT */ |
|
7388 |
Display *dpy = myDpy; |
|
7389 |
||
7390 |
if (__isAtomID(propertyID) |
|
7391 |
&& __isExternalAddress(requestorID) |
|
7392 |
&& ISCONNECTED |
|
7393 |
&& __isAtomID(targetID) |
|
7394 |
&& __isAtomID(selectionID)) { |
|
7395 |
XEvent ev; |
|
7396 |
Window requestor = _WindowVal(requestorID); |
|
7397 |
Atom property = _AtomVal(propertyID); |
|
7398 |
Atom target = _AtomVal(targetID); |
|
7399 |
Atom selection = _AtomVal(selectionID); |
|
7400 |
Status result; |
|
7401 |
||
7402 |
ev.xselection.type = SelectionNotify; |
|
7403 |
ev.xselection.selection = selection; |
|
7404 |
ev.xselection.target = target; |
|
7405 |
if (__isExternalAddress(windowID)) |
|
7406 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7407 |
else |
|
7408 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7409 |
ev.xselection.time = CurrentTime; |
|
7410 |
if (property == None) |
|
7411 |
ev.xselection.property = target; |
|
7412 |
else |
|
7413 |
ev.xselection.property = property; |
|
7414 |
||
7415 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7416 |
ev.xselection.selection, |
|
7417 |
ev.xselection.property, |
|
7418 |
ev.xselection.target, |
|
7419 |
ev.xselection.requestor, |
|
7420 |
requestor)); |
|
7421 |
||
7422 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7423 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7424 |
DPRINTF(("bad status\n")); |
|
382 | 7425 |
RETURN (false); |
295 | 7426 |
} |
382 | 7427 |
RETURN (true) |
7428 |
} |
|
7429 |
%}. |
|
7430 |
self primitiveFailed. |
|
7431 |
^ false |
|
295 | 7432 |
! |
7433 |
||
7434 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7435 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
7436 |
! |
|
7437 |
||
7438 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7439 |
|s| |
|
7440 |
||
7441 |
(anObject isMemberOf:String) ifTrue:[ |
|
7442 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7443 |
]. |
|
7444 |
s := WriteStream on:(ByteArray new:200). |
|
7445 |
anObject storeBinaryOn:s. |
|
7446 |
^ self |
|
7447 |
setProperty:propertyID |
|
7448 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7449 |
value:(s contents) |
|
7450 |
for:aWindowID |
|
7451 |
! |
|
7452 |
||
7453 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7454 |
||
7455 |
%{ /* UNLIMITEDSTACK */ |
|
7456 |
||
7457 |
Display *dpy = myDpy; |
|
7458 |
Atom prop, type; |
|
7459 |
Window window; |
|
7460 |
unsigned int value; |
|
7461 |
||
7462 |
if (__isAtomID(propertyID) |
|
7463 |
&& __isAtomID(typeID) |
|
7464 |
&& ISCONNECTED |
|
7465 |
&& (__isString(anObject) |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7466 |
|| __isSmallInteger(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7467 |
|| __isSymbol(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7468 |
|| __isByteArray(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7469 |
|| __isWords(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7470 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7471 |
prop = _AtomVal(propertyID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7472 |
type = _AtomVal(typeID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7473 |
if (__isExternalAddress(aWindowID)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7474 |
window = _WindowVal(aWindowID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7475 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7476 |
window = DefaultRootWindow(dpy); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7477 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7478 |
if (__isSmallInteger(anObject)) { |
555 | 7479 |
value = __intVal(anObject); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7480 |
XChangeProperty(dpy, window, prop, type, 32, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7481 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7482 |
(unsigned char *)(&value), sizeof(unsigned int)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7483 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7484 |
if (__isByteArray(anObject)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7485 |
XChangeProperty(dpy, window, prop, type, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7486 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7487 |
__ByteArrayInstPtr(anObject)->ba_element, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7488 |
__byteArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7489 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7490 |
/* string or symbol or wordArray-like (16bit-string) object */ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7491 |
if (__isWords(__qClass(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7492 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7493 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7494 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7495 |
__wordArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7496 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7497 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7498 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7499 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7500 |
strlen(__stringVal(anObject))); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7501 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7502 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7503 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7504 |
RETURN (true); |
295 | 7505 |
} |
7506 |
%}. |
|
7507 |
^ false |
|
7508 |
! |
|
7509 |
||
7510 |
setSelection:anObject owner:aWindowId |
|
7511 |
"set the object selection, and make aWindowId be the owner. |
|
7512 |
This can be used by other Smalltalk(X) applications only." |
|
7513 |
||
7514 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7515 |
^ false |
|
7516 |
]. |
|
7517 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7518 |
^ true |
|
7519 |
! |
|
7520 |
||
7521 |
setSelectionOwner:aWindowId of:selectionID |
|
7522 |
"set the owner of a selection; return false if failed" |
|
7523 |
||
7524 |
%{ /* NOCONTEXT */ |
|
7525 |
Display *dpy = myDpy; |
|
7526 |
Window win; |
|
7527 |
||
7528 |
if (__isExternalAddress(aWindowId) |
|
7529 |
&& __isAtomID(selectionID) |
|
7530 |
&& ISCONNECTED) { |
|
7531 |
win = _WindowVal(aWindowId); |
|
7532 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7533 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7534 |
RETURN (false); |
|
7535 |
} |
|
7536 |
RETURN (true); |
|
7537 |
} |
|
7538 |
%} |
|
7539 |
. |
|
7540 |
self primitiveFailed. |
|
7541 |
^ nil |
|
7542 |
! |
|
7543 |
||
7544 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7545 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7546 |
! |
|
7547 |
||
7548 |
setTextSelection:aString owner:aWindowId |
|
7549 |
"set the text selection, and make aWindowId be the owner. |
|
7550 |
This can be used by any other X application." |
|
7551 |
||
7552 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7553 |
'ownerchange failed' errorPrintNL. |
|
7554 |
]. |
|
7555 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7556 |
! ! |
|
7557 |
||
7558 |
!XWorkstation methodsFor:'window stuff'! |
|
7559 |
||
7560 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7561 |
"clear a rectangular area to viewbackground" |
|
7562 |
||
7563 |
%{ /* NOCONTEXT */ |
|
7564 |
||
7565 |
int w, h; |
|
7566 |
||
7567 |
if (__isExternalAddress(aWindowId) |
|
7568 |
&& __bothSmallInteger(x, y) |
|
7569 |
&& __bothSmallInteger(width, height)) { |
|
555 | 7570 |
w = __intVal(width); |
7571 |
h = __intVal(height); |
|
295 | 7572 |
if (w < 0) w = 0; |
7573 |
if (h < 0) h = 0; |
|
555 | 7574 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
295 | 7575 |
RETURN ( self ); |
7576 |
} |
|
7577 |
%} |
|
7578 |
. |
|
7579 |
self primitiveFailed |
|
7580 |
! |
|
7581 |
||
7582 |
clearWindow:aWindowId |
|
7583 |
"clear a window to viewbackground" |
|
7584 |
||
7585 |
%{ /* NOCONTEXT */ |
|
7586 |
||
7587 |
if (__isExternalAddress(aWindowId)) { |
|
7588 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7589 |
RETURN ( self ); |
|
7590 |
} |
|
7591 |
%} |
|
7592 |
. |
|
7593 |
self primitiveFailed |
|
7594 |
! |
|
7595 |
||
7596 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7597 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7598 |
||
7599 |
%{ /* NOCONTEXT */ |
|
7600 |
||
7601 |
XWindowChanges chg; |
|
7602 |
int mask = CWSibling | CWStackMode; |
|
7603 |
||
7604 |
if (__isExternalAddress(aWindowId) |
|
7605 |
&& __isExternalAddress(siblingId)) { |
|
7606 |
if (modeSymbol == @symbol(above)) { |
|
7607 |
chg.stack_mode = Above; |
|
7608 |
} else if (modeSymbol == @symbol(below)) { |
|
7609 |
chg.stack_mode = Below; |
|
7610 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7611 |
chg.stack_mode = TopIf; |
|
7612 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7613 |
chg.stack_mode = BottomIf; |
|
7614 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7615 |
chg.stack_mode = Opposite; |
|
7616 |
} else { |
|
7617 |
mask = CWSibling; |
|
7618 |
} |
|
7619 |
||
7620 |
chg.sibling = _WindowVal(siblingId); |
|
7621 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7622 |
mask, &chg); |
|
7623 |
RETURN ( self ); |
|
7624 |
} |
|
7625 |
bad: ; |
|
7626 |
%} |
|
7627 |
. |
|
7628 |
self primitiveFailed |
|
7629 |
! |
|
7630 |
||
7631 |
lowerWindow:aWindowId |
|
7632 |
"bring a window to back" |
|
7633 |
||
7634 |
%{ /* NOCONTEXT */ |
|
7635 |
||
7636 |
if (__isExternalAddress(aWindowId)) { |
|
7637 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7638 |
RETURN ( self ); |
|
7639 |
} |
|
7640 |
%} |
|
7641 |
. |
|
7642 |
self primitiveFailed |
|
7643 |
! |
|
7644 |
||
7645 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7646 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7647 |
||
7648 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7649 |
||
7650 |
aBoolean ifTrue:[ |
|
7651 |
wicon := aView icon. |
|
7652 |
wicon notNil ifTrue:[ |
|
7653 |
wiconId := wicon id |
|
7654 |
]. |
|
7655 |
wiconView := aView iconView. |
|
7656 |
wiconView notNil ifTrue:[ |
|
7657 |
wiconViewId := wiconView id |
|
7658 |
]. |
|
7659 |
wlabel := aView label. |
|
7660 |
]. |
|
7661 |
%{ |
|
7662 |
||
7663 |
XWMHints wmhints; |
|
7664 |
XSizeHints szhints; |
|
7665 |
Display *dpy = myDpy; |
|
7666 |
Window win; |
|
7667 |
||
7668 |
if (__isExternalAddress(aWindowId)) { |
|
7669 |
win = _WindowVal(aWindowId); |
|
7670 |
||
7671 |
szhints.flags = 0; |
|
7672 |
if (__bothSmallInteger(xPos, yPos)) { |
|
555 | 7673 |
szhints.x = __intVal(xPos); |
7674 |
szhints.y = __intVal(yPos); |
|
295 | 7675 |
szhints.flags |= USPosition; |
7676 |
} |
|
7677 |
if (__bothSmallInteger(w, h)) { |
|
555 | 7678 |
szhints.width = __intVal(w); |
7679 |
szhints.height = __intVal(h); |
|
295 | 7680 |
szhints.flags |= USSize; |
7681 |
} |
|
7682 |
||
7683 |
if (aBoolean == true) { |
|
7684 |
char *windowName; |
|
7685 |
Pixmap iconBitmap = (Pixmap)0; |
|
7686 |
Window iconWindow; |
|
7687 |
||
7688 |
if (__isExternalAddress(wiconId)) |
|
7689 |
iconBitmap = _PixmapVal(wiconId); |
|
7690 |
else |
|
7691 |
iconBitmap = (Pixmap)0; |
|
7692 |
||
7693 |
if (__isExternalAddress(wiconViewId)) |
|
7694 |
iconWindow = _WindowVal(wiconViewId); |
|
7695 |
else |
|
7696 |
iconWindow = (Window)0; |
|
7697 |
||
7698 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7699 |
windowName = (char *)_stringVal(wlabel); |
|
7700 |
else |
|
7701 |
windowName = ""; |
|
7702 |
||
7703 |
if (iconBitmap || windowName) { |
|
7704 |
XSetStandardProperties(dpy, win, |
|
7705 |
windowName, windowName, |
|
7706 |
iconBitmap, |
|
7707 |
0, 0, &szhints); |
|
7708 |
} |
|
7709 |
||
7710 |
wmhints.flags = 0; |
|
7711 |
if (iconBitmap) { |
|
7712 |
wmhints.flags |= IconPixmapHint; |
|
7713 |
wmhints.icon_pixmap = iconBitmap; |
|
7714 |
} |
|
7715 |
if (iconWindow) { |
|
7716 |
wmhints.flags |= IconWindowHint; |
|
7717 |
wmhints.icon_window = iconWindow; |
|
7718 |
} |
|
7719 |
||
7720 |
wmhints.initial_state = IconicState; |
|
7721 |
wmhints.flags |= StateHint; |
|
7722 |
XSetWMHints(dpy, win, &wmhints); |
|
7723 |
} |
|
7724 |
||
7725 |
if (szhints.flags) { |
|
7726 |
XSetNormalHints(dpy, win, &szhints); |
|
7727 |
} |
|
7728 |
||
7729 |
XMapWindow(dpy, win); |
|
7730 |
RETURN ( self ); |
|
7731 |
} |
|
7732 |
%} |
|
7733 |
. |
|
7734 |
self primitiveFailed |
|
7735 |
! |
|
7736 |
||
7737 |
mapWindow:aWindowId |
|
7738 |
"make a window visible" |
|
7739 |
||
7740 |
%{ /* NOCONTEXT */ |
|
7741 |
||
7742 |
if (__isExternalAddress(aWindowId)) { |
|
7743 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7744 |
RETURN ( self ); |
|
7745 |
} |
|
7746 |
%} |
|
7747 |
. |
|
7748 |
self primitiveFailed |
|
7749 |
! |
|
7750 |
||
7751 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7752 |
"move and resize a window" |
|
7753 |
||
7754 |
%{ /* NOCONTEXT */ |
|
7755 |
||
7756 |
int newWidth, newHeight; |
|
7757 |
||
7758 |
if (__isExternalAddress(aWindowId) |
|
7759 |
&& __bothSmallInteger(w, h) |
|
7760 |
&& __bothSmallInteger(x, y)) { |
|
555 | 7761 |
newWidth = __intVal(w); |
7762 |
newHeight = __intVal(h); |
|
295 | 7763 |
if (newWidth < 1) newWidth = 1; |
7764 |
if (newHeight < 1) newHeight = 1; |
|
7765 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
555 | 7766 |
__intVal(x), __intVal(y), |
295 | 7767 |
newWidth, newHeight); |
7768 |
RETURN ( self ); |
|
7769 |
} |
|
7770 |
%} |
|
7771 |
. |
|
7772 |
self primitiveFailed |
|
7773 |
! |
|
7774 |
||
7775 |
moveWindow:aWindowId x:x y:y |
|
7776 |
"move a window" |
|
7777 |
||
7778 |
%{ /* NOCONTEXT */ |
|
7779 |
||
7780 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
555 | 7781 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
295 | 7782 |
RETURN ( self ); |
7783 |
} |
|
7784 |
%} |
|
7785 |
. |
|
7786 |
self primitiveFailed |
|
7787 |
! |
|
7788 |
||
7789 |
raiseWindow:aWindowId |
|
7790 |
"bring a window to front" |
|
7791 |
||
7792 |
%{ /* NOCONTEXT */ |
|
7793 |
||
7794 |
if (__isExternalAddress(aWindowId)) { |
|
7795 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7796 |
RETURN ( self ); |
|
7797 |
} |
|
7798 |
%} |
|
7799 |
. |
|
7800 |
self primitiveFailed |
|
7801 |
! |
|
7802 |
||
7803 |
resizeWindow:aWindowId width:w height:h |
|
7804 |
"resize a window" |
|
7805 |
||
7806 |
%{ /* NOCONTEXT */ |
|
7807 |
||
7808 |
int newWidth, newHeight; |
|
7809 |
||
7810 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
555 | 7811 |
newWidth = __intVal(w); |
7812 |
newHeight = __intVal(h); |
|
295 | 7813 |
if (newWidth < 1) newWidth = 1; |
7814 |
if (newHeight < 1) newHeight = 1; |
|
7815 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7816 |
RETURN ( self ); |
|
7817 |
} |
|
7818 |
%} |
|
7819 |
. |
|
7820 |
self primitiveFailed |
|
7821 |
! |
|
7822 |
||
7823 |
setBackingStore:how in:aWindowId |
|
7824 |
"turn on/off backing-store for a window" |
|
7825 |
||
7826 |
%{ /* NOCONTEXT */ |
|
7827 |
||
7828 |
XSetWindowAttributes wa; |
|
7829 |
||
7830 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7831 |
if (__INST(ignoreBackingStore) != true) { |
295 | 7832 |
if (how == @symbol(always)) wa.backing_store = Always; |
7833 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7834 |
else if (how == true) wa.backing_store = Always; |
|
7835 |
else wa.backing_store = 0; |
|
7836 |
BEGIN_INTERRUPTSBLOCKED |
|
7837 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7838 |
END_INTERRUPTSBLOCKED |
|
7839 |
} |
|
7840 |
RETURN ( self ); |
|
7841 |
} |
|
7842 |
%}. |
|
7843 |
self primitiveFailed |
|
7844 |
! |
|
7845 |
||
7846 |
setBitGravity:how in:aWindowId |
|
7847 |
"set bit gravity for a window" |
|
7848 |
||
7849 |
%{ /* NOCONTEXT */ |
|
7850 |
||
7851 |
XSetWindowAttributes wa; |
|
7852 |
||
7853 |
if (__isExternalAddress(aWindowId)) { |
|
7854 |
if (how == @symbol(NorthWest)) { |
|
7855 |
wa.bit_gravity = NorthWestGravity; |
|
7856 |
} else if (how == @symbol(NorthEast)) { |
|
7857 |
wa.bit_gravity = NorthEastGravity; |
|
7858 |
} else if (how == @symbol(SouthWest)) { |
|
7859 |
wa.bit_gravity = SouthWestGravity; |
|
7860 |
} else if (how == @symbol(SouthEast)) { |
|
7861 |
wa.bit_gravity = SouthEastGravity; |
|
7862 |
} else if (how == @symbol(Center)) { |
|
7863 |
wa.bit_gravity = CenterGravity; |
|
7864 |
} else if (how == @symbol(North)) { |
|
7865 |
wa.bit_gravity = NorthGravity; |
|
7866 |
} else if (how == @symbol(South)) { |
|
7867 |
wa.bit_gravity = SouthGravity; |
|
7868 |
} else if (how == @symbol(West)) { |
|
7869 |
wa.bit_gravity = WestGravity; |
|
7870 |
} else if (how == @symbol(East)) { |
|
7871 |
wa.bit_gravity = EastGravity; |
|
7872 |
} else { |
|
7873 |
wa.bit_gravity = NorthWestGravity; |
|
7874 |
} |
|
7875 |
||
7876 |
BEGIN_INTERRUPTSBLOCKED |
|
7877 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7878 |
END_INTERRUPTSBLOCKED |
|
7879 |
RETURN ( self ); |
|
7880 |
} |
|
7881 |
%}. |
|
7882 |
self primitiveFailed |
|
7883 |
! |
|
7884 |
||
7885 |
setCursor:aCursorId in:aWindowId |
|
7886 |
"define a windows cursor" |
|
7887 |
||
7888 |
%{ /* NOCONTEXT */ |
|
7889 |
||
7890 |
Display *dpy = myDpy; |
|
7891 |
||
7892 |
if (__isExternalAddress(aWindowId) |
|
7893 |
&& __isExternalAddress(aCursorId)) { |
|
7894 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7895 |
RETURN ( self ); |
|
7896 |
} |
|
7897 |
%}. |
|
7898 |
self primitiveFailed |
|
7899 |
! |
|
7900 |
||
7901 |
setIconName:aString in:aWindowId |
|
7902 |
"define a windows iconname" |
|
7903 |
||
7904 |
%{ /* NOCONTEXT */ |
|
7905 |
||
7906 |
if (__isExternalAddress(aWindowId) |
|
7907 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7908 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7909 |
RETURN ( self ); |
|
7910 |
} |
|
7911 |
%}. |
|
7912 |
self primitiveFailed |
|
7913 |
! |
|
7914 |
||
7915 |
setSaveUnder:yesOrNo in:aWindowId |
|
7916 |
"turn on/off save-under for a window" |
|
7917 |
||
7918 |
%{ /* NOCONTEXT */ |
|
7919 |
||
7920 |
XSetWindowAttributes wa; |
|
7921 |
||
7922 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7923 |
if (__INST(hasSaveUnder) == true) { |
295 | 7924 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
7925 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7926 |
} |
|
7927 |
RETURN ( self ); |
|
7928 |
} |
|
7929 |
%}. |
|
7930 |
self primitiveFailed |
|
7931 |
! |
|
7932 |
||
7933 |
setTransient:aWindowId for:aMainWindowId |
|
7934 |
"set aWindowId to be a transient of aMainWindow" |
|
7935 |
||
7936 |
%{ /* NOCONTEXT */ |
|
7937 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7938 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7939 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7940 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7941 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7942 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7943 |
} else { |
374 | 7944 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7945 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7946 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7947 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7948 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7949 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7950 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7951 |
RETURN ( self ); |
7952 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7953 |
getOutOfHere: ; |
295 | 7954 |
%}. |
7955 |
self primitiveFailed |
|
7956 |
! |
|
7957 |
||
7958 |
setWindowBackground:aColorIndex in:aWindowId |
|
7959 |
"set the windows background color. This is the color with which |
|
7960 |
the view is filled whenever exposed. Do not confuse this with |
|
7961 |
the background drawing color, which is used with opaque drawing." |
|
7962 |
||
7963 |
%{ /* NOCONTEXT */ |
|
7964 |
||
7965 |
if (__isExternalAddress(aWindowId) |
|
7966 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7967 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7968 |
RETURN ( self ); |
7969 |
} |
|
7970 |
%}. |
|
7971 |
self primitiveFailed |
|
7972 |
! |
|
7973 |
||
7974 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7975 |
"set the windows background pattern to be a form. |
|
7976 |
This is the pattern with which the view is filled whenever exposed. |
|
7977 |
Do not confuse this with the background drawing color, which is used |
|
7978 |
with opaque drawing." |
|
7979 |
||
7980 |
%{ /* NOCONTEXT */ |
|
7981 |
||
7982 |
if (__isExternalAddress(aWindowId) |
|
7983 |
&& __isExternalAddress(aPixmapId)) { |
|
7984 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7985 |
RETURN ( self ); |
|
7986 |
} |
|
7987 |
%}. |
|
7988 |
self primitiveFailed |
|
7989 |
! |
|
7990 |
||
7991 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7992 |
"set the windows border color" |
|
7993 |
||
7994 |
%{ /* NOCONTEXT */ |
|
7995 |
||
7996 |
if (__isExternalAddress(aWindowId) |
|
7997 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7998 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7999 |
RETURN ( self ); |
8000 |
} |
|
8001 |
%}. |
|
8002 |
self primitiveFailed |
|
8003 |
! |
|
8004 |
||
8005 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
8006 |
"set the windows border pattern" |
|
8007 |
||
8008 |
%{ /* NOCONTEXT */ |
|
8009 |
||
8010 |
if (__isExternalAddress(aWindowId) |
|
8011 |
&& __isExternalAddress(aPixmapId)) { |
|
8012 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
8013 |
RETURN ( self ); |
|
8014 |
} |
|
8015 |
%} |
|
8016 |
. |
|
8017 |
self primitiveFailed |
|
8018 |
! |
|
8019 |
||
8020 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
8021 |
"set the windows border shape" |
|
8022 |
||
8023 |
hasShapeExtension ifFalse:[^ self]. |
|
8024 |
||
8025 |
%{ /* NOCONTEXT */ |
|
8026 |
||
8027 |
#ifdef SHAPE |
|
8028 |
if (__isExternalAddress(aWindowId) |
|
8029 |
&& __isExternalAddress(aPixmapId)) { |
|
8030 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
8031 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
8032 |
RETURN ( self ); |
|
8033 |
} |
|
8034 |
#endif |
|
8035 |
%}. |
|
8036 |
self primitiveFailed |
|
8037 |
! |
|
8038 |
||
8039 |
setWindowBorderWidth:aNumber in:aWindowId |
|
8040 |
"set the windows border width" |
|
8041 |
||
8042 |
%{ /* NOCONTEXT */ |
|
8043 |
||
8044 |
if (__isExternalAddress(aWindowId) |
|
8045 |
&& __isSmallInteger(aNumber)) { |
|
555 | 8046 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
295 | 8047 |
RETURN ( self ); |
8048 |
} |
|
8049 |
%}. |
|
8050 |
self primitiveFailed |
|
8051 |
! |
|
8052 |
||
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8053 |
setWindowClass:wClass name:wName in:aWindowId |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8054 |
"define class and name of a window. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8055 |
This may be used by the window manager to |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8056 |
select client specific resources." |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8057 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8058 |
%{ |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8059 |
if (__isExternalAddress(aWindowId)) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8060 |
XClassHint classhint; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8061 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8062 |
classhint.res_class = classhint.res_name = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8063 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8064 |
if (__isString(wClass) || __isSymbol(wClass)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8065 |
classhint.res_class = (char *)_stringVal(wClass); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8066 |
} else if (wClass != nil) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8067 |
goto error; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8068 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8069 |
if (__isString(wName) || __isSymbol(wName)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8070 |
classhint.res_name = (char *)_stringVal(wName); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8071 |
} else if (wName != nil) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8072 |
goto error; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8073 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8074 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8075 |
RETURN ( self ); |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8076 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8077 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8078 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8079 |
self primitiveFailed |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8080 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8081 |
|
295 | 8082 |
setWindowGravity:how in:aWindowId |
8083 |
"set window gravity for a window" |
|
8084 |
||
8085 |
%{ /* NOCONTEXT */ |
|
8086 |
||
8087 |
XSetWindowAttributes wa; |
|
8088 |
||
8089 |
if (__isExternalAddress(aWindowId)) { |
|
8090 |
if (how == @symbol(NorthWest)) { |
|
8091 |
wa.win_gravity = NorthWestGravity; |
|
8092 |
} else if (how == @symbol(NorthEast)) { |
|
8093 |
wa.win_gravity = NorthEastGravity; |
|
8094 |
} else if (how == @symbol(SouthWest)) { |
|
8095 |
wa.win_gravity = SouthWestGravity; |
|
8096 |
} else if (how == @symbol(SouthEast)) { |
|
8097 |
wa.win_gravity = SouthEastGravity; |
|
8098 |
} else if (how == @symbol(Center)) { |
|
8099 |
wa.win_gravity = CenterGravity; |
|
8100 |
} else if (how == @symbol(North)) { |
|
8101 |
wa.win_gravity = NorthGravity; |
|
8102 |
} else if (how == @symbol(South)) { |
|
8103 |
wa.win_gravity = SouthGravity; |
|
8104 |
} else if (how == @symbol(West)) { |
|
8105 |
wa.win_gravity = WestGravity; |
|
8106 |
} else if (how == @symbol(East)) { |
|
8107 |
wa.win_gravity = EastGravity; |
|
8108 |
} else { |
|
8109 |
wa.win_gravity = NorthWestGravity; |
|
8110 |
} |
|
8111 |
||
8112 |
BEGIN_INTERRUPTSBLOCKED |
|
8113 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8114 |
END_INTERRUPTSBLOCKED |
|
8115 |
RETURN ( self ); |
|
8116 |
} |
|
8117 |
%}. |
|
8118 |
self primitiveFailed |
|
8119 |
! |
|
8120 |
||
8121 |
setWindowIcon:aForm in:aWindowId |
|
8122 |
"define a bitmap to be used as icon" |
|
8123 |
||
8124 |
|iconId| |
|
8125 |
||
8126 |
aForm notNil ifTrue:[ |
|
8127 |
iconId := aForm id |
|
8128 |
]. |
|
8129 |
%{ |
|
8130 |
if (__isExternalAddress(iconId) |
|
8131 |
&& __isExternalAddress(aWindowId)) { |
|
8132 |
XWMHints hints; |
|
8133 |
||
8134 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8135 |
hints.flags = IconPixmapHint; |
|
8136 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8137 |
RETURN ( self ); |
|
8138 |
} |
|
8139 |
%}. |
|
8140 |
self primitiveFailed |
|
8141 |
! |
|
8142 |
||
8143 |
setWindowIconWindow:aView in:aWindowId |
|
8144 |
"define a window to be used as icon" |
|
8145 |
||
8146 |
|iconWindowId| |
|
8147 |
||
8148 |
aView notNil ifTrue:[ |
|
8149 |
iconWindowId := aView id |
|
8150 |
]. |
|
8151 |
%{ |
|
8152 |
if (__isExternalAddress(iconWindowId) |
|
8153 |
&& __isExternalAddress(aWindowId)) { |
|
8154 |
XWMHints wmhints; |
|
8155 |
||
8156 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
8157 |
wmhints.flags = IconWindowHint; |
|
8158 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
8159 |
RETURN ( self ); |
|
8160 |
} |
|
8161 |
%}. |
|
8162 |
self primitiveFailed |
|
8163 |
! |
|
8164 |
||
8165 |
setWindowName:aString in:aWindowId |
|
8166 |
"define a windows name" |
|
8167 |
||
8168 |
%{ /* NOCONTEXT */ |
|
8169 |
||
8170 |
if (__isExternalAddress(aWindowId) |
|
8171 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
8172 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
8173 |
RETURN ( self ); |
|
8174 |
} |
|
8175 |
%}. |
|
8176 |
self primitiveFailed |
|
8177 |
! |
|
8178 |
||
8179 |
setWindowShape:aPixmapId in:aWindowId |
|
8180 |
"set the windows shape" |
|
8181 |
||
8182 |
hasShapeExtension ifFalse:[^ self]. |
|
8183 |
||
8184 |
%{ /* NOCONTEXT */ |
|
8185 |
||
8186 |
#ifdef SHAPE |
|
8187 |
if (__isExternalAddress(aWindowId) |
|
8188 |
&& __isExternalAddress(aPixmapId)) { |
|
8189 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
8190 |
0, 0, |
|
8191 |
_PixmapVal(aPixmapId), ShapeSet); |
|
8192 |
RETURN ( self ); |
|
8193 |
} |
|
8194 |
#endif |
|
8195 |
%}. |
|
8196 |
self primitiveFailed |
|
8197 |
! |
|
8198 |
||
8199 |
unmapWindow:aWindowId |
|
8200 |
"make a window invisible" |
|
8201 |
||
8202 |
%{ /* NOCONTEXT */ |
|
8203 |
||
8204 |
if (__isExternalAddress(aWindowId)) { |
|
8205 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
8206 |
RETURN ( self ); |
|
8207 |
} |
|
8208 |
%} |
|
8209 |
. |
|
8210 |
self primitiveFailed |
|
8211 |
! ! |
|
8212 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
8213 |
!XWorkstation class methodsFor:'documentation'! |
295 | 8214 |
|
8215 |
version |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8216 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.154 1996-07-19 16:39:53 cg Exp $' |
295 | 8217 |
! ! |
8218 |
XWorkstation initialize! |