author | Claus Gittinger <cg@exept.de> |
Wed, 24 Jul 1996 13:50:07 +0200 | |
changeset 995 | 2f2c0b2bff1a |
parent 994 | 7e720b29c838 |
child 1008 | ca0a38a11bdc |
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 |
|
975 | 14 |
instanceVariableNames:'screen hasShapeExtension 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 |
/* |
|
186 | 116 |
* PEX extension - if available |
117 |
*/ |
|
118 |
#ifdef PEX5 |
|
119 |
# include <PEX5/PEX.h> |
|
120 |
#endif |
|
121 |
||
122 |
/* |
|
123 |
* XImage extension - if available |
|
124 |
*/ |
|
125 |
#ifdef XIE |
|
126 |
# include <X11/extensions/XIE.h> |
|
127 |
#endif |
|
128 |
||
129 |
/* |
|
90 | 130 |
* when I have more time to check it out, I will support display-PS |
0 | 131 |
*/ |
132 |
#ifdef DPS |
|
133 |
# ifdef sgi |
|
134 |
# include <X11/extensions/XDPS.h> |
|
135 |
# include <X11/extensions/XDPSlib.h> |
|
136 |
# include <X11/extensions/dpsXclient.h> |
|
137 |
# else |
|
138 |
# include <DPS/XDPS.h> |
|
139 |
# include <DPS/XDPSlib.h> |
|
140 |
# include <DPS/dpsXclient.h> |
|
141 |
# endif |
|
142 |
#endif |
|
143 |
||
90 | 144 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
145 |
/* |
|
146 |
* accessing private data in Display ... sorry |
|
147 |
*/ |
|
148 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
149 |
#else |
|
150 |
# define DISPLAYACCESS(d) d |
|
151 |
#endif |
|
152 |
||
78 | 153 |
/* |
154 |
* some defines - tired of typing ... |
|
155 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
156 |
#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
|
157 |
#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
|
158 |
#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
|
159 |
#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
|
160 |
#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
|
161 |
#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
|
162 |
#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
|
163 |
|
211 | 164 |
#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
|
165 |
#define _AtomVal(o) __intVal(o) |
211 | 166 |
#define __isAtomID(o) __isSmallInteger(o) |
167 |
||
555 | 168 |
#define myDpy _DisplayVal(__INST(displayId)) |
169 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 170 |
|
171 |
#ifndef THISCONTEXT_IN_REGISTER |
|
172 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
173 |
# define END_INTERRUPTSBLOCKED /* */ |
|
174 |
#else |
|
175 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
176 |
{ \ |
|
850 | 177 |
int needUnblock = 0; \ |
178 |
extern OBJ __thisContext__; \ |
|
179 |
\ |
|
180 |
__thisContext__ = __thisContext;\ |
|
181 |
if (!__interruptsBlocked) { \ |
|
182 |
__BLOCKINTERRUPTS(); \ |
|
183 |
needUnblock = 1; \ |
|
184 |
} |
|
78 | 185 |
|
186 |
# define END_INTERRUPTSBLOCKED \ |
|
850 | 187 |
__thisContext = __thisContext; \ |
188 |
__thisContext__ = 0; \ |
|
189 |
if (needUnblock) { \ |
|
190 |
__UNBLOCKINTERRUPTS(); \ |
|
191 |
} \ |
|
78 | 192 |
} |
193 |
||
194 |
#endif |
|
195 |
%} |
|
196 |
! ! |
|
197 |
||
198 |
!XWorkstation primitiveVariables! |
|
199 |
%{ |
|
0 | 200 |
/* |
146 | 201 |
* remembered info from private error handler |
0 | 202 |
*/ |
2 | 203 |
static char lastErrorMsg[80] = ""; |
204 |
static unsigned lastRequestCode = 0; |
|
205 |
static unsigned lastMinorCode = 0; |
|
206 |
static unsigned lastResource = 0; |
|
129 | 207 |
|
208 |
static int __debug__ = 0; |
|
209 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 210 |
%} |
211 |
! ! |
|
212 |
||
213 |
!XWorkstation primitiveFunctions! |
|
214 |
%{ |
|
18 | 215 |
/* |
144 | 216 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
217 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 218 |
* the implementation below is somewhat wrong: it will |
78 | 219 |
* report all errors for Display, even though there could be |
162 | 220 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
221 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 222 |
*/ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
223 |
|
12 | 224 |
__XErrorHandler__(dpy, event) |
0 | 225 |
Display *dpy; |
226 |
XErrorEvent *event; |
|
227 |
{ |
|
228 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
|
229 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 230 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 231 |
} |
2 | 232 |
lastRequestCode = event->request_code; |
233 |
lastMinorCode = event->minor_code; |
|
234 |
lastResource = event->resourceid; |
|
911 | 235 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
236 |
/* |
|
237 |
* this is a BadWindow error for X_DestroyWindow. |
|
238 |
* ignore it here, since it results from the GC freeing windows |
|
239 |
* in non bottom-up window order. |
|
240 |
*/ |
|
241 |
return 0; |
|
242 |
} |
|
2 | 243 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
244 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
245 |
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
|
246 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
247 |
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
|
248 |
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
|
249 |
} |
43 | 250 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
251 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 252 |
return 0; |
253 |
} |
|
254 |
||
90 | 255 |
#ifdef VIRTUAL_ROOT |
0 | 256 |
/* |
18 | 257 |
* added since RootWindow-macro is not suficient |
258 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
259 |
*/ |
|
260 |
static Window |
|
261 |
getRootWindow(dpy, screen) |
|
262 |
Display *dpy; |
|
263 |
{ |
|
264 |
Window root; |
|
265 |
Atom vRootAtom = None; |
|
266 |
int i; |
|
267 |
Window rootReturn, parentReturn; |
|
268 |
Window* children; |
|
269 |
unsigned int numChildren; |
|
270 |
||
271 |
root = RootWindow(dpy, screen); |
|
272 |
/* |
|
273 |
* on IRIS, this creates a badwindow error - why ? |
|
274 |
* children contains a funny window (000034) |
|
275 |
*/ |
|
90 | 276 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 277 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 278 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
279 |
if (vRootAtom != None) { |
|
280 |
for (i=0; i < numChildren; i++) { |
|
281 |
Atom actual_type; |
|
282 |
int actual_format; |
|
283 |
unsigned long nitems, bytesafter; |
|
284 |
Window* newRoot = (Window*) 0; |
|
285 |
||
286 |
if (children[i]) { |
|
287 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
288 |
0L, 1L, False, XA_WINDOW, |
|
289 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
290 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
291 |
root = *newRoot; |
|
292 |
break; |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
296 |
if (children) XFree( children ); |
|
297 |
} |
|
18 | 298 |
} |
90 | 299 |
# endif |
18 | 300 |
return root; |
301 |
} |
|
90 | 302 |
#endif |
0 | 303 |
%} |
78 | 304 |
! ! |
0 | 305 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
306 |
!XWorkstation class methodsFor:'documentation'! |
295 | 307 |
|
308 |
copyright |
|
309 |
" |
|
310 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
311 |
All Rights Reserved |
|
312 |
||
313 |
This software is furnished under a license and may be used |
|
314 |
only in accordance with the terms of that license and with the |
|
315 |
inclusion of the above copyright notice. This software may not |
|
316 |
be provided or otherwise made available to, or used by, any |
|
317 |
other person. No title to or ownership of the software is |
|
318 |
hereby transferred. |
|
319 |
" |
|
320 |
! |
|
321 |
||
322 |
documentation |
|
323 |
" |
|
324 |
this class provides the interface to X11. It redefines all required methods |
|
325 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
326 |
limited to one display - in theory, you can create Views on many displays |
|
327 |
simultanously. However, the default setup is for one display only. |
|
328 |
To support multiple displays, you will have to start another event dispatcher |
|
329 |
process for the other display(s) and create the other views with a slightly |
|
330 |
different protocol. However, 'normal' applications do not have to care for |
|
331 |
all of this ... |
|
332 |
||
333 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 334 |
|
335 |
[author:] |
|
850 | 336 |
Claus Gittinger |
295 | 337 |
" |
338 |
! ! |
|
339 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
340 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
341 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
342 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
343 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
344 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
345 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
346 |
|
386 | 347 |
RawKeysymTranslation isNil ifTrue:[ |
348 |
"/ the following table maps X-keyevents to ST/X |
|
349 |
"/ device independed events. |
|
350 |
"/ It is NOT meant as a keyboardMap replacement. |
|
351 |
||
352 |
RawKeysymTranslation := d := Dictionary new. |
|
353 |
d at:'Delete_line' put:#DeleteLine. |
|
354 |
d at:'Delete_word' put:#DeleteWord. |
|
355 |
d at:'Down' put:#CursorDown. |
|
356 |
d at:'Up' put:#CursorUp. |
|
357 |
d at:'Left' put:#CursorLeft. |
|
358 |
d at:'Right' put:#CursorRight. |
|
359 |
] |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
360 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
361 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
362 |
!XWorkstation class methodsFor:'error handling'! |
2 | 363 |
|
129 | 364 |
debug:aBoolean |
365 |
%{ /* NOCONTEXT */ |
|
366 |
||
367 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
368 |
%} |
|
369 |
! |
|
370 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
371 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
372 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
373 |
#ifdef COUNT_RESOURCES |
928 | 374 |
printf("colors %d bitmaps %d view %d gc %d cursor %d font %d\n", |
375 |
__cnt_color, __cnt_bitmap, |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
376 |
__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
|
377 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
378 |
%} |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
379 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
380 |
|
78 | 381 |
errorStringOfLastError |
382 |
%{ |
|
216 | 383 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 384 |
%} |
385 |
! |
|
386 |
||
135 | 387 |
lastErrorString |
2 | 388 |
"return the last X-error string - |
389 |
when buffering is on, this may be |
|
390 |
an error for a long-ago operation" |
|
78 | 391 |
|
392 |
|string requestCode s match line| |
|
393 |
||
394 |
string := self errorStringOfLastError. |
|
395 |
requestCode := self requestCodeOfLastError. |
|
396 |
" |
|
397 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
398 |
and append the name of the corresponding X-request |
|
399 |
" |
|
400 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
401 |
s notNil ifTrue:[ |
|
402 |
match := 'XRequest.' , requestCode printString. |
|
403 |
line := s peekForLineStartingWith:match. |
|
404 |
line notNil ifTrue:[ |
|
405 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
406 |
]. |
|
407 |
s close. |
|
408 |
]. |
|
409 |
^ string |
|
295 | 410 |
! |
411 |
||
412 |
minorCodeOfLastError |
|
413 |
%{ /* NOCONTEXT */ |
|
414 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
415 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 416 |
%} |
417 |
! |
|
418 |
||
419 |
requestCodeOfLastError |
|
152 | 420 |
%{ /* NOCONTEXT */ |
421 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
422 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 423 |
%} |
135 | 424 |
! |
425 |
||
295 | 426 |
resourceIdOfLastError |
0 | 427 |
%{ /* NOCONTEXT */ |
295 | 428 |
|
429 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 430 |
%} |
431 |
! ! |
|
432 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
433 |
!XWorkstation class methodsFor:'queries'! |
104 | 434 |
|
435 |
platformName |
|
133 | 436 |
"ST-80 compatibility. |
437 |
Return a string describing the display systems platform." |
|
438 |
||
715 | 439 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
440 |
||
441 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 442 |
! ! |
443 |
||
0 | 444 |
!XWorkstation methodsFor:'accessing & queries'! |
445 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
446 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
447 |
"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
|
448 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
449 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
450 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
451 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
452 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
453 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
454 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
455 |
|
295 | 456 |
blackpixel |
457 |
"return the colornumber of black" |
|
458 |
||
459 |
^ blackpixel |
|
460 |
! |
|
461 |
||
462 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
463 |
"return the state-mask for button1 in motion events' state-field. |
295 | 464 |
For backward compatibility." |
465 |
||
466 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
467 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 468 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
469 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
470 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
471 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
472 |
" |
295 | 473 |
! |
474 |
||
475 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
476 |
"return the state-mask for button2 in motion events' state-field |
295 | 477 |
For backward compatibility." |
478 |
||
479 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
480 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 481 |
%} |
482 |
! |
|
483 |
||
484 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
485 |
"return the state-mask for button3 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(Button3MotionMask)); |
295 | 490 |
%} |
491 |
! |
|
492 |
||
493 |
buttonMotionMask:aButton |
|
494 |
"return the state-mask for button1 in motion events state-field. |
|
495 |
This is the devices mask." |
|
496 |
||
497 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
498 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
499 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
500 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
501 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
502 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
503 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
504 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
505 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 506 |
} |
507 |
%}. |
|
508 |
^ nil |
|
509 |
! |
|
510 |
||
382 | 511 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
512 |
"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
|
513 |
|
382 | 514 |
%{ /* NOCONTEXT */ |
515 |
RETURN (__MKSMALLINT(ControlMask)); |
|
516 |
%} |
|
517 |
! |
|
518 |
||
295 | 519 |
defaultEventMask |
520 |
"return a mask to enable some events by default." |
|
521 |
||
522 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
523 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 524 |
KeyPressMask | KeyReleaseMask | |
525 |
EnterWindowMask | LeaveWindowMask | |
|
526 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
527 |
%} |
|
528 |
! |
|
529 |
||
0 | 530 |
displayFileDescriptor |
531 |
"return the displays fileNumber - for select" |
|
532 |
||
533 |
%{ /* NOCONTEXT */ |
|
534 |
||
150 | 535 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
536 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 537 |
} |
538 |
RETURN (nil); |
|
0 | 539 |
%} |
540 |
! |
|
541 |
||
133 | 542 |
displayName |
543 |
"return the X-connections display name. |
|
544 |
This is (currently) nil for the default display, |
|
545 |
something like foo:0 for any other remote display. |
|
546 |
Future versions may return non-nil strings for the default display as well." |
|
547 |
||
548 |
^ displayName |
|
549 |
! |
|
550 |
||
341 | 551 |
protocolVersion |
552 |
"return the X-servers protocol version - should normally not be of |
|
553 |
any interest" |
|
554 |
||
555 |
%{ /* NOCONTEXT */ |
|
556 |
if (ISCONNECTED) { |
|
557 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
558 |
} |
|
559 |
RETURN (nil); |
|
560 |
%} |
|
561 |
||
562 |
" |
|
563 |
Display protocolVersion |
|
564 |
" |
|
565 |
! |
|
566 |
||
567 |
serverVendor |
|
568 |
"return the X-server vendor string - this should normally not be of |
|
569 |
any interest, but can be for special cases |
|
570 |
(to avoid bugs in certain implementations)" |
|
571 |
%{ |
|
572 |
if (ISCONNECTED) { |
|
573 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
574 |
} |
|
575 |
RETURN (nil); |
|
576 |
%} |
|
577 |
||
578 |
" |
|
579 |
Display serverVendor |
|
580 |
" |
|
581 |
! |
|
582 |
||
382 | 583 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
584 |
"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
|
585 |
|
382 | 586 |
%{ /* NOCONTEXT */ |
587 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
588 |
%} |
|
589 |
! |
|
590 |
||
341 | 591 |
translatePoint:aPoint from:windowId1 to:windowId2 |
592 |
"given a point in window1, return the coordinate in window2. |
|
593 |
This expects a device coordinate (relative to the first views origin) |
|
594 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
595 |
- use to xlate points from a window to rootwindow" |
|
596 |
||
597 |
|x1 y1 x2 y2| |
|
598 |
||
599 |
x1 := x2 := aPoint x truncated. |
|
600 |
y1 := y2 := aPoint y truncated. |
|
601 |
%{ |
|
602 |
int xpos, ypos; |
|
603 |
Window w1, w2, child_return; |
|
555 | 604 |
int screen = __intVal(__INST(screen)); |
341 | 605 |
Display *dpy = myDpy; |
606 |
||
607 |
if (__isExternalAddress(windowId1) |
|
608 |
&& __isExternalAddress(windowId2) |
|
609 |
&& __bothSmallInteger(x1, y1)) { |
|
610 |
w1 = _WindowVal(windowId1); |
|
611 |
w2 = _WindowVal(windowId2); |
|
612 |
#ifdef VIRTUAL_ROOT |
|
613 |
if ((w1 == RootWindow(dpy, screen)) |
|
614 |
|| (w2 == RootWindow(dpy, screen))) { |
|
615 |
if (w1 == RootWindow(dpy, screen)) { |
|
616 |
w1 = getRootWindow(dpy, screen); |
|
617 |
} |
|
618 |
if (w2 == RootWindow(dpy, screen)) { |
|
619 |
w2 = getRootWindow(dpy, screen); |
|
620 |
} |
|
621 |
} |
|
622 |
#endif |
|
623 |
BEGIN_INTERRUPTSBLOCKED |
|
624 |
XTranslateCoordinates(dpy, w1, w2, |
|
555 | 625 |
__intVal(x1), __intVal(y1), |
341 | 626 |
&xpos, &ypos, &child_return); |
627 |
END_INTERRUPTSBLOCKED |
|
628 |
x2 = __MKSMALLINT(xpos); |
|
629 |
y2 = __MKSMALLINT(ypos); |
|
630 |
} |
|
631 |
%}. |
|
632 |
||
633 |
^ (x2 @ y2) |
|
634 |
! |
|
635 |
||
636 |
vendorRelease |
|
637 |
"return the X-servers vendor release - should normally not be of |
|
638 |
any interest, but can be for special cases. |
|
639 |
(to avoid bugs in certain implementations)" |
|
640 |
||
641 |
%{ /* NOCONTEXT */ |
|
642 |
if (ISCONNECTED) { |
|
643 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
644 |
} |
|
645 |
RETURN (nil); |
|
646 |
%} |
|
647 |
||
648 |
" |
|
649 |
Display vendorRelease |
|
650 |
" |
|
651 |
! |
|
652 |
||
653 |
viewIdFromPoint:aPoint in:windowId |
|
654 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
655 |
hit by this coordinate. Return nil if no view was hit. |
|
656 |
The returned id may be the id of a non ST view. |
|
657 |
- used to find the window to drop objects after a cross-view drag." |
|
658 |
||
659 |
%{ /* NOCONTEXT */ |
|
660 |
||
661 |
Display *dpy = myDpy; |
|
555 | 662 |
int screen = __intVal(__INST(screen)); |
341 | 663 |
OBJ xp, yp; |
664 |
int xpos, ypos; |
|
665 |
Window child_return; |
|
666 |
||
667 |
if (__isExternalAddress(windowId) |
|
668 |
&& __isPoint(aPoint)) { |
|
669 |
xp = _point_X(aPoint); |
|
670 |
yp = _point_Y(aPoint); |
|
671 |
if (__bothSmallInteger(xp, yp)) { |
|
672 |
BEGIN_INTERRUPTSBLOCKED |
|
673 |
XTranslateCoordinates(dpy, |
|
674 |
RootWindow(dpy, screen), |
|
675 |
_WindowVal(windowId), |
|
555 | 676 |
__intVal(xp), __intVal(yp), |
341 | 677 |
&xpos, &ypos, &child_return); |
678 |
END_INTERRUPTSBLOCKED |
|
679 |
if (child_return) { |
|
680 |
RETURN ( __MKOBJ(child_return) ); |
|
681 |
} |
|
682 |
RETURN ( nil ); |
|
683 |
} |
|
684 |
} |
|
685 |
%}. |
|
686 |
windowId notNil ifTrue:[ |
|
687 |
aPoint isPoint ifTrue:[ |
|
688 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
689 |
] |
|
690 |
]. |
|
691 |
||
692 |
^ nil |
|
693 |
! |
|
694 |
||
695 |
virtualExtent |
|
696 |
"return the virtual extent of the display (in pixels). |
|
697 |
On most systems, this is the same as the physical width; |
|
698 |
except, if a window manager with a virtual desktop like olvwm |
|
699 |
(simulating a bigger screen) is running." |
|
700 |
||
701 |
%{ |
|
555 | 702 |
if ((__INST(rootId) != __INST(virtualRootId)) |
703 |
&& __isExternalAddress(__INST(virtualRootId))) { |
|
341 | 704 |
Window vRootWin; |
705 |
Window root; |
|
706 |
int x, y; |
|
707 |
unsigned int width, height; |
|
708 |
unsigned int dummy; |
|
709 |
||
555 | 710 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
341 | 711 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
712 |
&dummy, &dummy)) { |
|
713 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
714 |
} |
|
715 |
} |
|
716 |
%}. |
|
717 |
^ width @ height |
|
718 |
! |
|
719 |
||
720 |
whitepixel |
|
721 |
"return the colornumber of white" |
|
722 |
||
723 |
^ whitepixel |
|
724 |
! ! |
|
725 |
||
726 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
727 |
||
0 | 728 |
hasDPS |
186 | 729 |
"return true, if this workstation supports display postscript. |
730 |
Both the server must support it, and the feature must have been |
|
731 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 732 |
|
733 |
^ hasDPSExtension |
|
186 | 734 |
|
735 |
" |
|
736 |
Display hasDPS |
|
737 |
" |
|
738 |
! |
|
739 |
||
150 | 740 |
hasExtension:extensionString |
741 |
"query for an X extension. The argument, extensionString |
|
742 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 743 |
Return true, if that extension is available in the server. |
744 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 745 |
|
746 |
%{ |
|
747 |
int dummy; |
|
748 |
||
749 |
if (__isString(extensionString) && ISCONNECTED) { |
|
750 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
751 |
RETURN ( true ); |
|
752 |
} |
|
753 |
} |
|
754 |
%}. |
|
755 |
^ false |
|
186 | 756 |
|
757 |
" |
|
758 |
Display hasExtension:'XVideo' |
|
759 |
Display hasExtension:'Input' |
|
760 |
Display hasExtension:'GLX' |
|
761 |
Display hasExtension:'X3D-PEX' |
|
762 |
Display hasExtension:'XInputExtension' |
|
763 |
Display hasExtension:'SHAPE' |
|
764 |
Display hasExtension:'MIT-SHM' |
|
765 |
Display hasExtension:'SGIFullScreenStereo' |
|
766 |
" |
|
150 | 767 |
! |
768 |
||
295 | 769 |
hasImageExtension |
770 |
"return true, if this workstation supports the X image extension. |
|
771 |
Both the server must support it, and the feature must have been |
|
772 |
enabled in the smalltalk system, for true to be returned." |
|
773 |
||
774 |
^ hasImageExtension |
|
775 |
||
776 |
" |
|
777 |
Display hasImageExtension |
|
778 |
" |
|
779 |
! |
|
780 |
||
781 |
hasInputExtension |
|
782 |
"return true, if this workstation supports the X input extension. |
|
783 |
Both the server must support it, and the feature must have been |
|
784 |
enabled in the smalltalk system, for true to be returned." |
|
785 |
||
786 |
^ hasInputExtension |
|
787 |
||
788 |
" |
|
789 |
Display hasInputExtension |
|
790 |
" |
|
791 |
! |
|
792 |
||
793 |
hasMultibuffer |
|
794 |
"return true, if this workstation supports the multibuffer extension. |
|
795 |
Both the server must support it, and the feature must have been |
|
796 |
enabled in the smalltalk system, for true to be returned." |
|
797 |
||
798 |
^ hasMbufExtension |
|
799 |
||
800 |
" |
|
801 |
Display hasMultibuffer |
|
802 |
" |
|
803 |
! |
|
804 |
||
805 |
hasPEX |
|
806 |
"return true, if this workstation supports PEX 3D graphics. |
|
807 |
Both the server must support it, and the feature must have been |
|
808 |
enabled in the smalltalk system, for true to be returned." |
|
809 |
||
810 |
^ hasPEXExtension |
|
811 |
||
812 |
" |
|
813 |
Display hasPEX |
|
814 |
" |
|
815 |
! |
|
816 |
||
817 |
hasShape |
|
818 |
"return true, if this workstation supports non-rectangular windows. |
|
819 |
Both the server must support it, and the feature must have been |
|
820 |
enabled in the smalltalk system, for true to be returned." |
|
821 |
||
822 |
^ hasShapeExtension |
|
823 |
||
824 |
" |
|
825 |
Display hasShape |
|
826 |
" |
|
827 |
! |
|
828 |
||
829 |
hasShm |
|
830 |
"return true, if this workstation supports the shared pixmap extension. |
|
831 |
Both the server must support it, and the feature must have been |
|
832 |
enabled in the smalltalk system, for true to be returned." |
|
833 |
||
834 |
^ hasShmExtension |
|
835 |
||
836 |
" |
|
837 |
Display hasShm |
|
838 |
" |
|
839 |
! |
|
840 |
||
841 |
hasXVideo |
|
842 |
"return true, if this workstation supports the XVideo extension. |
|
843 |
Both the server must support it, and the feature must have been |
|
844 |
enabled in the smalltalk system, for true to be returned." |
|
845 |
||
846 |
^ hasXVideoExtension |
|
847 |
||
848 |
" |
|
849 |
Display hasXVideo |
|
850 |
" |
|
851 |
! |
|
852 |
||
853 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
854 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 855 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 856 |
|
857 |
|xIconSizes count ret| |
|
858 |
||
859 |
%{ |
|
860 |
Display *dpy = myDpy; |
|
555 | 861 |
int screen = __intVal(__INST(screen)); |
295 | 862 |
XIconSize *sizeList; |
863 |
int cnt; |
|
864 |
||
865 |
if (ISCONNECTED) { |
|
850 | 866 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
867 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
868 |
count = __MKSMALLINT(cnt); |
|
869 |
} |
|
295 | 870 |
} |
871 |
%}. |
|
872 |
xIconSizes isNil ifTrue:[^ nil]. |
|
873 |
||
874 |
ret := OrderedCollection new:count. |
|
875 |
1 to:count do:[ :i | |
|
850 | 876 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 877 |
|
878 |
%{ |
|
850 | 879 |
XIconSize *slp; |
880 |
||
881 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
882 |
minWidth = __MKSMALLINT(slp->min_width); |
|
883 |
minHeight = __MKSMALLINT(slp->min_height); |
|
884 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
885 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
886 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
887 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 888 |
%}. |
850 | 889 |
d := IdentityDictionary new. |
890 |
d at:#minWidth put:minWidth. |
|
891 |
d at:#maxWidth put:maxWidth. |
|
892 |
d at:#widthStep put:widthStep. |
|
893 |
d at:#minHeight put:minHeight. |
|
894 |
d at:#maxHeight put:maxHeight. |
|
895 |
d at:#heightStep put:heightStep. |
|
896 |
||
897 |
ret add:d |
|
295 | 898 |
]. |
899 |
||
900 |
xIconSizes free. |
|
901 |
^ ret |
|
902 |
||
903 |
" |
|
819 | 904 |
Display iconSizes |
295 | 905 |
" |
906 |
! |
|
907 |
||
341 | 908 |
ignoreBackingStore:aBoolean |
909 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
910 |
no backing store used - this can be used on servers where backing store is |
|
911 |
very slow or is broken (can be put into display-rc-file)" |
|
912 |
||
913 |
ignoreBackingStore := aBoolean |
|
295 | 914 |
! |
915 |
||
823 | 916 |
preferredIconSize |
917 |
"return the displays preferred size for icons. |
|
918 |
Redefined to return a special value on SGI servers." |
|
919 |
||
920 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
850 | 921 |
^ 86@68 |
823 | 922 |
]. |
923 |
^ super preferredIconSize |
|
924 |
||
925 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
926 |
! |
|
927 |
||
43 | 928 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
929 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
930 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
931 |
depth, bitsPerPixel and padding values." |
43 | 932 |
|
150 | 933 |
|nFormats "{ Class: SmallInteger }" |
934 |
formatArray| |
|
43 | 935 |
%{ |
936 |
Display *dpy = myDpy; |
|
150 | 937 |
|
938 |
if (! ISCONNECTED) { |
|
939 |
RETURN (nil); |
|
940 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
941 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 942 |
%}. |
943 |
formatArray := Array new:nFormats. |
|
150 | 944 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
945 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 946 |
|
947 |
i := index. |
|
43 | 948 |
%{ |
70 | 949 |
ScreenFormat *format; |
950 |
Display *dpy = myDpy; |
|
951 |
||
90 | 952 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
555 | 953 |
format += (__intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
954 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
955 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
956 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 957 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
958 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
959 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
960 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
961 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
962 |
formatArray at:index put:info. |
43 | 963 |
]. |
964 |
^ formatArray |
|
965 |
||
966 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
967 |
Display supportedImageFormats |
43 | 968 |
" |
969 |
! |
|
970 |
||
823 | 971 |
supportsIconViews |
972 |
"return true, if this device supports views as icons. |
|
973 |
Only Xservers (currently) support this." |
|
974 |
||
975 |
^ true |
|
976 |
||
977 |
" |
|
978 |
Display supportsIconViews |
|
979 |
" |
|
980 |
||
981 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
982 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
983 |
! |
|
984 |
||
81 | 985 |
supportsViewGravity |
986 |
"return true, if this device supports gravity attributes. |
|
82 | 987 |
We do not depend on it being implemented, but some resizing operations |
81 | 988 |
are faster, it is is." |
989 |
||
990 |
^ true |
|
0 | 991 |
! ! |
992 |
||
993 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
994 |
||
295 | 995 |
createBitmapFromArray:anArray width:w height:h |
996 |
|bitmapId| |
|
997 |
||
998 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
999 |
bitmapId isNil ifTrue:[ |
|
1000 |
self primitiveFailed |
|
1001 |
]. |
|
1002 |
^ bitmapId |
|
1003 |
! |
|
1004 |
||
1005 |
createBitmapFromFile:aString for:aForm |
|
1006 |
|id w h| |
|
1007 |
||
1008 |
%{ |
|
1009 |
Display *dpy = myDpy; |
|
555 | 1010 |
int screen = __intVal(__INST(screen)); |
295 | 1011 |
Pixmap newBitmap; |
1012 |
char *filename; |
|
1013 |
unsigned b_width, b_height; |
|
1014 |
int b_x_hot, b_y_hot; |
|
1015 |
int status; |
|
1016 |
||
1017 |
if (ISCONNECTED) { |
|
1018 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1019 |
filename = (char *)_stringVal(aString); |
|
1020 |
||
1021 |
BEGIN_INTERRUPTSBLOCKED |
|
1022 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1023 |
filename, &b_width, &b_height, &newBitmap, |
|
1024 |
&b_x_hot, &b_y_hot); |
|
1025 |
END_INTERRUPTSBLOCKED |
|
1026 |
||
892 | 1027 |
if ((status == BitmapSuccess) && newBitmap) { |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1028 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1029 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1030 |
#endif |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1031 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1032 |
h = __MKSMALLINT(b_height); |
295 | 1033 |
id = __MKOBJ(newBitmap); |
1034 |
} |
|
1035 |
} |
|
1036 |
} |
|
1037 |
%}. |
|
1038 |
id notNil ifTrue:[ |
|
1039 |
aForm setWidth:w height:h |
|
1040 |
]. |
|
1041 |
^ id |
|
1042 |
! |
|
1043 |
||
1044 |
createBitmapWidth:w height:h |
|
1045 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1046 |
(i.e. random). Return a bitmap id or nil" |
|
1047 |
||
1048 |
%{ /* NOCONTEXT */ |
|
1049 |
||
1050 |
Display *dpy = myDpy; |
|
555 | 1051 |
int screen = __intVal(__INST(screen)); |
295 | 1052 |
Pixmap newBitmap; |
1053 |
||
1054 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1055 |
BEGIN_INTERRUPTSBLOCKED |
|
1056 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1057 |
__intVal(w), __intVal(h), 1); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1058 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1059 |
if (newBitmap) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1060 |
__cnt_bitmap++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1061 |
#endif |
295 | 1062 |
END_INTERRUPTSBLOCKED |
1063 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1064 |
} |
|
1065 |
%} |
|
1066 |
. |
|
1067 |
self primitiveFailed. |
|
1068 |
^ nil |
|
1069 |
! |
|
1070 |
||
0 | 1071 |
createPixmapWidth:w height:h depth:d |
1072 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1073 |
(i.e. random). Return a bitmap id or nil" |
|
1074 |
||
1075 |
%{ /* NOCONTEXT */ |
|
1076 |
||
1077 |
Display *dpy = myDpy; |
|
555 | 1078 |
int screen = __intVal(__INST(screen)); |
0 | 1079 |
Pixmap newBitmap; |
1080 |
||
150 | 1081 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1082 |
BEGIN_INTERRUPTSBLOCKED |
1083 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1084 |
__intVal(w), __intVal(h), __intVal(d)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1085 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1086 |
if (newBitmap) |
928 | 1087 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1088 |
#endif |
70 | 1089 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1090 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1091 |
} |
1092 |
%} |
|
1093 |
. |
|
43 | 1094 |
self primitiveFailed. |
1095 |
^ nil |
|
0 | 1096 |
! |
1097 |
||
1098 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1099 |
"will vanish - for compatibility with previous versions" |
1100 |
||
1101 |
^ self |
|
850 | 1102 |
createWindowFor:aView |
1103 |
origin:(xpos @ ypos) |
|
1104 |
extent:(wwidth @ wheight) |
|
1105 |
minExtent:(aView minExtent) |
|
1106 |
maxExtent:(aView maxExtent) |
|
1107 |
borderWidth:(aView borderWidth) |
|
1108 |
subViewOf:(aView superView) |
|
1109 |
onTop:(aView isPopUpView) |
|
1110 |
inputOnly:(aView isInputOnly) |
|
1111 |
label:(aView label) |
|
1112 |
cursor:(aView cursor) |
|
1113 |
icon:(aView icon) |
|
1114 |
iconView:(aView iconView) |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1115 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1116 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1117 |
! |
1118 |
||
1119 |
createWindowFor:aView |
|
70 | 1120 |
origin:origin |
1121 |
extent:extent |
|
1122 |
minExtent:minExt |
|
1123 |
maxExtent:maxExt |
|
1124 |
borderWidth:bWidth |
|
1125 |
subViewOf:wsuperView |
|
157 | 1126 |
onTop:wisPopUpView |
70 | 1127 |
inputOnly:winputOnly |
1128 |
label:wlabel |
|
1129 |
cursor:wcursor |
|
1130 |
icon:wicon |
|
1131 |
iconView:wiconView |
|
46 | 1132 |
|
1133 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1134 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1135 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1136 |
vBgForm deepForm preferredVisual preferredDepth| |
1137 |
||
1138 |
displayId isNil ifTrue:[ |
|
1139 |
self primitiveFailed. |
|
1140 |
^ nil |
|
1141 |
]. |
|
0 | 1142 |
|
46 | 1143 |
origin notNil ifTrue:[ |
70 | 1144 |
xpos := origin x. |
1145 |
ypos := origin y. |
|
46 | 1146 |
] ifFalse:[ |
70 | 1147 |
xpos := ypos := 0. |
0 | 1148 |
]. |
46 | 1149 |
extent notNil ifTrue:[ |
70 | 1150 |
wwidth := extent x. |
1151 |
wheight := extent y. |
|
46 | 1152 |
] ifFalse:[ |
70 | 1153 |
wwidth := wheight := 100. |
46 | 1154 |
]. |
1155 |
minExt notNil ifTrue:[ |
|
70 | 1156 |
minWidth := minExt x. |
1157 |
minHeight := minExt y |
|
0 | 1158 |
]. |
46 | 1159 |
maxExt notNil ifTrue:[ |
70 | 1160 |
maxWidth := maxExt x. |
1161 |
maxHeight := maxExt y |
|
46 | 1162 |
]. |
1163 |
||
0 | 1164 |
wsuperView notNil ifTrue:[ |
70 | 1165 |
wsuperViewId := wsuperView id |
0 | 1166 |
]. |
1167 |
wcursor isNil ifTrue:[ |
|
145 | 1168 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1169 |
] ifFalse:[ |
70 | 1170 |
wcursorId := wcursor id |
0 | 1171 |
]. |
1172 |
||
1173 |
wicon notNil ifTrue:[ |
|
70 | 1174 |
wiconId := wicon id |
0 | 1175 |
]. |
1176 |
wiconView notNil ifTrue:[ |
|
70 | 1177 |
wiconViewId := wiconView id |
0 | 1178 |
]. |
1179 |
weventMask := aView eventMask. |
|
1180 |
||
150 | 1181 |
preferredVisual := aView preferredVisual. |
1182 |
preferredDepth := aView preferredDepth. |
|
23 | 1183 |
|
72 | 1184 |
%{ /* STACK:16000 */ |
0 | 1185 |
Display *dpy = myDpy; |
555 | 1186 |
int screen = __intVal(__INST(screen)); |
0 | 1187 |
Visual visual; |
1188 |
XGCValues xgcv; |
|
1189 |
XSetWindowAttributes xswa; |
|
1190 |
XSizeHints sizehints; |
|
1191 |
XWMHints wmhints; |
|
46 | 1192 |
int bw, bd, bg; |
0 | 1193 |
Window newWindow, parentWindow; |
1194 |
char *windowName; |
|
1195 |
XFontStruct *f; |
|
1196 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1197 |
int flags = 0, depth, ioClass; |
|
1198 |
Window iconWindow; |
|
1199 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1200 |
Atom WmQuitAppAtom; |
|
1201 |
Atom atoms[3]; |
|
1202 |
int atomCount = 0, isTopWindow = 0; |
|
1203 |
||
1204 |
sizehints.flags = 0; |
|
1205 |
sizehints.width = 100; |
|
1206 |
sizehints.height = 100; |
|
1207 |
sizehints.x = 0; |
|
1208 |
sizehints.y = 0; |
|
1209 |
||
97 | 1210 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1211 |
sizehints.flags |= PSize; |
555 | 1212 |
sizehints.width = __intVal(wwidth); |
1213 |
sizehints.height = __intVal(wheight); |
|
0 | 1214 |
} |
97 | 1215 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1216 |
sizehints.flags |= PPosition; |
555 | 1217 |
sizehints.x = __intVal(xpos); |
1218 |
sizehints.y = __intVal(ypos); |
|
0 | 1219 |
} |
97 | 1220 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1221 |
sizehints.flags |= PMinSize; |
555 | 1222 |
sizehints.min_width = __intVal(minWidth); |
1223 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1224 |
} |
97 | 1225 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1226 |
sizehints.flags |= PMaxSize; |
555 | 1227 |
sizehints.max_width = __intVal(maxWidth); |
1228 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1229 |
} |
1230 |
||
37 | 1231 |
bg = WhitePixel(dpy, screen); |
0 | 1232 |
|
97 | 1233 |
if (__isSmallInteger(bWidth)) { |
555 | 1234 |
bw = __intVal(bWidth); |
46 | 1235 |
} else { |
70 | 1236 |
bw = 0; |
0 | 1237 |
} |
1238 |
||
72 | 1239 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1240 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1241 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1242 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1243 |
} else { |
70 | 1244 |
parentWindow = RootWindow(dpy, screen); |
1245 |
isTopWindow = 1; |
|
0 | 1246 |
} |
1247 |
||
157 | 1248 |
if (wisPopUpView == true) |
70 | 1249 |
xswa.override_redirect = 1; |
0 | 1250 |
else |
70 | 1251 |
xswa.override_redirect = 0; |
0 | 1252 |
|
1253 |
if (winputOnly == true) |
|
70 | 1254 |
ioClass = InputOnly; |
0 | 1255 |
else |
70 | 1256 |
ioClass = InputOutput; |
0 | 1257 |
|
97 | 1258 |
if (__isSmallInteger(weventMask)) { |
555 | 1259 |
xswa.event_mask = __intVal(weventMask); |
0 | 1260 |
} else { |
70 | 1261 |
xswa.event_mask = 0; |
0 | 1262 |
} |
1263 |
||
1264 |
if (ioClass == InputOnly) { |
|
70 | 1265 |
bw = 0; |
1266 |
depth = 0; |
|
1267 |
flags |= CWEventMask; |
|
0 | 1268 |
} else { |
70 | 1269 |
depth = DefaultDepth(dpy,screen); |
1270 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1271 |
||
1272 |
if (backPixmap != (Pixmap)0) { |
|
1273 |
xswa.background_pixmap = backPixmap; |
|
1274 |
flags |= CWBackPixmap; |
|
1275 |
} else { |
|
1276 |
xswa.background_pixel = bg; |
|
1277 |
flags |= CWBackPixel; |
|
1278 |
} |
|
1279 |
xswa.border_pixel = bd; |
|
0 | 1280 |
} |
23 | 1281 |
|
0 | 1282 |
visual.visualid = CopyFromParent; |
150 | 1283 |
if (__isSmallInteger(preferredDepth)) { |
555 | 1284 |
depth = __intVal(preferredDepth); |
23 | 1285 |
} |
54 | 1286 |
|
1287 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1288 |
if (preferredVisual != nil) { |
70 | 1289 |
XVisualInfo vi; |
1290 |
int cls; |
|
1291 |
||
150 | 1292 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1293 |
cls = StaticGray; |
150 | 1294 |
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
|
1295 |
cls = GrayScale; |
150 | 1296 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1297 |
cls = StaticColor; |
150 | 1298 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1299 |
cls = PseudoColor; |
150 | 1300 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1301 |
cls = TrueColor; |
150 | 1302 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1303 |
cls = DirectColor; |
1304 |
else |
|
1305 |
cls = PseudoColor; |
|
200 | 1306 |
|
70 | 1307 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1308 |
visual.visualid = vi.visualid; |
|
163 | 1309 |
/* |
1310 |
printf("visualId=%x\n", vi.visualid); |
|
1311 |
*/ |
|
70 | 1312 |
} |
23 | 1313 |
} |
0 | 1314 |
|
1315 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1316 |
sizehints.x, sizehints.y, |
1317 |
sizehints.width, sizehints.height, |
|
1318 |
bw, depth, ioClass, &visual, |
|
1319 |
flags, &xswa); |
|
54 | 1320 |
END_INTERRUPTSBLOCKED |
0 | 1321 |
|
1322 |
if (! newWindow) { |
|
70 | 1323 |
RETURN ( nil ); |
0 | 1324 |
} |
1325 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1326 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1327 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1328 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1329 |
|
54 | 1330 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1331 |
/* |
1332 |
* define its cursor |
|
1333 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1334 |
if (__isExternalAddress(wcursorId)) { |
70 | 1335 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1336 |
} |
1337 |
||
1338 |
/* |
|
1339 |
* define its icon and name |
|
1340 |
* (only makes sense for topWindows) |
|
1341 |
*/ |
|
1342 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1343 |
if (__isExternalAddress(wiconId)) |
70 | 1344 |
iconBitmap = _PixmapVal(wiconId); |
1345 |
else |
|
1346 |
iconBitmap = (Pixmap)0; |
|
1347 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1348 |
if (__isExternalAddress(wiconViewId)) |
70 | 1349 |
iconWindow = _WindowVal(wiconViewId); |
1350 |
else |
|
1351 |
iconWindow = (Window)0; |
|
1352 |
||
1353 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1354 |
windowName = (char *)_stringVal(wlabel); |
|
1355 |
else |
|
1356 |
windowName = ""; |
|
1357 |
||
1358 |
if (iconBitmap || windowName) { |
|
1359 |
XSetStandardProperties(dpy, newWindow, |
|
1360 |
windowName, windowName, |
|
1361 |
iconBitmap, |
|
1362 |
0, 0, &sizehints); |
|
1363 |
||
1364 |
} |
|
1365 |
||
1366 |
wmhints.flags = 0; |
|
1367 |
if (iconBitmap) { |
|
1368 |
wmhints.flags |= IconPixmapHint; |
|
1369 |
wmhints.icon_pixmap = iconBitmap; |
|
1370 |
} |
|
1371 |
if (iconWindow) { |
|
1372 |
wmhints.flags |= IconWindowHint; |
|
1373 |
wmhints.icon_window = iconWindow; |
|
1374 |
} |
|
0 | 1375 |
/* |
70 | 1376 |
wmhints.flags |= InputHint; |
1377 |
wmhints.input = True; |
|
0 | 1378 |
*/ |
70 | 1379 |
XSetWMHints(dpy, newWindow, &wmhints); |
1380 |
||
1381 |
/* |
|
1382 |
* tell window manager to not kill us but send an event instead |
|
1383 |
*/ |
|
1384 |
/* |
|
1385 |
* get atoms first (if not already known) |
|
1386 |
*/ |
|
555 | 1387 |
if (__INST(protocolsAtom) == nil) { |
70 | 1388 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
555 | 1389 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1390 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1391 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
555 | 1392 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1393 |
#endif |
1394 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1395 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
555 | 1396 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1397 |
#endif |
70 | 1398 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
555 | 1399 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1400 |
} else { |
0 | 1401 |
#ifdef USE_QUIT_APP_ATOM |
555 | 1402 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1403 |
#else |
70 | 1404 |
WmQuitAppAtom = 0; |
0 | 1405 |
#endif |
555 | 1406 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1407 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1408 |
#ifdef USE_SAVEYOURSELF_ATOM |
555 | 1409 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1410 |
#else |
70 | 1411 |
WmSaveYourselfAtom = 0; |
0 | 1412 |
#endif |
70 | 1413 |
} |
1414 |
||
1415 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1416 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1417 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1418 |
#endif |
1419 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1420 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1421 |
#endif |
70 | 1422 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1423 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1424 |
} |
1425 |
||
54 | 1426 |
END_INTERRUPTSBLOCKED |
1427 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1428 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1429 |
%}. |
0 | 1430 |
self addKnownView:aView withId:windowId. |
1431 |
^ windowId |
|
1432 |
! |
|
1433 |
||
1434 |
destroyGC:aGCId |
|
1435 |
||
1436 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1437 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1438 |
GC gc = _GCVal(aGCId); |
1439 |
||
1440 |
if (gc) { |
|
1441 |
BEGIN_INTERRUPTSBLOCKED |
|
1442 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1443 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1444 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1445 |
#endif |
366 | 1446 |
END_INTERRUPTSBLOCKED |
1447 |
} |
|
70 | 1448 |
RETURN ( self ); |
0 | 1449 |
} |
118 | 1450 |
%}. |
0 | 1451 |
self primitiveFailed |
1452 |
! |
|
1453 |
||
295 | 1454 |
destroyPixmap:aDrawableId |
0 | 1455 |
|
1456 |
%{ /* NOCONTEXT */ |
|
1457 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1458 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1459 |
Pixmap pix = _PixmapVal(aDrawableId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1460 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1461 |
if (pix) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1462 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1463 |
XFreePixmap(myDpy, pix); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1464 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1465 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1466 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1467 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1468 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1469 |
RETURN ( self ); |
0 | 1470 |
} |
118 | 1471 |
%}. |
295 | 1472 |
self primitiveFailed |
1473 |
! |
|
1474 |
||
1475 |
destroyView:aView withId:aWindowId |
|
1476 |
%{ |
|
1477 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1478 |
Window win = _WindowVal(aWindowId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1479 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1480 |
if (win) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1481 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1482 |
XDestroyWindow(myDpy, win); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1483 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1484 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1485 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1486 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1487 |
} |
295 | 1488 |
} |
1489 |
%}. |
|
1490 |
self removeKnownView:aView |
|
0 | 1491 |
! |
1492 |
||
1493 |
dpsContextFor:aDrawableId and:aGCId |
|
1494 |
||
1495 |
%{ /* NOCONTEXT */ |
|
1496 |
#ifdef XXDPS |
|
555 | 1497 |
int screen = __intVal(__INST(screen)); |
0 | 1498 |
DPSContext dps; |
1499 |
int height; |
|
1500 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1501 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1502 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1503 |
&& ISCONNECTED) { |
70 | 1504 |
BEGIN_INTERRUPTSBLOCKED |
1505 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1506 |
_GCVal(aGCId), |
|
1507 |
0, height, 0, colormap, NULL, 0, |
|
1508 |
XDPSDefaultTextBackstop, |
|
1509 |
XDPSDefaultErrorProc, |
|
1510 |
NULL); |
|
1511 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1512 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1513 |
} |
1514 |
#endif |
|
1515 |
%} |
|
1516 |
. |
|
43 | 1517 |
self primitiveFailed. |
1518 |
^ nil |
|
295 | 1519 |
! |
1520 |
||
1521 |
gcFor:aDrawableId |
|
132 | 1522 |
|
1523 |
%{ /* NOCONTEXT */ |
|
555 | 1524 |
int screen = __intVal(__INST(screen)); |
295 | 1525 |
GC gc; |
1526 |
||
1527 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1528 |
BEGIN_INTERRUPTSBLOCKED |
|
1529 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1530 |
0L, (XGCValues *)0); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1531 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1532 |
if (gc) |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1533 |
__cnt_gc++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1534 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1535 |
|
295 | 1536 |
END_INTERRUPTSBLOCKED |
1537 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1538 |
} |
1539 |
%}. |
|
1540 |
self primitiveFailed. |
|
1541 |
^ nil |
|
295 | 1542 |
! |
1543 |
||
1544 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1545 |
|
1546 |
%{ /* UNLIMITEDSTACK */ |
|
1547 |
||
295 | 1548 |
Display *dpy = myDpy; |
555 | 1549 |
int screen = __intVal(__INST(screen)); |
295 | 1550 |
Pixmap newBitmap; |
1551 |
unsigned int b_width, b_height; |
|
1552 |
REGISTER unsigned char *cp; |
|
1553 |
REGISTER unsigned char *pBits; |
|
1554 |
unsigned char *b_bits, *allocatedBits; |
|
1555 |
int index, row; |
|
1556 |
REGISTER int col; |
|
1557 |
unsigned bits; |
|
1558 |
static char reverseBitTable[256]; |
|
1559 |
static firstCall = 1; |
|
1560 |
int nBytes; |
|
1561 |
unsigned char fastBits[10000]; |
|
1562 |
OBJ num, *op; |
|
1563 |
int bytesPerRow; |
|
1564 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1565 |
if (! ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1566 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1567 |
} |
295 | 1568 |
if (firstCall) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1569 |
for (index=0; index < 256; index++) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1570 |
reverseBitTable[index] = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1571 |
if (index & 128) reverseBitTable[index] |= 1; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1572 |
if (index & 64) reverseBitTable[index] |= 2; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1573 |
if (index & 32) reverseBitTable[index] |= 4; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1574 |
if (index & 16) reverseBitTable[index] |= 8; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1575 |
if (index & 8) reverseBitTable[index] |= 16; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1576 |
if (index & 4) reverseBitTable[index] |= 32; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1577 |
if (index & 2) reverseBitTable[index] |= 64; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1578 |
if (index & 1) reverseBitTable[index] |= 128; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1579 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1580 |
firstCall = 0; |
295 | 1581 |
} |
1582 |
||
1583 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1584 |
newBitmap = (Pixmap)0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1585 |
b_width = __intVal(w); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1586 |
b_height = __intVal(h); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1587 |
bytesPerRow = (b_width + 7) / 8; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1588 |
nBytes = b_height * bytesPerRow; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1589 |
if (nBytes < sizeof(fastBits)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1590 |
cp = b_bits = fastBits; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1591 |
allocatedBits = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1592 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1593 |
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
|
1594 |
if (! cp) goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1595 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1596 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1597 |
if (__qClass(anArray) == @global(Array)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1598 |
index = 1; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1599 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1600 |
for (row = b_height; row; row--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1601 |
for (col = bytesPerRow; col; col--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1602 |
num = *op++; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1603 |
if (! __isSmallInteger(num)) goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1604 |
bits = __intVal(num); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1605 |
*cp++ = reverseBitTable[bits]; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1606 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1607 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1608 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1609 |
if (__qClass(anArray) == @global(ByteArray)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1610 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1611 |
for (col = b_height*bytesPerRow; col; col--) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1612 |
*cp++ = reverseBitTable[*pBits++]; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1613 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1614 |
} else { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1615 |
goto fail; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1616 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1617 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1618 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1619 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1620 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1621 |
(char *)b_bits, |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1622 |
b_width, b_height); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1623 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1624 |
if (newBitmap) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1625 |
__cnt_bitmap++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1626 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1627 |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1628 |
END_INTERRUPTSBLOCKED |
295 | 1629 |
fail: ; |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1630 |
if (allocatedBits) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1631 |
free(allocatedBits); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1632 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
0 | 1633 |
} |
1634 |
%} |
|
295 | 1635 |
! |
1636 |
||
1637 |
realRootWindowFor:aView |
|
1638 |
"the name of this method is historic; |
|
1639 |
- it will vanish" |
|
1640 |
||
1641 |
|id| |
|
1642 |
||
1643 |
id := self realRootWindowId. |
|
1644 |
self addKnownView:aView withId:id. |
|
1645 |
^ id |
|
1646 |
! |
|
1647 |
||
1648 |
realRootWindowId |
|
1649 |
"return the id of the real root window. |
|
1650 |
This may not be the window you see as background, |
|
1651 |
since some window managers install a virtual root window on top |
|
1652 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1653 |
care of any virtual root." |
|
0 | 1654 |
|
1655 |
%{ /* NOCONTEXT */ |
|
1656 |
||
555 | 1657 |
int screen = __intVal(__INST(screen)); |
295 | 1658 |
Window root; |
1659 |
OBJ id; |
|
1660 |
||
555 | 1661 |
if (__INST(rootId) != nil) { |
1662 |
RETURN (__INST(rootId)); |
|
295 | 1663 |
} |
0 | 1664 |
|
150 | 1665 |
if (ISCONNECTED) { |
295 | 1666 |
root = RootWindow(myDpy, screen); |
1667 |
if (! root) { |
|
1668 |
id = nil; |
|
1669 |
} else { |
|
555 | 1670 |
__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
|
1671 |
} |
295 | 1672 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1673 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1674 |
%}. |
295 | 1675 |
self primitiveFailed |
1676 |
! |
|
1677 |
||
1678 |
rootWindowFor:aView |
|
1679 |
|id| |
|
1680 |
||
1681 |
id := self rootWindowId. |
|
1682 |
self addKnownView:aView withId:id. |
|
0 | 1683 |
^ id |
1684 |
! |
|
1685 |
||
295 | 1686 |
rootWindowId |
1687 |
"return the id of the root window. |
|
1688 |
This is the window you see as background, |
|
1689 |
however, it may or may not be the real physical root window, |
|
1690 |
since some window managers install a virtual root window on top |
|
1691 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1692 |
|
0 | 1693 |
%{ /* NOCONTEXT */ |
555 | 1694 |
int screen = __intVal(__INST(screen)); |
295 | 1695 |
Window rootWin, vRootWin; |
1696 |
OBJ id; |
|
1697 |
||
555 | 1698 |
if (__INST(virtualRootId) != nil) { |
1699 |
RETURN (__INST(virtualRootId)); |
|
295 | 1700 |
} |
0 | 1701 |
|
169 | 1702 |
if (ISCONNECTED) { |
295 | 1703 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1704 |
#ifndef IRIS |
|
180 | 1705 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1706 |
/* |
1707 |
* on IRIS, this creates a badwindow error - why ? |
|
1708 |
* children contains a funny window (000034) |
|
1709 |
*/ |
|
1710 |
||
1711 |
/* |
|
1712 |
* care for virtual root windows (tvtwm & friends) |
|
1713 |
*/ |
|
1714 |
{ |
|
1715 |
Atom vRootAtom = None; |
|
1716 |
int i; |
|
1717 |
Window rootReturn, parentReturn; |
|
1718 |
Window* children; |
|
1719 |
unsigned int numChildren; |
|
1720 |
||
1721 |
if (XQueryTree(myDpy, rootWin, |
|
1722 |
&rootReturn, &parentReturn, |
|
1723 |
&children, &numChildren)) { |
|
1724 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1725 |
if (vRootAtom != None) { |
|
1726 |
for (i=0; i < numChildren; i++) { |
|
1727 |
Atom actual_type; |
|
1728 |
int actual_format; |
|
1729 |
unsigned long nitems, bytesafter; |
|
1730 |
Window* newRoot = (Window*) 0; |
|
1731 |
||
1732 |
if (children[i]) { |
|
1733 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1734 |
0L, 1L, False, XA_WINDOW, |
|
1735 |
&actual_type, &actual_format, |
|
1736 |
&nitems, &bytesafter, |
|
1737 |
(unsigned char**) &newRoot |
|
1738 |
) == Success && newRoot) { |
|
1739 |
vRootWin = *newRoot; |
|
1740 |
break; |
|
1741 |
} |
|
1742 |
} |
|
1743 |
} |
|
1744 |
if (children) XFree( children ); |
|
1745 |
} |
|
1746 |
} |
|
1747 |
} |
|
180 | 1748 |
END_INTERRUPTSBLOCKED |
295 | 1749 |
#endif |
1750 |
} |
|
1751 |
||
1752 |
/* cannot happen */ |
|
1753 |
if (! vRootWin) { |
|
1754 |
vRootWin = rootWin; |
|
1755 |
if (! rootWin) { |
|
1756 |
RETURN ( nil ); |
|
1757 |
} |
|
1758 |
} |
|
555 | 1759 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1760 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1761 |
RETURN ( id ); |
63 | 1762 |
%} |
0 | 1763 |
! ! |
1764 |
||
1765 |
!XWorkstation methodsFor:'color stuff'! |
|
1766 |
||
295 | 1767 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1768 |
"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
|
1769 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1770 |
|
1771 |
%{ /* NOCONTEXT */ |
|
1772 |
||
1773 |
Display *dpy = myDpy; |
|
555 | 1774 |
int screen = __intVal(__INST(screen)); |
295 | 1775 |
XColor color; |
1776 |
unsigned long dummy; |
|
1777 |
Status ok; |
|
1778 |
||
1779 |
BEGIN_INTERRUPTSBLOCKED |
|
1780 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1781 |
&dummy, 0, &color.pixel, 1); |
|
1782 |
END_INTERRUPTSBLOCKED |
|
1783 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1784 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1785 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1786 |
#endif |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1787 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1788 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1789 |
%}. |
43 | 1790 |
^ nil |
0 | 1791 |
! |
1792 |
||
1793 |
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
|
1794 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1795 |
Dont use this method, colornames are mostly X specific" |
1796 |
||
1797 |
%{ /* NOCONTEXT */ |
|
1798 |
||
1799 |
char *colorname; |
|
1800 |
Display *dpy = myDpy; |
|
1801 |
XColor scolor, ecolor; |
|
555 | 1802 |
int screen = __intVal(__INST(screen)); |
850 | 1803 |
int id; |
54 | 1804 |
Status ok; |
0 | 1805 |
|
150 | 1806 |
if (ISCONNECTED) { |
850 | 1807 |
if (__isString(aString) || __isSymbol(aString)) { |
1808 |
colorname = (char *)_stringVal(aString); |
|
1809 |
||
1810 |
BEGIN_INTERRUPTSBLOCKED |
|
1811 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1812 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1813 |
#ifdef QUICK_TRUE_COLORS |
850 | 1814 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1815 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1816 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1817 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1818 |
RETURN ( __MKSMALLINT(id) ); |
|
1819 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1820 |
#endif |
850 | 1821 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1822 |
} |
|
1823 |
END_INTERRUPTSBLOCKED |
|
1824 |
if (! ok) { |
|
1825 |
RETURN ( nil ); |
|
1826 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1827 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1828 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1829 |
#endif |
850 | 1830 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1831 |
} |
|
0 | 1832 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1833 |
%}. |
43 | 1834 |
self primitiveFailed. |
1835 |
^ nil |
|
0 | 1836 |
! |
1837 |
||
295 | 1838 |
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
|
1839 |
"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
|
1840 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1841 |
|
1842 |
|r g b| |
|
1843 |
||
1844 |
r := self percentToXColorValue:redVal. |
|
1845 |
g := self percentToXColorValue:greenVal. |
|
1846 |
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
|
1847 |
^ 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
|
1848 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1849 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1850 |
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
|
1851 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1852 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1853 |
Display *dpy; |
295 | 1854 |
XColor ecolor; |
555 | 1855 |
int screen = __intVal(__INST(screen)); |
295 | 1856 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1857 |
int id; |
295 | 1858 |
|
1859 |
if (__bothSmallInteger(r, g) |
|
1860 |
&& __isSmallInteger(b) |
|
1861 |
&& ISCONNECTED) { |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1862 |
ecolor.red = __intVal(r); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1863 |
ecolor.green= __intVal(g); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1864 |
ecolor.blue = __intVal(b); |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1865 |
#ifdef QUICK_TRUE_COLORS |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1866 |
if (__INST(visualType) == @symbol(TrueColor)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1867 |
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
|
1868 |
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
|
1869 |
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
|
1870 |
RETURN ( __MKSMALLINT(id) ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1871 |
} |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1872 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1873 |
dpy = myDpy; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1874 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1875 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1876 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1877 |
if (! ok) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1878 |
RETURN ( nil ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1879 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1880 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1881 |
__cnt_color++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1882 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1883 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1884 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1885 |
%}. |
295 | 1886 |
self primitiveFailed. |
1887 |
^ nil |
|
1888 |
! |
|
1889 |
||
1890 |
freeColor:colorIndex |
|
1891 |
"free a display color when its no longer needed" |
|
0 | 1892 |
|
1893 |
%{ /* NOCONTEXT */ |
|
1894 |
||
1895 |
Display *dpy = myDpy; |
|
295 | 1896 |
unsigned long color; |
555 | 1897 |
int screen = __intVal(__INST(screen)); |
295 | 1898 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1899 |
#ifdef QUICK_TRUE_COLORS |
555 | 1900 |
if (__INST(visualType) == @symbol(TrueColor)) { |
850 | 1901 |
/* no need to do anything on TrueColor displays ... */ |
1902 |
RETURN (self); |
|
295 | 1903 |
} |
1904 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1905 |
|
295 | 1906 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
850 | 1907 |
color = (long) __intVal(colorIndex); |
1908 |
BEGIN_INTERRUPTSBLOCKED |
|
1909 |
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
|
1910 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
1911 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1912 |
#endif |
850 | 1913 |
END_INTERRUPTSBLOCKED |
1914 |
RETURN ( self ); |
|
0 | 1915 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1916 |
%}. |
295 | 1917 |
self primitiveFailed |
1918 |
! |
|
1919 |
||
1920 |
getRGBFrom:index into:aBlock |
|
1921 |
"get rgb components (0..100) of color in map at:index, |
|
1922 |
and evaluate the 3-arg block, aBlock with them" |
|
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 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1925 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1926 |
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
|
1927 |
val := aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1928 |
value:(r * 100.0 / 16rFFFF) |
850 | 1929 |
value:(g * 100.0 / 16rFFFF) |
1930 |
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
|
1931 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1932 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1933 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1934 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1935 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1936 |
"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
|
1937 |
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
|
1938 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1939 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1940 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
850 | 1941 |
val := aBlock |
1942 |
value:(r * 100.0 / 16rFFFF) |
|
1943 |
value:(g * 100.0 / 16rFFFF) |
|
1944 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1945 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1946 |
^ val |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1947 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1948 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1949 |
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
|
1950 |
"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
|
1951 |
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
|
1952 |
|
295 | 1953 |
|r g b| |
1954 |
%{ |
|
1955 |
Display *dpy = myDpy; |
|
555 | 1956 |
int screen = __intVal(__INST(screen)); |
295 | 1957 |
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
|
1958 |
int sr, sg, sb; |
295 | 1959 |
int bits, scale, shift; |
1960 |
||
1961 |
if (__isSmallInteger(index)) { |
|
555 | 1962 |
color.pixel = __intVal(index); |
295 | 1963 |
BEGIN_INTERRUPTSBLOCKED |
1964 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
1965 |
END_INTERRUPTSBLOCKED |
|
1966 |
||
1967 |
/* |
|
1968 |
* have to compensate for an error in X ?, which does not scale |
|
1969 |
* colors correctly if lesser than 16bits are valid in a color, |
|
1970 |
* (for example, color white on a 4bitsPerRGB server will return |
|
1971 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
1972 |
*/ |
|
555 | 1973 |
bits = __intVal(__INST(bitsPerRGB)); |
295 | 1974 |
scale = (1<<bits) - 1; |
1975 |
shift = 16 - bits; |
|
1976 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1977 |
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
|
1978 |
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
|
1979 |
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
|
1980 |
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
|
1981 |
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
|
1982 |
b = __MKSMALLINT(sb); |
295 | 1983 |
} |
1984 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1985 |
^ aBlock value:r value:g value:b |
295 | 1986 |
! |
1987 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1988 |
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
|
1989 |
"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
|
1990 |
and evaluate the 3-arg block, aBlock with them" |
295 | 1991 |
|
1992 |
|r g b| |
|
1993 |
||
1994 |
displayId isNil ifTrue:[ |
|
1995 |
self pimitiveFailed. |
|
1996 |
^ nil |
|
1997 |
]. |
|
1998 |
%{ |
|
1999 |
Display *dpy = myDpy; |
|
555 | 2000 |
int screen = __intVal(__INST(screen)); |
295 | 2001 |
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
|
2002 |
int sr, sg, sb; |
295 | 2003 |
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
|
2004 |
int bits, scale, shift; |
295 | 2005 |
|
2006 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
2007 |
BEGIN_INTERRUPTSBLOCKED |
|
2008 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2009 |
(char *)_stringVal(colorName), &color)) { |
|
2010 |
/* |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2011 |
* 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
|
2012 |
* 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
|
2013 |
* (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
|
2014 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
295 | 2015 |
*/ |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2016 |
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
|
2017 |
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
|
2018 |
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
|
2019 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2020 |
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
|
2021 |
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
|
2022 |
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
|
2023 |
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
|
2024 |
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
|
2025 |
b = __MKSMALLINT(sb); |
295 | 2026 |
} |
2027 |
END_INTERRUPTSBLOCKED |
|
2028 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2029 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2030 |
^ aBlock value:r value:g value:b |
295 | 2031 |
! |
2032 |
||
2033 |
listOfAvailableColors |
|
2034 |
"return a list of all available colornames. |
|
2035 |
This should not be used, since colornames are very |
|
2036 |
display-specific (here X-specific)." |
|
2037 |
||
2038 |
|aStream list line index colorName| |
|
2039 |
||
2040 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2041 |
aStream isNil ifTrue:[^ nil]. |
|
2042 |
list := OrderedCollection new. |
|
2043 |
[aStream atEnd] whileFalse:[ |
|
2044 |
line := aStream nextLine. |
|
2045 |
line notNil ifTrue:[ |
|
2046 |
"skip the r/g/b numbers" |
|
2047 |
index := 1. |
|
2048 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2049 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2050 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2051 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2052 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2053 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2054 |
colorName := line copyFrom:index. |
|
2055 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2056 |
list add:colorName |
|
2057 |
] |
|
2058 |
] |
|
2059 |
]. |
|
2060 |
aStream close. |
|
2061 |
^ list sort |
|
2062 |
! |
|
2063 |
||
2064 |
percentToXColorValue:aPercentage |
|
2065 |
"given a color-component value in percent (0..100), return the corresponding |
|
2066 |
x-component value (0..65k) as an integer" |
|
2067 |
||
2068 |
%{ /* NOCONTEXT */ |
|
2069 |
||
2070 |
if (__isSmallInteger(aPercentage)) { |
|
555 | 2071 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2072 |
} |
2073 |
if (__isFloat(aPercentage)) { |
|
555 | 2074 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 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 |
%}. |
295 | 2077 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2078 |
! |
2079 |
||
892 | 2080 |
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
|
2081 |
"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
|
2082 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2083 |
|
2084 |
%{ /* NOCONTEXT */ |
|
2085 |
||
2086 |
char *colorname; |
|
2087 |
Display *dpy = myDpy; |
|
2088 |
XColor color; |
|
555 | 2089 |
int screen = __intVal(__INST(screen)); |
0 | 2090 |
int r, g, b; |
2091 |
int ok = 1; |
|
2092 |
||
892 | 2093 |
if (__isSmallInteger(sred)) |
2094 |
r = __intVal(sred); |
|
0 | 2095 |
else ok = 0; |
2096 |
||
892 | 2097 |
if (__isSmallInteger(sgreen)) |
2098 |
g = __intVal(sgreen); |
|
0 | 2099 |
else ok = 0; |
2100 |
||
892 | 2101 |
if (__isSmallInteger(sblue)) |
2102 |
b = __intVal(sblue); |
|
0 | 2103 |
else ok = 0; |
2104 |
||
97 | 2105 |
if (__isSmallInteger(index) && ok) { |
555 | 2106 |
color.pixel = __intVal(index); |
70 | 2107 |
color.red = r; |
2108 |
color.green = g; |
|
2109 |
color.blue = b; |
|
2110 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2111 |
||
2112 |
BEGIN_INTERRUPTSBLOCKED |
|
2113 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2114 |
END_INTERRUPTSBLOCKED |
|
2115 |
RETURN ( self ); |
|
0 | 2116 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2117 |
%}. |
0 | 2118 |
self primitiveFailed |
295 | 2119 |
! ! |
2120 |
||
2121 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2122 |
||
2123 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2124 |
"change a cursors colors" |
|
2125 |
||
2126 |
|fgR fgG fgB bgR bgG bgB| |
|
2127 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2128 |
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
|
2129 |
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
|
2130 |
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
|
2131 |
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
|
2132 |
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
|
2133 |
bgB := bgColor scaledBlue. |
0 | 2134 |
%{ |
295 | 2135 |
XColor fgcolor, bgcolor; |
2136 |
||
2137 |
if (__isExternalAddress(aCursorId) |
|
2138 |
&& __bothSmallInteger(fgG, fgB) |
|
2139 |
&& __bothSmallInteger(bgR, bgG) |
|
2140 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2141 |
||
555 | 2142 |
fgcolor.red = __intVal(fgR); |
2143 |
fgcolor.green= __intVal(fgG); |
|
2144 |
fgcolor.blue = __intVal(fgB); |
|
2145 |
bgcolor.red = __intVal(bgR); |
|
2146 |
bgcolor.green= __intVal(bgG); |
|
2147 |
bgcolor.blue = __intVal(bgB); |
|
70 | 2148 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2149 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2150 |
END_INTERRUPTSBLOCKED |
2151 |
RETURN ( self ); |
|
2152 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2153 |
%}. |
0 | 2154 |
self primitiveFailed |
70 | 2155 |
! |
2156 |
||
295 | 2157 |
createCursorShape:aShape |
974 | 2158 |
"create a cursor given a shape-symbol. This only works |
2159 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2160 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2161 |
|
2162 |
|number id| |
|
2163 |
||
2164 |
displayId isNil ifTrue:[ |
|
2165 |
self primitiveFailed. |
|
2166 |
^ nil |
|
2167 |
]. |
|
2168 |
number := self shapeNumberFromSymbol:aShape. |
|
2169 |
%{ |
|
2170 |
Cursor newCursor; |
|
2171 |
||
2172 |
if (__isSmallInteger(number)) { |
|
2173 |
BEGIN_INTERRUPTSBLOCKED |
|
555 | 2174 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2175 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2176 |
if (newCursor) |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2177 |
__cnt_cursor++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2178 |
#endif |
295 | 2179 |
END_INTERRUPTSBLOCKED |
2180 |
if (newCursor != (Cursor)0) { |
|
2181 |
id = __MKOBJ(newCursor); |
|
70 | 2182 |
} |
0 | 2183 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2184 |
%}. |
295 | 2185 |
^ id |
2186 |
! |
|
2187 |
||
974 | 2188 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2189 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2190 |
||
2191 |
|id sourceId maskId| |
|
2192 |
||
2193 |
displayId isNil ifTrue:[ |
|
2194 |
self primitiveFailed. |
|
2195 |
^ nil |
|
2196 |
]. |
|
2197 |
sourceId := sourceForm id. |
|
2198 |
maskId := maskForm id. |
|
2199 |
%{ |
|
2200 |
Cursor newCursor; |
|
2201 |
XColor fgColor, bgColor; |
|
2202 |
||
2203 |
if (__isExternalAddress(sourceId) |
|
2204 |
&& __isExternalAddress(maskId) |
|
2205 |
&& __bothSmallInteger(hx, hy)) { |
|
2206 |
fgColor.red = 0; /* fg is black */ |
|
2207 |
fgColor.green = 0; |
|
2208 |
fgColor.blue = 0; |
|
2209 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2210 |
bgColor.green = 0xFFFF; |
|
2211 |
bgColor.blue = 0xFFFF; |
|
2212 |
||
2213 |
BEGIN_INTERRUPTSBLOCKED |
|
2214 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2215 |
_PixmapVal(sourceId), |
|
2216 |
_PixmapVal(maskId), |
|
555 | 2217 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2218 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2219 |
if (newCursor) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2220 |
__cnt_cursor++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2221 |
#endif |
295 | 2222 |
END_INTERRUPTSBLOCKED |
2223 |
if (newCursor != (Cursor)0) { |
|
2224 |
id = __MKOBJ(newCursor); |
|
70 | 2225 |
} |
0 | 2226 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2227 |
%}. |
295 | 2228 |
^ id |
2229 |
! |
|
2230 |
||
2231 |
destroyCursor:aCursorId |
|
974 | 2232 |
"release a cursor - frees any device resources" |
0 | 2233 |
|
2234 |
%{ /* NOCONTEXT */ |
|
2235 |
||
295 | 2236 |
if (ISCONNECTED) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2237 |
if (__isExternalAddress(aCursorId)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2238 |
Cursor curs = _CursorVal(aCursorId); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2239 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2240 |
if (curs) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2241 |
BEGIN_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2242 |
XFreeCursor(myDpy, curs); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2243 |
#ifdef COUNT_RESOURCES |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2244 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2245 |
#endif |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2246 |
END_INTERRUPTSBLOCKED |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2247 |
} |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2248 |
RETURN ( self ); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
2249 |
} |
0 | 2250 |
} |
974 | 2251 |
%}. |
0 | 2252 |
self primitiveFailed |
295 | 2253 |
! |
2254 |
||
974 | 2255 |
needDeviceFormsForCursor |
2256 |
^ true |
|
2257 |
! |
|
2258 |
||
295 | 2259 |
shapeNumberFromSymbol:shape |
974 | 2260 |
"given a shape-symbol, return the corresponding cursor-number, |
2261 |
or nil if no such standard cursor exists." |
|
295 | 2262 |
|
2263 |
"this is pure X-knowlegde - but you may easily add more" |
|
2264 |
||
2265 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2266 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2267 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2268 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2269 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2270 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2271 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2272 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2273 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2274 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2275 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2276 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2277 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2278 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2279 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2280 |
((shape == #origin) |
|
2281 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2282 |
((shape == #corner) |
|
2283 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2284 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2285 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2286 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2287 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2288 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
974 | 2289 |
"/ ('XWORKSTATION: invalid cursorShape:' , shape printString) infoPrintNL. |
2290 |
^ nil |
|
0 | 2291 |
! ! |
2292 |
||
2293 |
!XWorkstation methodsFor:'drawing'! |
|
2294 |
||
976 | 2295 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
2296 |
width:w height:h gc:dstGCId |
|
118 | 2297 |
"do a bit-blt; copy bits from the rectangle defined by |
2298 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2299 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2300 |
argument is not integer." |
|
0 | 2301 |
|
2302 |
%{ /* NOCONTEXT */ |
|
2303 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2304 |
GC gc; |
0 | 2305 |
Drawable source, dest; |
2306 |
||
975 | 2307 |
if (__isExternalAddress(dstGCId) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2308 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2309 |
&& __isExternalAddress(destId) |
97 | 2310 |
&& __bothSmallInteger(w, h) |
2311 |
&& __bothSmallInteger(srcX, srcY) |
|
2312 |
&& __bothSmallInteger(dstX, dstY)) { |
|
975 | 2313 |
gc = _GCVal(dstGCId); |
70 | 2314 |
source = (Drawable) _WindowVal(sourceId); |
2315 |
dest = (Drawable) _WindowVal(destId); |
|
2316 |
XCopyArea(myDpy, source, dest, gc, |
|
555 | 2317 |
__intVal(srcX), __intVal(srcY), |
2318 |
__intVal(w), __intVal(h), |
|
2319 |
__intVal(dstX), __intVal(dstY)); |
|
70 | 2320 |
RETURN ( self ); |
0 | 2321 |
} |
118 | 2322 |
%}. |
2323 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2324 |
or any non integer coordinate" |
|
2325 |
||
0 | 2326 |
self primitiveFailed |
2327 |
! |
|
2328 |
||
976 | 2329 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
2330 |
width:w height:h gc:dstGCId |
|
118 | 2331 |
"do a bit-blt, but only copy the low-bit plane; |
2332 |
copy bits from the rectangle defined by |
|
2333 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2334 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2335 |
argument is not integer." |
|
0 | 2336 |
|
2337 |
%{ /* NOCONTEXT */ |
|
2338 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2339 |
GC gc; |
0 | 2340 |
Drawable source, dest; |
2341 |
||
975 | 2342 |
if (__isExternalAddress(dstGCId) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2343 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2344 |
&& __isExternalAddress(destId) |
97 | 2345 |
&& __bothSmallInteger(w, h) |
2346 |
&& __bothSmallInteger(srcX, srcY) |
|
2347 |
&& __bothSmallInteger(dstX, dstY)) { |
|
975 | 2348 |
gc = _GCVal(dstGCId); |
70 | 2349 |
source = (Drawable) _WindowVal(sourceId); |
2350 |
dest = (Drawable) _WindowVal(destId); |
|
2351 |
XCopyPlane(myDpy, source, dest, gc, |
|
555 | 2352 |
__intVal(srcX), __intVal(srcY), |
2353 |
__intVal(w), __intVal(h), |
|
2354 |
__intVal(dstX), __intVal(dstY), 1); |
|
70 | 2355 |
RETURN ( self ); |
0 | 2356 |
} |
118 | 2357 |
%}. |
2358 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2359 |
or any non integer coordinate" |
|
2360 |
||
0 | 2361 |
self primitiveFailed |
2362 |
! |
|
2363 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2364 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2365 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2366 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2367 |
|
2368 |
%{ /* NOCONTEXT */ |
|
2369 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2370 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2371 |
Window win; |
0 | 2372 |
int w, h, angle1, angle2; |
2373 |
double f; |
|
2374 |
||
97 | 2375 |
if (__isSmallInteger(startAngle)) |
850 | 2376 |
angle1 = __intVal(startAngle) * 64; |
36 | 2377 |
else if (__isFloat(startAngle)) { |
850 | 2378 |
f = __floatVal(startAngle); |
2379 |
angle1 = f * 64; |
|
0 | 2380 |
} |
97 | 2381 |
if (__isSmallInteger(angle)) |
850 | 2382 |
angle2 = __intVal(angle) * 64; |
36 | 2383 |
else if (__isFloat(angle)) { |
850 | 2384 |
f = __floatVal(angle); |
2385 |
angle2 = f * 64; |
|
0 | 2386 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2387 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2388 |
&& __isExternalAddress(aDrawableId) |
97 | 2389 |
&& __bothSmallInteger(x, y) |
2390 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2391 |
win = _WindowVal(aDrawableId); |
2392 |
gc = _GCVal(aGCId); |
|
2393 |
w = __intVal(width); |
|
2394 |
h = __intVal(height); |
|
2395 |
/* |
|
2396 |
* need this check here: some servers simply dump core with bad args |
|
2397 |
*/ |
|
2398 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2399 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2400 |
w, h, angle1, angle2); |
|
2401 |
} |
|
2402 |
RETURN ( self ); |
|
0 | 2403 |
} |
73 | 2404 |
%}. |
2405 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2406 |
self primitiveFailed |
2407 |
! |
|
2408 |
||
295 | 2409 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2410 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2411 |
||
2412 |
%{ /* NOCONTEXT */ |
|
2413 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2414 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2415 |
Window win; |
295 | 2416 |
|
2417 |
if (__isExternalAddress(aGCId) |
|
2418 |
&& __isExternalAddress(aDrawableId) |
|
2419 |
&& __bothSmallInteger(x0, y0) |
|
2420 |
&& __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
|
2421 |
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
|
2422 |
win = _WindowVal(aDrawableId); |
555 | 2423 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
2424 |
__intVal(x1), __intVal(y1)); |
|
295 | 2425 |
RETURN ( self ); |
2426 |
} |
|
2427 |
%}. |
|
2428 |
"badGC, badDrawable or coordinates not integer" |
|
2429 |
self primitiveFailed |
|
2430 |
! |
|
2431 |
||
2432 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2433 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2434 |
||
2435 |
%{ /* NOCONTEXT */ |
|
2436 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2437 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2438 |
Window win; |
295 | 2439 |
|
2440 |
if (__isExternalAddress(aGCId) |
|
2441 |
&& __isExternalAddress(aDrawableId) |
|
2442 |
&& __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
|
2443 |
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
|
2444 |
win = _WindowVal(aDrawableId); |
555 | 2445 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
295 | 2446 |
RETURN ( self ); |
2447 |
} |
|
2448 |
%}. |
|
2449 |
"badGC, badDrawable or x/y not integer" |
|
2450 |
self primitiveFailed |
|
2451 |
! |
|
2452 |
||
2453 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2454 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2455 |
define the polygon. |
|
2456 |
If any coordinate is not integer, an error is triggered." |
|
2457 |
||
2458 |
|numberOfPoints newPoints| |
|
2459 |
||
2460 |
numberOfPoints := aPolygon size. |
|
2461 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2462 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2463 |
Window win; |
295 | 2464 |
OBJ point, x, y; |
2465 |
int i, num; |
|
2466 |
XPoint *points; |
|
2467 |
XPoint qPoints[100]; |
|
377 | 2468 |
int mustFree = 0; |
295 | 2469 |
|
2470 |
if (__isExternalAddress(aGCId) |
|
2471 |
&& __isExternalAddress(aDrawableId) |
|
2472 |
&& __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
|
2473 |
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
|
2474 |
win = _WindowVal(aDrawableId); |
555 | 2475 |
num = __intVal(numberOfPoints); |
295 | 2476 |
/* |
2477 |
* avoid a (slow) malloc, if the number of points is small |
|
2478 |
*/ |
|
2479 |
if (num > 100) { |
|
2480 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2481 |
if (! points) goto fail; |
|
377 | 2482 |
mustFree = 1; |
295 | 2483 |
} else |
2484 |
points = qPoints; |
|
2485 |
||
2486 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2487 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2488 |
if (! __isPoint(point)) goto fail; |
2489 |
x = _point_X(point); |
|
2490 |
y = _point_Y(point); |
|
2491 |
if (! __bothSmallInteger(x, y)) |
|
2492 |
goto fail; |
|
555 | 2493 |
points[i].x = __intVal(x); |
2494 |
points[i].y = __intVal(y); |
|
295 | 2495 |
} |
2496 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2497 |
if (mustFree) |
295 | 2498 |
free(points); |
2499 |
RETURN ( self ); |
|
2500 |
} |
|
2501 |
fail: ; |
|
377 | 2502 |
if (mustFree) |
382 | 2503 |
free(points); |
295 | 2504 |
%}. |
2505 |
"badGC, badDrawable or coordinates not integer" |
|
2506 |
self primitiveFailed |
|
2507 |
! |
|
2508 |
||
2509 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2510 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2511 |
||
2512 |
%{ /* NOCONTEXT */ |
|
2513 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2514 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2515 |
Window win; |
295 | 2516 |
int w, h; |
2517 |
||
2518 |
if (__isExternalAddress(aGCId) |
|
2519 |
&& __isExternalAddress(aDrawableId) |
|
2520 |
&& __bothSmallInteger(x, y) |
|
2521 |
&& __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
|
2522 |
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
|
2523 |
win = _WindowVal(aDrawableId); |
555 | 2524 |
w = __intVal(width); |
2525 |
h = __intVal(height); |
|
295 | 2526 |
/* |
2527 |
* need this check here: some servers simply dump core with bad args |
|
2528 |
*/ |
|
2529 |
if ((w >= 0) && (h >= 0)) { |
|
555 | 2530 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
295 | 2531 |
} |
2532 |
RETURN ( self ); |
|
2533 |
} |
|
2534 |
%}. |
|
2535 |
"badGC, badDrawable or coordinates not integer" |
|
2536 |
self primitiveFailed |
|
2537 |
! |
|
2538 |
||
2539 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2540 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2541 |
foreground and background characters. |
|
2542 |
If the coordinates are not integers, an error is triggered." |
|
2543 |
||
2544 |
%{ /* NOCONTEXT */ |
|
2545 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2546 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2547 |
Window win; |
295 | 2548 |
unsigned char *cp; |
2549 |
OBJ cls; |
|
2550 |
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
|
2551 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2552 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2553 |
int nInstBytes; |
295 | 2554 |
|
2555 |
if (__isExternalAddress(aGCId) |
|
2556 |
&& __isExternalAddress(aDrawableId) |
|
2557 |
&& __isNonNilObject(aString) |
|
2558 |
&& __bothSmallInteger(index1, index2) |
|
2559 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2560 |
gc = _GCVal(aGCId); |
2561 |
win = _WindowVal(aDrawableId); |
|
2562 |
cls = __qClass(aString); |
|
2563 |
||
2564 |
i1 = __intVal(index1) - 1; |
|
2565 |
if (i1 >= 0) { |
|
2566 |
i2 = __intVal(index2) - 1; |
|
2567 |
if (i2 < i1) { |
|
2568 |
RETURN (self); |
|
2569 |
} |
|
2570 |
||
2571 |
cp = _stringVal(aString); |
|
2572 |
l = i2 - i1 + 1; |
|
2573 |
||
2574 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2575 |
n = _stringSize(aString); |
|
2576 |
if (i2 < n) { |
|
2577 |
cp += i1; |
|
2578 |
if (l > 1000) l = 1000; |
|
2579 |
if (opaque == true) |
|
2580 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2581 |
else |
|
2582 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2583 |
RETURN ( self ); |
|
2584 |
} |
|
2585 |
} |
|
2586 |
||
2587 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2588 |
cp += nInstBytes; |
|
2589 |
||
2590 |
if (__isBytes(aString)) { |
|
2591 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2592 |
||
2593 |
if (i2 < n) { |
|
2594 |
cp += i1; |
|
2595 |
if (l > 1000) l = 1000; |
|
2596 |
if (opaque == true) |
|
2597 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2598 |
else |
|
2599 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2600 |
RETURN ( self ); |
|
2601 |
} |
|
2602 |
} |
|
2603 |
||
2604 |
/* TWOBYTESTRINGS */ |
|
2605 |
if (__isWords(aString)) { |
|
2606 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2607 |
||
2608 |
if (i2 < n) { |
|
2609 |
union { |
|
2610 |
char b[2]; |
|
2611 |
unsigned short s; |
|
2612 |
} u; |
|
2613 |
int i; |
|
2614 |
XChar2b *cp2 = (XChar2b *)0; |
|
2615 |
int mustFree = 0; |
|
2616 |
||
2617 |
cp += (i1 * 2); |
|
2618 |
if (l > 1000) l = 1000; |
|
2619 |
||
2620 |
/* |
|
2621 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2622 |
* X expects them MSB first |
|
2623 |
* convert as required |
|
2624 |
*/ |
|
2625 |
||
2626 |
u.s = 0x1234; |
|
2627 |
if (u.b[0] != 0x12) { |
|
2628 |
if (l <= NLOCALBUFFER) { |
|
2629 |
cp2 = xlatebuffer; |
|
2630 |
} else { |
|
2631 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2632 |
mustFree = 1; |
|
2633 |
} |
|
2634 |
for (i=0; i<l; i++) { |
|
2635 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2636 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2637 |
} |
|
2638 |
cp = (char *) cp2; |
|
2639 |
} |
|
2640 |
||
2641 |
if (opaque == true) |
|
2642 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2643 |
else |
|
2644 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2645 |
||
2646 |
if (mustFree) { |
|
2647 |
free(cp2); |
|
2648 |
} |
|
2649 |
||
2650 |
RETURN ( self ); |
|
2651 |
} |
|
2652 |
} |
|
2653 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2654 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2655 |
#undef NLOCALBUFFER |
295 | 2656 |
%}. |
2657 |
"x/y not integer, badGC or drawable, or not a string" |
|
2658 |
self primitiveFailed |
|
2659 |
! |
|
2660 |
||
2661 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2662 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2663 |
foreground and background characters. |
|
2664 |
If the coordinates are not integers, an error is triggered." |
|
2665 |
||
2666 |
%{ /* NOCONTEXT */ |
|
2667 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2668 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2669 |
Window win; |
295 | 2670 |
unsigned char *cp; |
2671 |
int n; |
|
2672 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2673 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2674 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2675 |
int nInstBytes; |
295 | 2676 |
|
2677 |
if (__isExternalAddress(aGCId) |
|
2678 |
&& __isExternalAddress(aDrawableId) |
|
2679 |
&& __isNonNilObject(aString) |
|
2680 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2681 |
gc = _GCVal(aGCId); |
2682 |
win = _WindowVal(aDrawableId); |
|
2683 |
cls = __qClass(aString); |
|
2684 |
||
2685 |
cp = _stringVal(aString); |
|
2686 |
||
2687 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2688 |
n = _stringSize(aString); |
|
2689 |
if (n > 1000) n = 1000; |
|
2690 |
if (opaque == true) |
|
2691 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2692 |
else |
|
2693 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2694 |
RETURN ( self ); |
|
2695 |
} |
|
2696 |
||
2697 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2698 |
cp += nInstBytes; |
|
2699 |
||
2700 |
if (__isBytes(aString)) { |
|
2701 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2702 |
||
2703 |
if (n > 1000) n = 1000; |
|
2704 |
if (opaque == true) |
|
2705 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2706 |
else |
|
2707 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2708 |
RETURN ( self ); |
|
2709 |
} |
|
2710 |
||
2711 |
/* TWOBYTESTRINGS */ |
|
2712 |
if (__isWords(aString)) { |
|
2713 |
union { |
|
2714 |
char b[2]; |
|
2715 |
unsigned short s; |
|
2716 |
} u; |
|
2717 |
int i; |
|
2718 |
XChar2b *cp2; |
|
2719 |
int mustFree = 0; |
|
2720 |
||
2721 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2722 |
if (n > 1000) n = 1000; |
|
2723 |
||
2724 |
/* |
|
2725 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2726 |
* X expects them MSB first |
|
2727 |
* convert as required |
|
2728 |
*/ |
|
2729 |
||
2730 |
u.s = 0x1234; |
|
2731 |
if (u.b[0] != 0x12) { |
|
2732 |
if (n <= NLOCALBUFFER) { |
|
2733 |
cp2 = xlatebuffer; |
|
2734 |
} else { |
|
2735 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2736 |
mustFree = 1; |
|
2737 |
} |
|
2738 |
||
2739 |
for (i=0; i<n; i++) { |
|
2740 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2741 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2742 |
} |
|
2743 |
cp = (char *) cp2; |
|
2744 |
} |
|
2745 |
||
2746 |
if (opaque == true) |
|
2747 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2748 |
else |
|
2749 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2750 |
||
2751 |
||
2752 |
if (mustFree) { |
|
2753 |
free(cp2); |
|
2754 |
} |
|
2755 |
||
2756 |
RETURN ( self ); |
|
2757 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2758 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2759 |
#undef NLOCALBUFFER |
295 | 2760 |
%}. |
2761 |
"x/y not integer, badGC or drawable, or not a string" |
|
2762 |
self primitiveFailed |
|
2763 |
! |
|
2764 |
||
2765 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2766 |
width:imageWidth height:imageHeight |
|
2767 |
x:srcx y:srcy |
|
2768 |
into:aDrawableId |
|
2769 |
x:dstx y:dsty |
|
2770 |
width:w height:h |
|
2771 |
with:aGCId |
|
2772 |
||
2773 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2774 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2775 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2776 |
depth and pixel-units to be different. |
|
2777 |
It has to be checked elsewhere, that the server can do it with the given |
|
2778 |
depth - otherwise, primitive failure will be signalled. |
|
2779 |
Also it is assumed, that the colormap is setup correctly and the |
|
2780 |
colors are allocated - otherwise the colors may be wrong." |
|
2781 |
||
2782 |
" |
|
2783 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2784 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2785 |
" |
|
2786 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2787 |
width:imageWidth height:imageHeight |
|
2788 |
x:srcx y:srcy |
|
2789 |
into:aDrawableId |
|
2790 |
x:dstx y:dsty |
|
2791 |
width:w height:h |
|
2792 |
with:aGCId) |
|
2793 |
ifFalse:[ |
|
2794 |
" |
|
2795 |
also happens, if a segmentation violation occurs in the |
|
2796 |
XPutImage ... |
|
2797 |
" |
|
2798 |
self primitiveFailed |
|
2799 |
]. |
|
2800 |
! |
|
2801 |
||
2802 |
drawBits:imageBits depth:imageDepth |
|
2803 |
width:imageWidth height:imageHeight |
|
2804 |
x:srcx y:srcy |
|
2805 |
into:aDrawableId |
|
2806 |
x:dstx y:dsty |
|
2807 |
width:w height:h |
|
2808 |
with:aGCId |
|
2809 |
||
2810 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2811 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2812 |
Individual source pixels must have imageDepth bits. |
|
2813 |
It has to be checked elsewhere, that the server can do it with the given |
|
2814 |
depth - otherwise, primitive failure will be signalled. |
|
2815 |
Also it is assumed, that the colormap is setup correctly and the |
|
2816 |
colors are allocated - otherwise the colors may be wrong." |
|
2817 |
||
2818 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2819 |
width:imageWidth height:imageHeight |
|
2820 |
x:srcx y:srcy |
|
2821 |
into:aDrawableId |
|
2822 |
x:dstx y:dsty |
|
2823 |
width:w height:h |
|
2824 |
with:aGCId |
|
2825 |
||
2826 |
! |
|
2827 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2828 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
850 | 2829 |
in:aDrawableId with:aGCId |
90 | 2830 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2831 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2832 |
|
2833 |
%{ /* NOCONTEXT */ |
|
2834 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2835 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2836 |
Window win; |
0 | 2837 |
int w, h, angle1, angle2; |
2838 |
double f; |
|
2839 |
||
97 | 2840 |
if (__isSmallInteger(startAngle)) |
850 | 2841 |
angle1 = __intVal(startAngle) * 64; |
36 | 2842 |
else if (__isFloat(startAngle)) { |
850 | 2843 |
f = __floatVal(startAngle); |
2844 |
angle1 = f * 64; |
|
0 | 2845 |
} |
97 | 2846 |
if (__isSmallInteger(angle)) |
850 | 2847 |
angle2 = __intVal(angle) * 64; |
36 | 2848 |
else if (__isFloat(angle)) { |
850 | 2849 |
f = __floatVal(angle); |
2850 |
angle2 = f * 64; |
|
0 | 2851 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2852 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2853 |
&& __isExternalAddress(aDrawableId) |
97 | 2854 |
&& __bothSmallInteger(x, y) |
2855 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2856 |
gc = _GCVal(aGCId); |
2857 |
win = _WindowVal(aDrawableId); |
|
2858 |
w = __intVal(width); |
|
2859 |
h = __intVal(height); |
|
2860 |
/* |
|
2861 |
* need this check here: some servers simply dump core with bad args |
|
2862 |
*/ |
|
2863 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2864 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2865 |
w, h, angle1, angle2); |
|
2866 |
} |
|
2867 |
RETURN ( self ); |
|
0 | 2868 |
} |
73 | 2869 |
%}. |
2870 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2871 |
self primitiveFailed |
2872 |
! |
|
2873 |
||
2874 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2875 |
"fill a polygon given by its points. |
2876 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2877 |
|
2878 |
|numberOfPoints| |
|
0 | 2879 |
|
2880 |
numberOfPoints := aPolygon size. |
|
2881 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2882 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2883 |
Window win; |
73 | 2884 |
OBJ point, x, y; |
2885 |
int i, num; |
|
2886 |
XPoint *points; |
|
2887 |
XPoint qPoints[100]; |
|
377 | 2888 |
int mustFree = 0; |
73 | 2889 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2890 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2891 |
&& __isExternalAddress(aDrawableId) |
97 | 2892 |
&& __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
|
2893 |
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
|
2894 |
win = _WindowVal(aDrawableId); |
555 | 2895 |
num = __intVal(numberOfPoints); |
73 | 2896 |
if (num < 3) { |
70 | 2897 |
RETURN ( self ); |
2898 |
} |
|
73 | 2899 |
/* |
2900 |
* avoid (slow) malloc, if not many points |
|
2901 |
*/ |
|
96 | 2902 |
if (num > 100) { |
73 | 2903 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 2904 |
if (! points) goto fail; |
377 | 2905 |
mustFree = 1; |
96 | 2906 |
} else |
73 | 2907 |
points = qPoints; |
2908 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2909 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 2910 |
if (! __isPoint(point)) goto fail; |
2911 |
x = _point_X(point); |
|
2912 |
y = _point_Y(point); |
|
97 | 2913 |
if (! __bothSmallInteger(x, y)) |
73 | 2914 |
goto fail; |
555 | 2915 |
points[i].x = __intVal(x); |
2916 |
points[i].y = __intVal(y); |
|
73 | 2917 |
} |
2918 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 2919 |
if (mustFree) |
73 | 2920 |
free(points); |
2921 |
RETURN ( self ); |
|
377 | 2922 |
|
0 | 2923 |
fail: ; |
382 | 2924 |
if (mustFree) |
2925 |
free(points); |
|
0 | 2926 |
} |
73 | 2927 |
%}. |
2928 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2929 |
self primitiveFailed |
2930 |
! |
|
2931 |
||
295 | 2932 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
2933 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2934 |
||
2935 |
%{ /* NOCONTEXT */ |
|
2936 |
||
2937 |
int w, h; |
|
2938 |
||
2939 |
if (__isExternalAddress(aGCId) |
|
2940 |
&& __isExternalAddress(aDrawableId) |
|
2941 |
&& __bothSmallInteger(x, y) |
|
2942 |
&& __bothSmallInteger(width, height)) { |
|
555 | 2943 |
w = __intVal(width); |
2944 |
h = __intVal(height); |
|
295 | 2945 |
/* |
2946 |
* need this check here: some servers simply dump core with bad args |
|
2947 |
*/ |
|
2948 |
if ((w >= 0) && (h >= 0)) { |
|
2949 |
XFillRectangle(myDpy, |
|
2950 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
555 | 2951 |
__intVal(x), __intVal(y), w, h); |
295 | 2952 |
} |
2953 |
RETURN ( self ); |
|
2954 |
} |
|
2955 |
%}. |
|
2956 |
"badGC, badDrawable or coordinates not integer" |
|
2957 |
self primitiveFailed |
|
43 | 2958 |
! |
2959 |
||
2960 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 2961 |
width:imageWidth height:imageHeight |
2962 |
x:srcx y:srcy |
|
2963 |
into:aDrawableId |
|
2964 |
x:dstx y:dsty |
|
2965 |
width:w height:h |
|
2966 |
with:aGCId |
|
0 | 2967 |
|
132 | 2968 |
"since XPutImage may allocate huge amount of stack space |
2969 |
(some implementations use alloca), this must run with unlimited stack." |
|
2970 |
||
12 | 2971 |
%{ /* UNLIMITEDSTACK */ |
0 | 2972 |
|
43 | 2973 |
/* |
2974 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
2975 |
* XPutImage |
|
2976 |
*/ |
|
2977 |
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
|
2978 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2979 |
Window win; |
43 | 2980 |
XImage image; |
377 | 2981 |
int imgWdth; |
43 | 2982 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2983 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2984 |
&& __isExternalAddress(aDrawableId) |
97 | 2985 |
&& __bothSmallInteger(srcx, srcy) |
2986 |
&& __bothSmallInteger(dstx, dsty) |
|
2987 |
&& __bothSmallInteger(w, h) |
|
2988 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
2989 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 2990 |
&& __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
|
2991 |
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
|
2992 |
win = _WindowVal(aDrawableId); |
811 | 2993 |
if (! gc || !win) |
2994 |
goto fail; |
|
46 | 2995 |
#ifdef ARGDEBUG |
70 | 2996 |
printf("args ok\n"); |
46 | 2997 |
#endif |
555 | 2998 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
2999 |
image.width = imgWdth = __intVal(imageWidth); |
|
3000 |
image.height = __intVal(imageHeight); |
|
70 | 3001 |
image.xoffset = 0; |
3002 |
image.format = ZPixmap; |
|
3003 |
image.byte_order = MSBFirst; |
|
3004 |
image.bitmap_unit = 8; |
|
3005 |
image.bitmap_bit_order = MSBFirst; |
|
3006 |
image.bitmap_pad = 8; |
|
555 | 3007 |
image.depth = __intVal(imageDepth); |
3008 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
70 | 3009 |
switch (image.bits_per_pixel) { |
3010 |
case 1: |
|
377 | 3011 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 3012 |
break; |
3013 |
case 2: |
|
377 | 3014 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 3015 |
break; |
3016 |
case 4: |
|
377 | 3017 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 3018 |
break; |
3019 |
case 8: |
|
377 | 3020 |
image.bytes_per_line = imgWdth; |
70 | 3021 |
break; |
3022 |
case 16: |
|
377 | 3023 |
image.bytes_per_line = imgWdth*2; |
70 | 3024 |
break; |
3025 |
case 24: |
|
377 | 3026 |
image.bytes_per_line = imgWdth*3; |
70 | 3027 |
break; |
193 | 3028 |
case 32: |
377 | 3029 |
image.bytes_per_line = imgWdth*4; |
193 | 3030 |
break; |
70 | 3031 |
default: |
46 | 3032 |
#ifdef ARGDEBUG |
70 | 3033 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3034 |
#endif |
70 | 3035 |
goto fail; |
3036 |
} |
|
3037 |
image.red_mask = 0xFFFF; |
|
3038 |
image.green_mask = 0xFFFF; |
|
3039 |
image.blue_mask = 0xFFFF; |
|
555 | 3040 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
3041 |
__intVal(dstx), __intVal(dsty), |
|
3042 |
__intVal(w), __intVal(h)); |
|
70 | 3043 |
RETURN ( true ); |
43 | 3044 |
} |
46 | 3045 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3046 |
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
|
3047 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3048 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3049 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3050 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3051 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3052 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3053 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3054 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3055 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3056 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3057 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3058 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3059 |
#endif |
3060 |
||
0 | 3061 |
fail: ; |
3062 |
%} |
|
3063 |
. |
|
12 | 3064 |
^ false |
0 | 3065 |
! ! |
3066 |
||
86 | 3067 |
!XWorkstation methodsFor:'event handling'! |
0 | 3068 |
|
3069 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3070 |
"central event handling method: |
|
54 | 3071 |
get next event and send appropriate message to the sensor or view. |
0 | 3072 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3073 |
otherwise only events for the view with given id are processed. |
3074 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3075 |
handled." |
|
3076 |
||
54 | 3077 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3078 |
AbortSignal catch:[ |
83 | 3079 |
self dispatchLastEvent. |
3080 |
] |
|
54 | 3081 |
]. |
12 | 3082 |
! |
3083 |
||
295 | 3084 |
dispatchExposeEventFor:aViewIdOrNil |
3085 |
"get next expose event and send appropriate message to the sensor or view. |
|
3086 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3087 |
otherwise only events for the view with given id are processed." |
|
3088 |
||
3089 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3090 |
! |
3091 |
||
3092 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3093 |
|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
|
3094 |
eventType| |
12 | 3095 |
|
3096 |
%{ /* STACK: 8000 */ |
|
3097 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3098 |
|
3099 |
Display *dpy = myDpy; |
|
135 | 3100 |
OBJ eB; |
3101 |
XEvent *ev; |
|
3102 |
||
3103 |
# define ae ((XAnyEvent *)ev) |
|
3104 |
# define ee ((XExposeEvent *)ev) |
|
3105 |
# define ke ((XKeyPressedEvent *)ev) |
|
3106 |
# define be ((XButtonPressedEvent *)ev) |
|
3107 |
# define ce ((XConfigureEvent *)ev) |
|
3108 |
# define me ((XMotionEvent *)ev) |
|
3109 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3110 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3111 |
# define de ((XDestroyWindowEvent *)ev) |
|
3112 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3113 |
# define mape ((XMappingEvent *)ev) |
135 | 3114 |
|
0 | 3115 |
KeySym keySym; |
3116 |
unsigned char buffer[10]; |
|
3117 |
int i, nchars; |
|
3118 |
char *keySymString; |
|
3119 |
char keySymStringBuffer[32]; |
|
3120 |
static unsigned multiClickTime = 0; |
|
3121 |
unsigned nextMultiClickTime; |
|
150 | 3122 |
OBJ upDown; |
115 | 3123 |
|
3124 |
struct inlineCache *ipS; |
|
0 | 3125 |
static struct inlineCache vid = _ILC1; |
12 | 3126 |
|
3127 |
static struct inlineCache expS = _ILC5; |
|
3128 |
static struct inlineCache gexpS = _ILC5; |
|
3129 |
static struct inlineCache nexpS = _ILC1; |
|
3130 |
static struct inlineCache motS = _ILC4; |
|
3131 |
static struct inlineCache bpS = _ILC4; |
|
3132 |
static struct inlineCache bmpS = _ILC4; |
|
3133 |
static struct inlineCache bspS = _ILC4; |
|
3134 |
static struct inlineCache brS = _ILC4; |
|
3135 |
static struct inlineCache focInS = _ILC1; |
|
3136 |
static struct inlineCache focOutS = _ILC1; |
|
3137 |
static struct inlineCache peS = _ILC4; |
|
3138 |
static struct inlineCache plS = _ILC2; |
|
54 | 3139 |
static struct inlineCache termS = _ILC1; |
3140 |
static struct inlineCache savtermS = _ILC1; |
|
3141 |
static struct inlineCache destrS = _ILC1; |
|
3142 |
static struct inlineCache unmapS = _ILC1; |
|
3143 |
static struct inlineCache mapS = _ILC1; |
|
3144 |
static struct inlineCache confS = _ILC5; |
|
70 | 3145 |
static struct inlineCache coveredS = _ILC2; |
12 | 3146 |
|
3147 |
static struct inlineCache keymap = _ILC0; |
|
3148 |
static struct inlineCache created = _ILC0; |
|
3149 |
static struct inlineCache mapReq = _ILC0; |
|
3150 |
static struct inlineCache repar = _ILC0; |
|
3151 |
static struct inlineCache confReq = _ILC0; |
|
3152 |
static struct inlineCache resReq = _ILC0; |
|
3153 |
static struct inlineCache prop = _ILC0; |
|
129 | 3154 |
static struct inlineCache selClear = _ILC1; |
90 | 3155 |
static struct inlineCache selReq = _ILC4; |
3156 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3157 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3158 |
static struct inlineCache mapping = _ILC2; |
70 | 3159 |
static struct inlineCache vis = _ILC1; |
12 | 3160 |
|
3161 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3162 |
static struct inlineCache skrS = _ILC4; |
12 | 3163 |
|
555 | 3164 |
eB = __INST(eventBuffer); |
135 | 3165 |
if (__isByteArray(eB)) { |
555 | 3166 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3167 |
} else { |
3168 |
printf("DISPLAY: no eventBuffer\n"); |
|
3169 |
RETURN (false); |
|
3170 |
} |
|
3171 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3172 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3173 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3174 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3175 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3176 |
RETURN (nil); |
12 | 3177 |
} |
3178 |
||
3179 |
/* |
|
3180 |
* key, button and pointer events are sent to the sensor, |
|
3181 |
* or (if there is none) to the delegate. |
|
3182 |
* or (if there is none) to the view. |
|
26 | 3183 |
* |
3184 |
* expose events are sent to the sensor, |
|
3185 |
* or (if there is none) to the view |
|
3186 |
* |
|
12 | 3187 |
* sensor and delegate get view as additional argument |
115 | 3188 |
* all of this has been taken out of here to corresponding methods |
3189 |
* in DeviceWorkstation. |
|
12 | 3190 |
*/ |
90 | 3191 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3192 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3193 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3194 |
#endif |
135 | 3195 |
switch (ev->type) { |
70 | 3196 |
case KeyRelease: |
115 | 3197 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3198 |
ipS = &skrS; |
150 | 3199 |
upDown = false; |
70 | 3200 |
goto keyPressAndRelease; |
3201 |
||
3202 |
case KeyPress: |
|
115 | 3203 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3204 |
ipS = &skpS; |
150 | 3205 |
upDown = true; |
3206 |
/* FALL INTO */ |
|
70 | 3207 |
|
3208 |
keyPressAndRelease: |
|
555 | 3209 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
3210 |
__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
|
3211 |
#ifdef OLD |
555 | 3212 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3213 |
__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
|
3214 |
#else |
555 | 3215 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3216 |
__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
|
3217 |
#endif |
555 | 3218 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3219 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
70 | 3220 |
|
3221 |
arg = nil; |
|
3222 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3223 |
if (nchars |
|
3224 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3225 |
|| (buffer[0] >= 0x80))) { |
|
3226 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3227 |
keySymString = NULL; |
|
3228 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3229 |
#ifdef OLD |
150 | 3230 |
switch (keySym) { |
3231 |
case XK_Control_L: |
|
3232 |
case XK_Control_R: |
|
555 | 3233 |
__INST(ctrlDown) = upDown; |
150 | 3234 |
break; |
3235 |
case XK_Shift_L: |
|
3236 |
case XK_Shift_R: |
|
555 | 3237 |
__INST(shiftDown) = upDown; |
150 | 3238 |
break; |
3239 |
case XK_Meta_L: |
|
3240 |
case XK_Meta_R: |
|
555 | 3241 |
__INST(metaDown) = upDown; |
150 | 3242 |
break; |
3243 |
case XK_Alt_L: |
|
3244 |
case XK_Alt_R: |
|
555 | 3245 |
__INST(altDown) = upDown; |
150 | 3246 |
break; |
3247 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3248 |
#endif |
150 | 3249 |
|
70 | 3250 |
keySymString = XKeysymToString(keySym); |
3251 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3252 |
#ifdef OLD |
70 | 3253 |
if (keySymString[0] == 'D') { |
3254 |
/* |
|
3255 |
* remove underscore, dont want it in symbols |
|
3256 |
*/ |
|
3257 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3258 |
keySymString = "DeleteLine"; |
|
3259 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3260 |
keySymString = "DeleteWord"; |
|
3261 |
} |
|
3262 |
} |
|
3263 |
/* |
|
3264 |
* make names compatible |
|
3265 |
*/ |
|
3266 |
if (strcmp(keySymString, "Down") == 0) { |
|
3267 |
keySymString = "CursorDown"; |
|
3268 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3269 |
keySymString = "CursorUp"; |
|
3270 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3271 |
keySymString = "CursorLeft"; |
|
3272 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3273 |
keySymString = "CursorRight"; |
|
3274 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3275 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3276 |
#else |
350 | 3277 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3278 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3279 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3280 |
#endif |
70 | 3281 |
} |
3282 |
} |
|
3283 |
||
3284 |
if (arg == nil) { |
|
3285 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3286 |
break; |
|
3287 |
} |
|
3288 |
||
115 | 3289 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3290 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3291 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3292 |
__MKSMALLINT(ke->y), |
115 | 3293 |
theView); |
70 | 3294 |
break; |
3295 |
||
3296 |
case ButtonPress: |
|
555 | 3297 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
3298 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3299 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3300 |
||
3301 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3302 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
70 | 3303 |
else |
3304 |
nextMultiClickTime = 0; |
|
3305 |
||
3306 |
if (multiClickTime) { |
|
3307 |
if (be->time < multiClickTime) { |
|
3308 |
multiClickTime = nextMultiClickTime; |
|
3309 |
ipS = &bmpS; |
|
3310 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3311 |
goto sendButtonEvent; |
|
3312 |
break; |
|
3313 |
} |
|
3314 |
} |
|
3315 |
multiClickTime = nextMultiClickTime; |
|
3316 |
if (be->state & ShiftMask) { |
|
3317 |
ipS = &bspS; |
|
3318 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3319 |
goto sendButtonEvent; |
|
3320 |
} |
|
3321 |
ipS = &bpS; |
|
3322 |
symS = @symbol(buttonPress:x:y:view:); |
|
3323 |
goto sendButtonEvent; |
|
200 | 3324 |
|
70 | 3325 |
/* NOT REACHED */ |
3326 |
||
3327 |
case ButtonRelease: |
|
555 | 3328 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
3329 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3330 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
70 | 3331 |
ipS = &brS; |
3332 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3333 |
/* fall into */ |
|
3334 |
||
3335 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3336 |
butt = __MKSMALLINT(be->button); |
12 | 3337 |
#ifdef NOTDEF |
70 | 3338 |
/* |
3339 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3340 |
*/ |
|
555 | 3341 |
if (__INST(metaDown) == true) |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3342 |
butt = __MKSMALLINT(2); |
70 | 3343 |
else |
0 | 3344 |
#endif |
555 | 3345 |
butt = __AT_(__INST(buttonTranslation), butt); |
200 | 3346 |
|
12 | 3347 |
|
115 | 3348 |
(*(*ipS).ilc_func)(self, |
3349 |
symS |
|
3350 |
COMMA_CON, nil, ipS, |
|
3351 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3352 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3353 |
__MKSMALLINT(ke->y), |
115 | 3354 |
theView); |
70 | 3355 |
break; |
3356 |
||
3357 |
case MotionNotify: |
|
555 | 3358 |
if (__INST(motionEventCompression) != false) { |
135 | 3359 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3360 |
} |
3361 |
||
555 | 3362 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
3363 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3364 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3365 |
#ifdef OLD |
555 | 3366 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3367 |
__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
|
3368 |
#else |
555 | 3369 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3370 |
__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
|
3371 |
#endif |
555 | 3372 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3373 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
150 | 3374 |
|
115 | 3375 |
(*motS.ilc_func)(self, |
3376 |
@symbol(buttonMotion:x:y:view:) |
|
3377 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3378 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3379 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3380 |
__MKSMALLINT(me->y), |
115 | 3381 |
theView); |
70 | 3382 |
break; |
3383 |
||
3384 |
case FocusIn: |
|
115 | 3385 |
(*focInS.ilc_func)(self, |
3386 |
@symbol(focusInView:) |
|
3387 |
COMMA_CON, nil, &focInS, |
|
3388 |
theView); |
|
70 | 3389 |
break; |
3390 |
||
3391 |
case FocusOut: |
|
115 | 3392 |
(*focOutS.ilc_func)(self, |
3393 |
@symbol(focusOutView:) |
|
3394 |
COMMA_CON, nil, &focOutS, |
|
3395 |
theView); |
|
70 | 3396 |
break; |
3397 |
||
3398 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3399 |
#ifdef OLD |
555 | 3400 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3401 |
__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
|
3402 |
#else |
555 | 3403 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3404 |
__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
|
3405 |
#endif |
555 | 3406 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3407 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
150 | 3408 |
|
115 | 3409 |
(*peS.ilc_func)(self, |
3410 |
@symbol(pointerEnter:x:y:view:) |
|
3411 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3412 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3413 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3414 |
__MKSMALLINT(ewe->y), |
115 | 3415 |
theView); |
70 | 3416 |
break; |
3417 |
||
3418 |
case LeaveNotify: |
|
115 | 3419 |
(*plS.ilc_func)(self, |
3420 |
@symbol(pointerLeave:view:) |
|
3421 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3422 |
__MKSMALLINT(lwe->state), |
115 | 3423 |
theView); |
70 | 3424 |
break; |
3425 |
||
3426 |
case GraphicsExpose: |
|
115 | 3427 |
(*gexpS.ilc_func)(self, |
3428 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3429 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3430 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3431 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3432 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3433 |
__MKSMALLINT(ee->height), |
115 | 3434 |
theView); |
3435 |
||
3436 |
if (ee->count != 0) { |
|
70 | 3437 |
break; |
3438 |
} |
|
115 | 3439 |
/* fall into */ |
3440 |
||
3441 |
case NoExpose: |
|
3442 |
(*nexpS.ilc_func)(self, |
|
3443 |
@symbol(noExposeView:) |
|
3444 |
COMMA_CON, nil, &nexpS, |
|
3445 |
theView); |
|
3446 |
break; |
|
3447 |
||
3448 |
case Expose: |
|
3449 |
(*expS.ilc_func)(self, |
|
3450 |
@symbol(exposeX:y:width:height:view:) |
|
3451 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3452 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3453 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3454 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3455 |
__MKSMALLINT(ee->height), |
115 | 3456 |
theView); |
70 | 3457 |
break; |
3458 |
||
3459 |
case ConfigureNotify: |
|
3460 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3461 |
siblingID = __MKOBJ(ce->above); |
70 | 3462 |
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
|
3463 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3464 |
} |
3465 |
||
115 | 3466 |
(*confS.ilc_func)(self, |
3467 |
@symbol(configureX:y:width:height:view:) |
|
3468 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3469 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3470 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3471 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3472 |
__MKSMALLINT(ce->height), |
115 | 3473 |
theView); |
70 | 3474 |
if (sibling != nil) { |
115 | 3475 |
(*coveredS.ilc_func)(self, |
3476 |
@symbol(coveredBy:view:) |
|
3477 |
COMMA_CON, nil, &coveredS, |
|
3478 |
theView, |
|
3479 |
sibling); |
|
70 | 3480 |
} |
3481 |
break; |
|
3482 |
||
3483 |
case ClientMessage: |
|
555 | 3484 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
3485 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3486 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
115 | 3487 |
(*termS.ilc_func)(self, |
3488 |
@symbol(terminateView:) |
|
3489 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3490 |
break; |
3491 |
} |
|
555 | 3492 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
115 | 3493 |
(*savtermS.ilc_func)(self, |
3494 |
@symbol(saveAndTerminateView:) |
|
3495 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3496 |
break; |
3497 |
} |
|
3498 |
} |
|
3499 |
break; |
|
3500 |
||
3501 |
case DestroyNotify: |
|
115 | 3502 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3503 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3504 |
break; |
3505 |
||
3506 |
case UnmapNotify: |
|
115 | 3507 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3508 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3509 |
break; |
3510 |
||
3511 |
case MapNotify: |
|
115 | 3512 |
(*mapS.ilc_func)(self, |
3513 |
@symbol(mappedView:) |
|
3514 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3515 |
break; |
3516 |
||
3517 |
case KeymapNotify: |
|
115 | 3518 |
(*keymap.ilc_func)(theView, |
3519 |
@symbol(keyMapChange) |
|
3520 |
COMMA_CON, nil, &keymap); |
|
70 | 3521 |
break; |
3522 |
||
3523 |
case VisibilityNotify: |
|
3524 |
switch (ve->state) { |
|
3525 |
case VisibilityUnobscured: |
|
3526 |
arg = @symbol(unobscured); |
|
3527 |
break; |
|
3528 |
case VisibilityPartiallyObscured: |
|
3529 |
arg = @symbol(partiallyObscured); |
|
3530 |
break; |
|
3531 |
case VisibilityFullyObscured: |
|
3532 |
arg = @symbol(fullyObscured); |
|
3533 |
break; |
|
3534 |
} |
|
3535 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3536 |
break; |
|
3537 |
||
3538 |
case CreateNotify: |
|
3539 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3540 |
break; |
|
3541 |
||
3542 |
case MapRequest: |
|
3543 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3544 |
break; |
|
3545 |
||
3546 |
case ReparentNotify: |
|
3547 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3548 |
break; |
|
3549 |
||
3550 |
case ConfigureRequest: |
|
3551 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3552 |
break; |
|
3553 |
||
3554 |
case GravityNotify: |
|
3555 |
case ResizeRequest: |
|
3556 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3557 |
break; |
|
3558 |
||
3559 |
case CirculateNotify: |
|
3560 |
case CirculateRequest: |
|
3561 |
break; |
|
3562 |
||
3563 |
case PropertyNotify: |
|
115 | 3564 |
(*prop.ilc_func)(theView, |
3565 |
@symbol(propertyChange) |
|
3566 |
COMMA_CON, nil, &prop); |
|
70 | 3567 |
break; |
3568 |
||
3569 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3570 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3571 |
(*selClear.ilc_func)(theView, |
129 | 3572 |
@symbol(selectionClear:) |
3573 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3574 |
selectionID); |
70 | 3575 |
break; |
3576 |
||
90 | 3577 |
case SelectionNotify: |
3578 |
/* |
|
3579 |
* returned selection value (answer from SelectionRequest) |
|
3580 |
*/ |
|
129 | 3581 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3582 |
ev->xselection.property, ev->xselection.target, |
3583 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3584 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3585 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3586 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3587 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3588 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3589 |
(*selNotify.ilc_func)(theView, |
3590 |
@symbol(selectionNotify:target:selection:from:) |
|
3591 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3592 |
propertyID, targetID, selectionID, requestorID); |
70 | 3593 |
break; |
3594 |
||
90 | 3595 |
case SelectionRequest: |
129 | 3596 |
/* |
3597 |
* someone wants the selection |
|
3598 |
*/ |
|
3599 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3600 |
ev->xselectionrequest.property, |
3601 |
ev->xselectionrequest.target, |
|
3602 |
ev->xselectionrequest.selection, |
|
3603 |
ev->xselectionrequest.requestor)); |
|
129 | 3604 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3605 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3606 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3607 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3608 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3609 |
(*selReq.ilc_func)(theView, |
3610 |
@symbol(selectionRequest:target:selection:from:) |
|
3611 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3612 |
propertyID, targetID, selectionID, requestorID); |
70 | 3613 |
break; |
3614 |
||
3615 |
case ColormapNotify: |
|
115 | 3616 |
(*colormap.ilc_func)(theView, |
3617 |
@symbol(colorMapChange) |
|
3618 |
COMMA_CON, nil, &colormap); |
|
70 | 3619 |
break; |
3620 |
||
3621 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3622 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3623 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3624 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3625 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3626 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3627 |
arg = @symbol(mappingKeyboard); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3628 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3629 |
case MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3630 |
arg = @symbol(mappingPointer); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3631 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3632 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3633 |
arg = nil; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3634 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3635 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3636 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3637 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3638 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3639 |
break; |
0 | 3640 |
} |
135 | 3641 |
#undef ae |
0 | 3642 |
#undef ee |
3643 |
#undef ke |
|
3644 |
#undef be |
|
3645 |
#undef ce |
|
3646 |
#undef me |
|
3647 |
#undef ewe |
|
3648 |
#undef lwe |
|
3649 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3650 |
#undef mape |
0 | 3651 |
%} |
3652 |
. |
|
3653 |
^ true |
|
3654 |
! |
|
3655 |
||
295 | 3656 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3657 |
"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
|
3658 |
(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
|
3659 |
This code is somewhat special, since X has a concept of graphic |
295 | 3660 |
expose events (which are sent after a bitblt). After such a bitblt, |
3661 |
we only handle exposes until the graphicsExpose arrives. |
|
3662 |
Other systems may not need such a kludge" |
|
3663 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3664 |
"interested in exposes only ?" |
295 | 3665 |
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
|
3666 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3667 |
self dispatchExposeEventFor:dispatchingExpose |
3668 |
]. |
|
3669 |
^ self |
|
3670 |
]. |
|
3671 |
||
3672 |
"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
|
3673 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3674 |
self dispatchEventFor:nil withMask:nil |
3675 |
] |
|
3676 |
! |
|
3677 |
||
81 | 3678 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3679 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3680 |
events matching the mask are thrown away regardless of which |
|
3681 |
view they are for. Otherwise, only matching events for that |
|
3682 |
view are flushed." |
|
0 | 3683 |
|
3684 |
%{ /* NOCONTEXT */ |
|
3685 |
||
3686 |
Display *dpy = myDpy; |
|
3687 |
XEvent ev; |
|
3688 |
Window win; |
|
3689 |
||
97 | 3690 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3691 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3692 |
win = _WindowVal(aWindowIdOrNil); |
555 | 3693 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
81 | 3694 |
} else { |
555 | 3695 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
81 | 3696 |
} |
70 | 3697 |
RETURN ( self ); |
0 | 3698 |
} |
3699 |
%} |
|
3700 |
. |
|
3701 |
self primitiveFailed |
|
3702 |
! |
|
3703 |
||
295 | 3704 |
eventMaskFor:anEventSymbol |
3705 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3706 |
||
3707 |
%{ /* NOCONTEXT */ |
|
3708 |
||
3709 |
int m = 0; |
|
3710 |
||
3711 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3712 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3713 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3714 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3715 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3716 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3717 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3718 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3719 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3720 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3721 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3722 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3723 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3724 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3725 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3726 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3727 |
RETURN (__MKSMALLINT(m)); |
295 | 3728 |
%} |
3729 |
! |
|
3730 |
||
12 | 3731 |
eventPending |
310 | 3732 |
"return true, if any event is pending. |
3733 |
This looks for both the internal queue and the display connection." |
|
12 | 3734 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3735 |
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
|
3736 |
|
12 | 3737 |
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
|
3738 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3739 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3740 |
^ self eventPendingWithSync:false |
0 | 3741 |
! |
3742 |
||
295 | 3743 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3744 |
"return true, if a specific event is pending" |
|
3745 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3746 |
^ 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
|
3747 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3748 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3749 |
eventPendingWithSync:doSync |
7 | 3750 |
"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
|
3751 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3752 |
before checking." |
0 | 3753 |
|
12 | 3754 |
%{ /* UNLIMITEDSTACK */ |
0 | 3755 |
|
3756 |
Display *dpy = myDpy; |
|
3757 |
||
150 | 3758 |
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
|
3759 |
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
|
3760 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3761 |
} |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3762 |
if (XPending(dpy)) { |
150 | 3763 |
RETURN (true); |
3764 |
} |
|
3765 |
} |
|
3766 |
RETURN ( false ); |
|
0 | 3767 |
%} |
3768 |
! |
|
3769 |
||
341 | 3770 |
eventQueued |
3771 |
"return true, if any event is queued" |
|
3772 |
||
3773 |
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
|
3774 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3775 |
]. |
3776 |
^ self eventQueuedAlready |
|
3777 |
||
3778 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3779 |
! |
|
3780 |
||
3781 |
eventQueuedAlready |
|
3782 |
"return true, if any event is queued internally. |
|
3783 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3784 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3785 |
the display connection)." |
|
3786 |
||
3787 |
%{ /* UNLIMITEDSTACK */ |
|
3788 |
||
3789 |
if (ISCONNECTED) { |
|
3790 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3791 |
RETURN (true); |
|
3792 |
} |
|
3793 |
} |
|
3794 |
RETURN ( false ); |
|
3795 |
%} |
|
3796 |
! |
|
3797 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3798 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3799 |
"return true, if any of the masked events is pending" |
3800 |
||
3801 |
%{ /* UNLIMITEDSTACK */ |
|
3802 |
||
3803 |
Display *dpy = myDpy; |
|
3804 |
XEvent ev; |
|
3805 |
Window win; |
|
3806 |
int thereIsOne; |
|
3807 |
||
3808 |
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
|
3809 |
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
|
3810 |
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
|
3811 |
} |
295 | 3812 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3813 |
win = _WindowVal(aWindowIdOrNil); |
|
555 | 3814 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
295 | 3815 |
} else { |
555 | 3816 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
295 | 3817 |
} |
3818 |
if (thereIsOne) { |
|
3819 |
XPutBackEvent(dpy, &ev); |
|
3820 |
RETURN ( true ); |
|
3821 |
} |
|
3822 |
} |
|
3823 |
RETURN ( false ); |
|
3824 |
%} |
|
3825 |
! |
|
3826 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3827 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3828 |
"return true, if any expose event is pending for a specific view, |
3829 |
or any view (if the arg is nil). |
|
3830 |
This is an X specific, only required after a scroll operation." |
|
7 | 3831 |
|
12 | 3832 |
%{ /* UNLIMITEDSTACK */ |
7 | 3833 |
|
3834 |
Display *dpy = myDpy; |
|
3835 |
XEvent ev; |
|
3836 |
Window win; |
|
81 | 3837 |
int thereIsOne; |
3838 |
||
150 | 3839 |
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
|
3840 |
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
|
3841 |
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
|
3842 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3843 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3844 |
win = _WindowVal(aWindowIdOrNil); |
3845 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3846 |
} else { |
|
3847 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3848 |
} |
|
3849 |
if (thereIsOne) { |
|
3850 |
XPutBackEvent(dpy, &ev); |
|
3851 |
RETURN ( true ); |
|
3852 |
} |
|
81 | 3853 |
} |
3854 |
RETURN ( false ); |
|
3855 |
%} |
|
3856 |
! |
|
3857 |
||
295 | 3858 |
getEventFor:aViewIdOrNil withMask:eventMask |
3859 |
"read next event - put into local eventBuffer. |
|
3860 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3861 |
otherwise only events for that specific view will be fetched. |
|
3862 |
Returns true, if there was an event, false otherwise. |
|
3863 |
This method may block - so you better check for pending events |
|
3864 |
before calling for it. |
|
3865 |
||
3866 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3867 |
handle method to allow unlimitedstack here. |
|
3868 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3869 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3870 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3871 |
display connections. |
|
3872 |
" |
|
81 | 3873 |
|
3874 |
%{ /* UNLIMITEDSTACK */ |
|
3875 |
||
3876 |
Display *dpy = myDpy; |
|
295 | 3877 |
Window win, wWanted; |
3878 |
int evMask; |
|
3879 |
OBJ eB; |
|
3880 |
XEvent *ev; |
|
3881 |
||
3882 |
if (! ISCONNECTED) { |
|
3883 |
RETURN (false); |
|
3884 |
} |
|
3885 |
||
555 | 3886 |
eB = __INST(eventBuffer); |
295 | 3887 |
if (__isByteArray(eB)) { |
555 | 3888 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 3889 |
} else { |
3890 |
printf("DISPLAY: no eventBuffer\n"); |
|
3891 |
RETURN (false); |
|
3892 |
} |
|
3893 |
ev->type = 0; |
|
3894 |
||
3895 |
if (__isSmallInteger(eventMask)) { |
|
555 | 3896 |
evMask = __intVal(eventMask); |
295 | 3897 |
} else { |
3898 |
evMask = ~0; |
|
3899 |
} |
|
3900 |
||
3901 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
3902 |
wWanted = _WindowVal(aViewIdOrNil); |
|
3903 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 3904 |
RETURN ( true ); |
3905 |
} |
|
295 | 3906 |
} else { |
3907 |
if (evMask == ~0) { |
|
3908 |
XNextEvent(dpy, ev); |
|
3909 |
RETURN (true); |
|
3910 |
} |
|
3911 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
3912 |
RETURN (true); |
|
3913 |
} |
|
3914 |
} |
|
3915 |
%}. |
|
3916 |
^ false |
|
3917 |
! |
|
3918 |
||
3919 |
handleAllEvents |
|
3920 |
"from now on, handle any kind of event" |
|
3921 |
||
3922 |
dispatchingExpose := nil |
|
3923 |
! |
|
3924 |
||
3925 |
handleExposeOnlyFor:aView |
|
3926 |
"from now on, handle expose events only" |
|
3927 |
||
3928 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3929 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3930 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3931 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3932 |
"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
|
3933 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3934 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3935 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3936 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3937 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3938 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3939 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3940 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3941 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 3942 |
! |
3943 |
||
3944 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3945 |
"tell X that we are only interested in events from aMask, which |
295 | 3946 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
3947 |
||
3948 |
%{ /* NOCONTEXT */ |
|
3949 |
||
3950 |
int mask; |
|
3951 |
||
3952 |
if (__isExternalAddress(aWindowId) |
|
3953 |
&& __isSmallInteger(aMask)) { |
|
555 | 3954 |
mask = __intVal(aMask); |
295 | 3955 |
|
3956 |
#ifdef OLD |
|
3957 |
/* these may not be disabled */ |
|
3958 |
mask |= ExposureMask | StructureNotifyMask | |
|
3959 |
KeyPressMask | KeyReleaseMask | |
|
3960 |
EnterWindowMask | LeaveWindowMask | |
|
3961 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
3962 |
#endif |
|
3963 |
||
3964 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
3965 |
RETURN ( self ); |
|
3966 |
} |
|
3967 |
%} |
|
3968 |
. |
|
3969 |
self primitiveFailed |
|
3970 |
! |
|
3971 |
||
3972 |
startDispatch |
|
3973 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
3974 |
||
3975 |
dispatching ifTrue:[^ self]. |
|
3976 |
dispatchingExpose := nil. |
|
3977 |
super startDispatch |
|
0 | 3978 |
! ! |
295 | 3979 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3980 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3981 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3982 |
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
|
3983 |
"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
|
3984 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3985 |
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
|
3986 |
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
|
3987 |
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
|
3988 |
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
|
3989 |
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
|
3990 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3991 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3992 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3993 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3994 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3995 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3996 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3997 |
if (__isSmallInteger(stateMask)) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3998 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3999 |
} else { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4000 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4001 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4002 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4003 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4004 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4005 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4006 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4007 |
XEvent ev; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4008 |
Window target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4009 |
Status result; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4010 |
KeySym keySym, *syms; |
555 | 4011 |
int screen = __intVal(__INST(screen)); |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4012 |
char s[2]; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4013 |
int nSyms; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4014 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4015 |
if ((typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4016 |
|| (typeSymbol == @symbol(keyRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4017 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4018 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4019 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4020 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4021 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4022 |
s[1] = '\0'; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4023 |
keySym = XStringToKeysym(s); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4024 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4025 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4026 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4027 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4028 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4029 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4030 |
if (stateMask == nil) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4031 |
/* |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4032 |
* get the modifier from the keySym |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4033 |
*/ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4034 |
nSyms = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4035 |
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
|
4036 |
if (syms) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4037 |
int i; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4038 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4039 |
for (i=0; i<nSyms; i++) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4040 |
if (syms[i] == keySym) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4041 |
#ifdef MODIFIERDEBUG |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4042 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4043 |
#endif |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4044 |
if (i) state = (1 << (i-1)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4045 |
break; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4046 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4047 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4048 |
XFree(syms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4049 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4050 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4051 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4052 |
if ((typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4053 |
|| (typeSymbol == @symbol(buttonRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4054 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4055 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4056 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4057 |
ev.xbutton.button = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4058 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4059 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4060 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4061 |
RETURN (false); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4062 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4063 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4064 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4065 |
if (typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4066 |
ev.xany.type = KeyPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4067 |
else if (typeSymbol == @symbol(keyRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4068 |
ev.xany.type = KeyRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4069 |
else if (typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4070 |
ev.xany.type = ButtonPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4071 |
else if (typeSymbol == @symbol(buttonRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4072 |
ev.xany.type = ButtonRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4073 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4074 |
if (__isExternalAddress(targetId)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4075 |
target = _WindowVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4076 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4077 |
target = (Window) __longIntVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4078 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4079 |
ev.xkey.window = target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4080 |
ev.xkey.same_screen = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4081 |
ev.xkey.subwindow = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4082 |
ev.xkey.root = RootWindow(myDpy, screen); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4083 |
ev.xkey.x = __intVal(xPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4084 |
ev.xkey.y = __intVal(yPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4085 |
ev.xkey.state = state; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4086 |
ev.xkey.time = CurrentTime; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4087 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4088 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4089 |
if ((result == BadValue) || (result == BadWindow)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4090 |
DPRINTF(("bad status\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4091 |
RETURN ( false ) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4092 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4093 |
RETURN (true) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4094 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4095 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4096 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4097 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4098 |
! |
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 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4101 |
"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
|
4102 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4103 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4104 |
Notice: not all alien views allow this kind of synthetic input; |
850 | 4105 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4106 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4107 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4108 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4109 |
aCharacterOrString isString ifTrue:[ |
850 | 4110 |
aCharacterOrString do:[:char | |
4111 |
self simulateKeyboardInput:char inViewId:viewId |
|
4112 |
]. |
|
4113 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4114 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4115 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4116 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4117 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4118 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4119 |
(aCharacterOrString == Character cr) ifTrue:[ |
850 | 4120 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4121 |
] ifFalse:[ |
850 | 4122 |
(aCharacterOrString == Character tab) ifTrue:[ |
4123 |
code := #Tab |
|
4124 |
] ifFalse:[ |
|
4125 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4126 |
code := #Escape |
|
4127 |
] |
|
4128 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4129 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4130 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4131 |
control ifTrue:[ |
850 | 4132 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4133 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4134 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4135 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4136 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4137 |
"/ (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
|
4138 |
"/ 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
|
4139 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4140 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4141 |
code isNumber ifTrue:[ |
850 | 4142 |
code >= $A asciiValue ifTrue:[ |
4143 |
code <= $Z asciiValue ifTrue:[ |
|
4144 |
state := self shiftMask |
|
4145 |
] |
|
4146 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4147 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4148 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4149 |
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
|
4150 |
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
|
4151 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4152 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4153 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4154 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4155 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4156 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4157 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4158 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4159 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4160 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4161 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4162 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4163 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4164 |
|
295 | 4165 |
!XWorkstation methodsFor:'font stuff'! |
4166 |
||
4167 |
ascentOf:aFontId |
|
4168 |
"the normal ascent" |
|
4169 |
||
4170 |
%{ /* NOCONTEXT */ |
|
4171 |
||
4172 |
XFontStruct *f; |
|
4173 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4174 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4175 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4176 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4177 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4178 |
RETURN ( __MKSMALLINT(f->ascent) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4179 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4180 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4181 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4182 |
%}. |
295 | 4183 |
self primitiveFailed. |
4184 |
^ nil |
|
4185 |
! |
|
4186 |
||
4187 |
createFontFor:aFontName |
|
4188 |
"a basic method for X-font allocation; this method allows |
|
4189 |
any font to be aquired (even those not conforming to |
|
4190 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4191 |
||
4192 |
%{ /* UNLIMITEDSTACK */ |
|
4193 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4194 |
||
4195 |
XFontStruct *newFont; |
|
4196 |
||
4197 |
if (ISCONNECTED) { |
|
4198 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4199 |
BEGIN_INTERRUPTSBLOCKED |
|
4200 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4201 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4202 |
if (newFont) |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4203 |
__cnt_font++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4204 |
#endif |
295 | 4205 |
END_INTERRUPTSBLOCKED |
4206 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4207 |
} |
|
4208 |
} |
|
4209 |
%}. |
|
4210 |
^ nil |
|
4211 |
! |
|
4212 |
||
4213 |
decomposeXFontName:aString into:aBlock |
|
4214 |
"extract family, face, style and size from an |
|
4215 |
X-font name |
|
4216 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4217 |
evaluate aBlock with these" |
|
4218 |
||
4219 |
|origin family face style moreStyle skip fheight size |
|
4220 |
resX resY x1 x2 coding start end | |
|
4221 |
||
4222 |
aString isNil ifTrue:[^ false]. |
|
4223 |
(aString startsWith:'-') ifFalse:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4224 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4225 |
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
|
4226 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4227 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4228 |
end := aString indexOf:$- startingAt:1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4229 |
family := aString copyFrom:1 to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4230 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4231 |
end := aString indexOf:$- startingAt:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4232 |
style := aString copyFrom:start to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4233 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4234 |
size := aString copyFrom:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4235 |
size := (Number readFromString:size onError:[^false]). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4236 |
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
|
4237 |
^ true. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4238 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4239 |
('*-[0-9]*' match:aString) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4240 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4241 |
something like lucidasans-24 |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4242 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4243 |
end := aString indexOf:$- startingAt:1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4244 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4245 |
family := aString copyFrom:1 to:(end - 1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4246 |
start := end + 1. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4247 |
size := aString copyFrom:start. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4248 |
size := (Number readFromString:size onError:[^false]). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4249 |
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
|
4250 |
^ true. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4251 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4252 |
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
|
4253 |
^ true. |
295 | 4254 |
]. |
4255 |
||
4256 |
end := aString indexOf:$- startingAt:2. |
|
4257 |
(end == 0) ifTrue:[^ false]. |
|
4258 |
origin := aString copyFrom:2 to:(end - 1). |
|
4259 |
||
4260 |
start := end + 1. |
|
4261 |
end := aString indexOf:$- startingAt:start. |
|
4262 |
(end == 0) ifTrue:[^ false]. |
|
4263 |
family := aString copyFrom:start to:(end - 1). |
|
4264 |
||
4265 |
start := end + 1. |
|
4266 |
end := aString indexOf:$- startingAt:start. |
|
4267 |
(end == 0) ifTrue:[^ false]. |
|
4268 |
face := aString copyFrom:start to:(end - 1). |
|
4269 |
||
4270 |
start := end + 1. |
|
4271 |
end := aString indexOf:$- startingAt:start. |
|
4272 |
(end == 0) ifTrue:[^ false]. |
|
4273 |
style := aString copyFrom:start to:(end - 1). |
|
4274 |
(style = 'o') ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4275 |
style := 'oblique' |
295 | 4276 |
] ifFalse:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4277 |
(style = 'i') ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4278 |
style := 'italic' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4279 |
] ifFalse:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4280 |
(style = 'r') ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4281 |
style := 'roman' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4282 |
] |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4283 |
] |
295 | 4284 |
]. |
4285 |
||
4286 |
start := end + 1. |
|
4287 |
end := aString indexOf:$- startingAt:start. |
|
4288 |
(end == 0) ifTrue:[^ false]. |
|
4289 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4290 |
||
4291 |
start := end + 1. |
|
4292 |
end := aString indexOf:$- startingAt:start. |
|
4293 |
(end == 0) ifTrue:[^ false]. |
|
4294 |
skip := aString copyFrom:start to:(end - 1). |
|
4295 |
||
4296 |
start := end + 1. |
|
4297 |
end := aString indexOf:$- startingAt:start. |
|
4298 |
(end == 0) ifTrue:[^ false]. |
|
4299 |
fheight := aString copyFrom:start to:(end - 1). |
|
4300 |
||
4301 |
start := end + 1. |
|
4302 |
end := aString indexOf:$- startingAt:start. |
|
4303 |
(end == 0) ifTrue:[^ false]. |
|
4304 |
size := aString copyFrom:start to:(end - 1). |
|
4305 |
size := (Number readFromString:size) / 10. |
|
4306 |
||
4307 |
start := end + 1. |
|
4308 |
end := aString indexOf:$- startingAt:start. |
|
4309 |
(end == 0) ifTrue:[^ false]. |
|
4310 |
resX := aString copyFrom:start to:(end - 1). |
|
4311 |
||
4312 |
start := end + 1. |
|
4313 |
end := aString indexOf:$- startingAt:start. |
|
4314 |
(end == 0) ifTrue:[^ false]. |
|
4315 |
resY := aString copyFrom:start to:(end - 1). |
|
4316 |
||
4317 |
start := end + 1. |
|
4318 |
end := aString indexOf:$- startingAt:start. |
|
4319 |
(end == 0) ifTrue:[^ false]. |
|
4320 |
x1 := aString copyFrom:start to:(end - 1). |
|
4321 |
||
4322 |
start := end + 1. |
|
4323 |
end := aString indexOf:$- startingAt:start. |
|
4324 |
(end == 0) ifTrue:[^ false]. |
|
4325 |
x2 := aString copyFrom:start to:(end - 1). |
|
4326 |
||
4327 |
start := end + 1. |
|
4328 |
end := aString indexOf:$- startingAt:start. |
|
4329 |
(end == 0) ifTrue:[^ false]. |
|
4330 |
coding := aString copyFrom:start to:(end - 1). |
|
4331 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4332 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4333 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4334 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4335 |
|
295 | 4336 |
aBlock value:family value:face value:style value:size value:coding. |
4337 |
^ true |
|
4338 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4339 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 4340 |
! |
4341 |
||
4342 |
descentOf:aFontId |
|
4343 |
"the normal descent" |
|
4344 |
||
4345 |
%{ /* NOCONTEXT */ |
|
4346 |
||
4347 |
XFontStruct *f; |
|
4348 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4349 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4350 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4351 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4352 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4353 |
RETURN ( __MKSMALLINT(f->descent) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4354 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4355 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4356 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4357 |
%}. |
295 | 4358 |
self primitiveFailed. |
4359 |
^ nil |
|
4360 |
! |
|
4361 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4362 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4363 |
"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
|
4364 |
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
|
4365 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4366 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4367 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4368 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4369 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4370 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4371 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4372 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4373 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4374 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4375 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4376 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4377 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4378 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4379 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4380 |
if (ISCONNECTED) { |
850 | 4381 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4382 |
|
850 | 4383 |
f = _FontVal(aFontId); |
4384 |
if (f) { |
|
4385 |
n = f->n_properties; |
|
4386 |
prop = f->properties; |
|
4387 |
if (prop) { |
|
4388 |
while (n--) { |
|
4389 |
cp = XGetAtomName(myDpy, prop->name); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4390 |
#ifdef SUPERDEBUG |
850 | 4391 |
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
|
4392 |
#endif |
850 | 4393 |
if (prop->name == XA_FULL_NAME) { |
4394 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4395 |
if (cp) { |
|
4396 |
fullName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4397 |
#ifdef SUPERDEBUG |
850 | 4398 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4399 |
#endif |
850 | 4400 |
} |
4401 |
} |
|
4402 |
if (prop->name == fontAtom) { |
|
4403 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4404 |
if (cp) { |
|
4405 |
fontName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4406 |
#ifdef SUPERDEBUG |
850 | 4407 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4408 |
#endif |
850 | 4409 |
} |
4410 |
} |
|
4411 |
if (prop->name == encodingAtom) { |
|
4412 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4413 |
if (cp) { |
|
4414 |
encoding = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4415 |
#ifdef SUPERDEBUG |
850 | 4416 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4417 |
#endif |
850 | 4418 |
} |
4419 |
} |
|
4420 |
if (prop->name == registryAtom) { |
|
4421 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4422 |
if (cp) { |
|
4423 |
registry = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4424 |
#ifdef SUPERDEBUG |
850 | 4425 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4426 |
#endif |
850 | 4427 |
} |
4428 |
} |
|
4429 |
if (prop->name == charSetCollAtom) { |
|
4430 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4431 |
if (cp) { |
|
4432 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4433 |
#ifdef SUPERDEBUG |
850 | 4434 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4435 |
#endif |
850 | 4436 |
} |
4437 |
} |
|
4438 |
prop++; |
|
4439 |
} |
|
4440 |
} |
|
4441 |
} |
|
4442 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4443 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4444 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4445 |
^ self |
850 | 4446 |
extractEncodingFromRegistry:registry |
4447 |
encoding:encoding |
|
4448 |
charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4449 |
! |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4450 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4451 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4452 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4453 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4454 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4455 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4456 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
850 | 4457 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4458 |
] ifFalse:[ |
850 | 4459 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4460 |
enc := encoding asLowercase asSymbol |
|
4461 |
] ifFalse:[ |
|
4462 |
charSets := charSetCollections. |
|
4463 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
4464 |
charSets := charSets asUppercase asCollectionOfWords. |
|
4465 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
4466 |
enc := #iso8859 |
|
4467 |
] ifFalse:[ |
|
4468 |
(charSets includes:'ISO8859') ifTrue:[ |
|
4469 |
enc := #iso8859 |
|
4470 |
] ifFalse:[ |
|
4471 |
(charSets includes:'ASCII') ifTrue:[ |
|
4472 |
enc := #ascii |
|
4473 |
] ifFalse:[ |
|
4474 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
4475 |
enc := #iso8859 |
|
4476 |
] |
|
4477 |
] |
|
4478 |
] |
|
4479 |
] |
|
4480 |
] |
|
4481 |
] |
|
440
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 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4484 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4485 |
"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
|
4486 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4487 |
! |
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 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4490 |
"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
|
4491 |
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
|
4492 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4493 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4494 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4495 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4496 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4497 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4498 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4499 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4500 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4501 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4502 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4503 |
|
991 | 4504 |
fontMetricsOf:fontId into:aBlock |
4505 |
"evaluate aBlock, passing a fonts metrics as arguments" |
|
4506 |
||
4507 |
|encoding avgAscent avgDescent |
|
4508 |
maxAscent maxDescent minWidth maxWidth avgWidth| |
|
4509 |
||
994 | 4510 |
%{ |
991 | 4511 |
XFontStruct *f; |
4512 |
int len; |
|
4513 |
||
4514 |
if (ISCONNECTED) { |
|
994 | 4515 |
if (__isExternalAddress(fontId)) { |
4516 |
f = _FontVal(fontId); |
|
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4517 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4518 |
avgAscent = __MKSMALLINT(f->ascent); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4519 |
avgDescent = __MKSMALLINT(f->descent); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4520 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4521 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4522 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4523 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4524 |
BEGIN_INTERRUPTSBLOCKED |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4525 |
len = XTextWidth(f, " ", 1); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4526 |
END_INTERRUPTSBLOCKED |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4527 |
avgWidth = __MKSMALLINT( len ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4528 |
} |
991 | 4529 |
} |
4530 |
} |
|
4531 |
%}. |
|
4532 |
encoding := self encodingOf:fontId. |
|
4533 |
aBlock value:encoding |
|
4534 |
value:avgAscent |
|
4535 |
value:avgDescent |
|
4536 |
value:maxAscent |
|
4537 |
value:maxDescent |
|
4538 |
value:minWidth |
|
4539 |
value:maxWidth |
|
4540 |
value:avgWidth |
|
4541 |
! |
|
4542 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4543 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4544 |
"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
|
4545 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4546 |
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
|
4547 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4548 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4549 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4550 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4551 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4552 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4553 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4554 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4555 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4556 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4557 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4558 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4559 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4560 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4561 |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4562 |
f = _FontVal(aFontId); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4563 |
if (f) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4564 |
n = f->n_properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4565 |
prop = f->properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4566 |
if (prop) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4567 |
while (n--) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4568 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4569 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4570 |
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
|
4571 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4572 |
if (prop->name == XA_FULL_NAME) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4573 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4574 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4575 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4576 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4577 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4578 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4579 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4580 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4581 |
if (prop->name == fontAtom) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4582 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4583 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4584 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4585 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4586 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4587 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4588 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4589 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4590 |
prop++; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4591 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4592 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4593 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4594 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4595 |
} |
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 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4598 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4599 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4600 |
^ fontName |
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 |
|
295 | 4603 |
getAvailableFontsMatching:pattern |
4604 |
"return an Array filled with font names matching aPattern" |
|
4605 |
||
4606 |
%{ /* UNLIMITEDSTACK */ |
|
4607 |
||
4608 |
int nnames = 1500; |
|
4609 |
int available = nnames + 1; |
|
4610 |
char **fonts; |
|
4611 |
OBJ arr, str; |
|
4612 |
int i; |
|
4613 |
||
4614 |
if (ISCONNECTED) { |
|
4615 |
if (__isString(pattern)) { |
|
4616 |
for (;;) { |
|
4617 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4618 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4619 |
XFreeFontNames(fonts); |
|
4620 |
nnames = available * 2; |
|
4621 |
} |
|
4622 |
if (fonts == NULL) { |
|
4623 |
RETURN ( nil ); |
|
4624 |
} |
|
4625 |
/* |
|
4626 |
* now, that we know the number of font names, |
|
4627 |
* create the array ... |
|
4628 |
*/ |
|
4629 |
arr = __ARRAY_NEW_INT(available); |
|
4630 |
if (! arr) { |
|
4631 |
RETURN (nil); |
|
4632 |
} |
|
4633 |
/* |
|
4634 |
* ... and fill it |
|
4635 |
*/ |
|
4636 |
for (i=0; i<available; i++) { |
|
350 | 4637 |
__PROTECT__(arr); |
295 | 4638 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4639 |
__UNPROTECT__(arr); |
295 | 4640 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4641 |
} |
|
4642 |
RETURN (arr); |
|
4643 |
} |
|
4644 |
} |
|
4645 |
%}. |
|
4646 |
^ nil |
|
4647 |
! |
|
4648 |
||
4649 |
getDefaultFont |
|
4650 |
"return a default font id - used when class Font cannot |
|
4651 |
find anything usable" |
|
4652 |
||
4653 |
^ self createFontFor:'fixed' |
|
4654 |
! |
|
4655 |
||
4656 |
getFontWithFamily:familyString face:faceString |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4657 |
style:styleArgString size:sizeArg encoding:encodingSym |
295 | 4658 |
|
4659 |
"try to get the specified font, if not available, try next smaller |
|
4660 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4661 |
as family and the other parameters as nil. For example, the cursor font |
|
4662 |
can be aquired that way." |
|
4663 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4664 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4665 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4666 |
styleString := styleArgString. |
295 | 4667 |
|
4668 |
"special: if face is nil, allow access to X-fonts" |
|
4669 |
faceString isNil ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4670 |
sizeArg notNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4671 |
theName := familyString , '-' , sizeArg printString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4672 |
] ifFalse:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4673 |
theName := familyString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4674 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4675 |
theName isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4676 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4677 |
mhmh - fall back to the default font |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4678 |
" |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4679 |
theName := 'fixed' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4680 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4681 |
theId := self createFontFor:theName. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4682 |
theId isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4683 |
theId := self getDefaultFont |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4684 |
]. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4685 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4686 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4687 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4688 |
"/ 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
|
4689 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4690 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4691 |
((styleString endsWith:'-narrow') |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4692 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4693 |
|i| |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4694 |
i := styleString lastIndexOf:$-. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4695 |
spacing := styleString copyFrom:(i+1). |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4696 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4697 |
] ifFalse:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4698 |
spacing := 'normal'. |
295 | 4699 |
]. |
4700 |
||
4701 |
xlatedStyle := styleString. |
|
4702 |
xlatedStyle notNil ifTrue:[ |
|
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4703 |
xlatedStyle := xlatedStyle first asString |
295 | 4704 |
]. |
4705 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4706 |
id := self |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4707 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4708 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4709 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4710 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4711 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4712 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4713 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4714 |
registry:encodingSym |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4715 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4716 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4717 |
id isNil ifTrue:[ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4718 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4719 |
"/ too stupid: encodings come in both cases |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4720 |
"/ and X does not ignore case |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4721 |
"/ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4722 |
id := self |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4723 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4724 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4725 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4726 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4727 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4728 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4729 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4730 |
registry:encodingSym asUppercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4731 |
encoding:'*'. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4732 |
id isNil ifTrue:[ |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4733 |
id := self |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4734 |
getFontWithFoundry:'*' |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4735 |
family:familyString asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4736 |
weight:faceString |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4737 |
slant:xlatedStyle |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4738 |
spacing:spacing |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4739 |
pixelSize:nil |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4740 |
size:sizeArg |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4741 |
registry:encodingSym asLowercase |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4742 |
encoding:'*'. |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4743 |
] |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
4744 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4745 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4746 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4747 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4748 |
"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
|
4749 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
295 | 4750 |
! |
4751 |
||
4752 |
getFontWithFoundry:foundry family:family weight:weight |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4753 |
slant:slant spacing:spc pixelSize:pSize size:size |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4754 |
registry:registry encoding:encoding |
295 | 4755 |
|
4756 |
"get the specified font, if not available, return nil. |
|
4757 |
This is the new font creation method - all others will be changed to |
|
4758 |
use this entry. |
|
4759 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4760 |
||
4761 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4762 |
family: 'helvetica' 'courier' 'times' ... |
|
4763 |
weight: 'bold' 'medium' 'demi' ... |
|
4764 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4765 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4766 |
pixelSize: 16,18 ... usually left empty |
|
4767 |
size: size in point (1/72th of an inch) |
|
4768 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4769 |
encoding: vendor specific encoding (usually '*') |
295 | 4770 |
" |
4771 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4772 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4773 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4774 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4775 |
id| |
295 | 4776 |
|
4777 |
"this works only on 'Release >= 3' - X-servers" |
|
4778 |
"name is: |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4779 |
-foundry-family -weight -slant- |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4780 |
sony helvetica bold r |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4781 |
adobe courier medium i |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4782 |
msic fixed o |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4783 |
... ... |
295 | 4784 |
" |
4785 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4786 |
size isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4787 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4788 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4789 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4790 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4791 |
foundry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4792 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4793 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4794 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4795 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4796 |
family isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4797 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4798 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4799 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4800 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4801 |
weight isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4802 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4803 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4804 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4805 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4806 |
slant isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4807 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4808 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4809 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4810 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4811 |
spc isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4812 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4813 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4814 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4815 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4816 |
pSize isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4817 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4818 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4819 |
pSizeMatch := pSize printString |
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 |
registry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4822 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4823 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4824 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4825 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4826 |
encoding isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4827 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4828 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4829 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4830 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4831 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4832 |
theName := ('-' , foundryMatch, |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4833 |
'-' , familyMatch, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4834 |
'-' , weightMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4835 |
'-' , slantMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4836 |
'-' , spcMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4837 |
'-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4838 |
'-' , pSizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4839 |
'-' , sizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4840 |
'-*-*-*-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4841 |
'-' , registryMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4842 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4843 |
|
697 | 4844 |
"/ Transcript showCR:theName; endEntry. |
295 | 4845 |
|
4846 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4847 |
|
295 | 4848 |
|
4849 |
" |
|
4850 |
Display getFontWithFoundry:'*' |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4851 |
family:'courier' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4852 |
weight:'medium' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4853 |
slant:'r' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4854 |
spacing:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4855 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4856 |
size:13 |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4857 |
registry:'iso8859' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4858 |
encoding:'*' |
295 | 4859 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4860 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4861 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4862 |
! |
4863 |
||
4864 |
listOfAvailableFonts |
|
4865 |
"return a list with all available fonts on this display. |
|
4866 |
Since this takes a long time, keep the result of the query for the |
|
4867 |
next time. The elements of the returned collection are instances of |
|
4868 |
FontDescription." |
|
4869 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4870 |
|"stream aName fntDescr" names| |
295 | 4871 |
|
4872 |
listOfXFonts isNil ifTrue:[ |
|
4873 |
"/ |
|
4874 |
"/ old code; using a pipe to xlsfonts |
|
4875 |
"/ |
|
4876 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4877 |
"/ stream isNil ifTrue:[^ nil]. |
|
4878 |
"/ listOfXFonts := OrderedCollection new. |
|
4879 |
"/ [stream atEnd] whileFalse:[ |
|
4880 |
"/ aName := stream nextLine. |
|
4881 |
"/ aName notNil ifTrue:[ |
|
4882 |
"/ self decomposeXFontName:aName into: |
|
4883 |
"/ [:family :face :style :size :coding | |
|
4884 |
"/ family notNil ifTrue:[ |
|
4885 |
"/ fntDescr := FontDescription |
|
4886 |
"/ family:family |
|
4887 |
"/ face:face |
|
4888 |
"/ style:style |
|
4889 |
"/ size:size |
|
4890 |
"/ encoding:coding. |
|
4891 |
"/ listOfXFonts add:fntDescr |
|
4892 |
"/ ] |
|
4893 |
"/ ] |
|
4894 |
"/ ] |
|
4895 |
"/ ]. |
|
4896 |
"/ stream close. |
|
4897 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4898 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4899 |
"/ listOfXFonts := nil |
|
4900 |
"/ ] ifFalse:[ |
|
4901 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4902 |
"/ ]. |
|
4903 |
||
850 | 4904 |
"/ |
4905 |
"/ new code: |
|
4906 |
"/ use new primitive to get font names; |
|
4907 |
"/ this is much faster, and also works on systems where |
|
4908 |
"/ a) xlsfonts is broken (sco) |
|
4909 |
"/ b) xlsfonts is not available (aix) |
|
4910 |
"/ |
|
4911 |
names := self getAvailableFontsMatching:'*'. |
|
4912 |
names isNil ifTrue:[ |
|
4913 |
"no names returned ..." |
|
4914 |
^ nil |
|
4915 |
]. |
|
4916 |
listOfXFonts := names collect:[:aName | |
|
4917 |
|fntDescr| |
|
4918 |
||
4919 |
(self decomposeXFontName:aName into: |
|
4920 |
[:family :face :style :size :coding | |
|
4921 |
family notNil ifTrue:[ |
|
4922 |
fntDescr := FontDescription |
|
4923 |
family:family |
|
4924 |
face:face |
|
4925 |
style:style |
|
4926 |
size:size |
|
4927 |
encoding:coding. |
|
4928 |
] ifFalse:[ |
|
4929 |
fntDescr := FontDescription |
|
4930 |
name:aName |
|
4931 |
] |
|
4932 |
] |
|
4933 |
) ifFalse:[ |
|
4934 |
fntDescr := FontDescription name:aName. |
|
4935 |
]. |
|
4936 |
fntDescr |
|
4937 |
]. |
|
295 | 4938 |
|
4939 |
]. |
|
4940 |
^ listOfXFonts |
|
4941 |
||
4942 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4943 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4944 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4945 |
Display getAvailableFontsMatching:'*'. |
295 | 4946 |
" |
4947 |
||
4948 |
"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
|
4949 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 4950 |
! |
4951 |
||
4952 |
maxAscentOf:aFontId |
|
4953 |
"the max ascent" |
|
4954 |
||
4955 |
%{ /* NOCONTEXT */ |
|
4956 |
||
4957 |
XFontStruct *f; |
|
4958 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4959 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4960 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4961 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4962 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4963 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4964 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4965 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4966 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4967 |
%}. |
295 | 4968 |
self primitiveFailed. |
4969 |
^ nil |
|
4970 |
! |
|
4971 |
||
4972 |
maxDescentOf:aFontId |
|
4973 |
"the max descent" |
|
4974 |
||
4975 |
%{ /* NOCONTEXT */ |
|
4976 |
||
4977 |
XFontStruct *f; |
|
4978 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4979 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4980 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4981 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4982 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4983 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
4984 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4985 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4986 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4987 |
%}. |
295 | 4988 |
self primitiveFailed. |
4989 |
^ nil |
|
4990 |
! |
|
4991 |
||
4992 |
maxWidthOfFont:aFontId |
|
4993 |
"the width of the widest character" |
|
4994 |
||
4995 |
%{ /* NOCONTEXT */ |
|
4996 |
||
4997 |
XFontStruct *f; |
|
4998 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4999 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5000 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5001 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5002 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5003 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5004 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5005 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5006 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5007 |
%}. |
295 | 5008 |
self primitiveFailed. |
5009 |
^ nil |
|
5010 |
! |
|
5011 |
||
5012 |
minWidthOfFont:aFontId |
|
5013 |
||
5014 |
%{ /* NOCONTEXT */ |
|
5015 |
||
5016 |
XFontStruct *f; |
|
5017 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5018 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5019 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5020 |
f = _FontVal(aFontId); |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5021 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5022 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5023 |
} |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5024 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5025 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5026 |
%}. |
295 | 5027 |
self primitiveFailed. |
5028 |
^ nil |
|
5029 |
! |
|
5030 |
||
5031 |
releaseFont:aFontId |
|
5032 |
||
5033 |
%{ /* NOCONTEXT */ |
|
5034 |
||
5035 |
XFontStruct *f; |
|
5036 |
||
5037 |
if (ISCONNECTED) { |
|
5038 |
if (__isExternalAddress(aFontId)) { |
|
5039 |
f = _FontVal(aFontId); |
|
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5040 |
if (f) { |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5041 |
BEGIN_INTERRUPTSBLOCKED |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5042 |
XFreeFont(myDpy, f); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5043 |
#ifdef COUNT_RESOURCES |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5044 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5045 |
#endif |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5046 |
END_INTERRUPTSBLOCKED |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5047 |
RETURN ( self ); |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5048 |
} |
295 | 5049 |
} |
5050 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5051 |
%}. |
295 | 5052 |
self primitiveFailed |
5053 |
! |
|
5054 |
||
466 | 5055 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5056 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5057 |
on this display. |
|
5058 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5059 |
||
5060 |
|sizes| |
|
5061 |
||
466 | 5062 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5063 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5064 |
"special: in X11R5 and above, size 0 means: |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5065 |
there are scaled versions in all sizes available" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5066 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5067 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
295 | 5068 |
]. |
5069 |
^ sizes |
|
5070 |
||
5071 |
" |
|
5072 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5073 |
" |
|
466 | 5074 |
|
5075 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5076 |
! |
5077 |
||
5078 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
5079 |
||
5080 |
%{ /* NOCONTEXT */ |
|
5081 |
||
5082 |
XFontStruct *f; |
|
5083 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5084 |
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
|
5085 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5086 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5087 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5088 |
int nInstBytes; |
295 | 5089 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5090 |
if (ISCONNECTED) { |
850 | 5091 |
if (__bothSmallInteger(index1, index2) |
5092 |
&& __isExternalAddress(aFontId) |
|
5093 |
&& __isNonNilObject(aString)) { |
|
5094 |
f = _FontVal(aFontId); |
|
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5095 |
if (! f) goto fail; |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5096 |
|
850 | 5097 |
i1 = __intVal(index1) - 1; |
5098 |
cls = __qClass(aString); |
|
5099 |
||
5100 |
if (i1 >= 0) { |
|
5101 |
i2 = __intVal(index2) - 1; |
|
5102 |
if (i2 < i1) { |
|
5103 |
RETURN (self); |
|
5104 |
} |
|
5105 |
||
5106 |
cp = (char *) _stringVal(aString); |
|
5107 |
l = i2 - i1 + 1; |
|
5108 |
||
5109 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5110 |
n = _stringSize(aString); |
|
5111 |
if (i2 < n) { |
|
5112 |
cp += i1; |
|
5113 |
BEGIN_INTERRUPTSBLOCKED |
|
5114 |
len = XTextWidth(f, cp, l); |
|
5115 |
END_INTERRUPTSBLOCKED |
|
5116 |
RETURN ( __MKSMALLINT(len) ); |
|
5117 |
} |
|
5118 |
} |
|
5119 |
||
5120 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5121 |
cp += nInstBytes; |
|
5122 |
||
5123 |
if (__isBytes(aString)) { |
|
5124 |
n = __byteArraySize(aString) - nInstBytes; |
|
5125 |
if (i2 < n) { |
|
5126 |
cp += i1; |
|
5127 |
BEGIN_INTERRUPTSBLOCKED |
|
5128 |
len = XTextWidth(f, cp, l); |
|
5129 |
END_INTERRUPTSBLOCKED |
|
5130 |
RETURN ( __MKSMALLINT(len) ); |
|
5131 |
} |
|
5132 |
} |
|
5133 |
||
5134 |
/* TWOBYTESTRINGS */ |
|
5135 |
if (__isWords(aString)) { |
|
5136 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5137 |
||
5138 |
if (i2 < n) { |
|
5139 |
union { |
|
5140 |
char b[2]; |
|
5141 |
unsigned short s; |
|
5142 |
} u; |
|
5143 |
int i; |
|
5144 |
XChar2b *cp2 = (XChar2b *)0; |
|
5145 |
int mustFree = 0; |
|
5146 |
||
5147 |
cp += (i1 * 2); |
|
5148 |
if (l > 1000) l = 1000; |
|
5149 |
||
5150 |
/* |
|
5151 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5152 |
* X expects them MSB first |
|
5153 |
* convert as required |
|
5154 |
*/ |
|
5155 |
||
5156 |
u.s = 0x1234; |
|
5157 |
if (u.b[0] != 0x12) { |
|
5158 |
if (l <= NLOCALBUFFER) { |
|
5159 |
cp2 = xlatebuffer; |
|
5160 |
} else { |
|
5161 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5162 |
mustFree = 1; |
|
5163 |
} |
|
5164 |
for (i=0; i<l; i++) { |
|
5165 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5166 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5167 |
} |
|
5168 |
cp = (char *) cp2; |
|
5169 |
} |
|
5170 |
BEGIN_INTERRUPTSBLOCKED |
|
5171 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
5172 |
END_INTERRUPTSBLOCKED |
|
5173 |
||
5174 |
if (mustFree) { |
|
5175 |
free(cp2); |
|
5176 |
} |
|
5177 |
||
5178 |
RETURN ( __MKSMALLINT(len) ); |
|
5179 |
} |
|
5180 |
} |
|
5181 |
} |
|
5182 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5183 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5184 |
#undef NLOCALBUFFER |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5185 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5186 |
%}. |
295 | 5187 |
self primitiveFailed. |
5188 |
^ nil |
|
5189 |
! |
|
5190 |
||
5191 |
widthOf:aString inFont:aFontId |
|
5192 |
||
5193 |
%{ /* NOCONTEXT */ |
|
5194 |
||
5195 |
XFontStruct *f; |
|
5196 |
char *cp; |
|
5197 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5198 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5199 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5200 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5201 |
int nInstBytes; |
295 | 5202 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5203 |
if (ISCONNECTED) { |
850 | 5204 |
if (__isExternalAddress(aFontId) |
5205 |
&& __isNonNilObject(aString)) { |
|
5206 |
f = _FontVal(aFontId); |
|
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5207 |
if (! f) goto fail; |
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5208 |
|
850 | 5209 |
cls = __qClass(aString); |
5210 |
||
5211 |
cp = (char *)_stringVal(aString); |
|
5212 |
||
5213 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5214 |
n = _stringSize(aString); |
|
5215 |
BEGIN_INTERRUPTSBLOCKED |
|
5216 |
len = XTextWidth(f, cp, n); |
|
5217 |
END_INTERRUPTSBLOCKED |
|
5218 |
RETURN ( __MKSMALLINT(len) ); |
|
5219 |
} |
|
5220 |
||
5221 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5222 |
cp += nInstBytes; |
|
5223 |
||
5224 |
if (__isBytes(aString)) { |
|
5225 |
n = __byteArraySize(aString) - nInstBytes; |
|
5226 |
||
5227 |
BEGIN_INTERRUPTSBLOCKED |
|
5228 |
len = XTextWidth(f, cp, n); |
|
5229 |
END_INTERRUPTSBLOCKED |
|
5230 |
RETURN ( __MKSMALLINT(len) ); |
|
5231 |
} |
|
5232 |
||
5233 |
/* TWOBYTESTRINGS */ |
|
5234 |
if (__isWords(aString)) { |
|
5235 |
union { |
|
5236 |
char b[2]; |
|
5237 |
unsigned short s; |
|
5238 |
} u; |
|
5239 |
int i; |
|
5240 |
XChar2b *cp2; |
|
5241 |
int mustFree = 0; |
|
5242 |
||
5243 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5244 |
if (n > 1000) n = 1000; |
|
5245 |
||
5246 |
/* |
|
5247 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5248 |
* X expects them MSB first |
|
5249 |
* convert as required |
|
5250 |
*/ |
|
5251 |
||
5252 |
u.s = 0x1234; |
|
5253 |
if (u.b[0] != 0x12) { |
|
5254 |
if (n <= NLOCALBUFFER) { |
|
5255 |
cp2 = xlatebuffer; |
|
5256 |
} else { |
|
5257 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
5258 |
mustFree = 1; |
|
5259 |
} |
|
5260 |
||
5261 |
for (i=0; i<n; i++) { |
|
5262 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5263 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5264 |
} |
|
5265 |
cp = (char *) cp2; |
|
5266 |
} |
|
5267 |
||
5268 |
BEGIN_INTERRUPTSBLOCKED |
|
5269 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
5270 |
END_INTERRUPTSBLOCKED |
|
5271 |
||
5272 |
if (mustFree) { |
|
5273 |
free(cp2); |
|
5274 |
} |
|
5275 |
||
5276 |
RETURN ( __MKSMALLINT(len) ); |
|
5277 |
} |
|
5278 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5279 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5280 |
#undef NLOCALBUFFER |
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
5281 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5282 |
%}. |
295 | 5283 |
self primitiveFailed. |
5284 |
^ nil |
|
5285 |
! ! |
|
5286 |
||
5287 |
!XWorkstation methodsFor:'grabbing '! |
|
5288 |
||
5289 |
allowEvents:mode |
|
5290 |
%{ /* NOCONTEXT */ |
|
5291 |
||
5292 |
int _mode, ok = 1; |
|
5293 |
||
5294 |
if (mode == @symbol(asyncPointer)) |
|
5295 |
_mode = AsyncPointer; |
|
5296 |
else if (mode == @symbol(syncPointer)) |
|
5297 |
_mode = SyncPointer; |
|
5298 |
else if (mode == @symbol(asyncKeyboard)) |
|
5299 |
_mode = AsyncKeyboard; |
|
5300 |
else if (mode == @symbol(syncKeyboard)) |
|
5301 |
_mode = SyncKeyboard; |
|
5302 |
else if (mode == @symbol(syncBoth)) |
|
5303 |
_mode = SyncBoth; |
|
5304 |
else if (mode == @symbol(asyncBoth)) |
|
5305 |
_mode = AsyncBoth; |
|
5306 |
else if (mode == @symbol(replayPointer)) |
|
5307 |
_mode = ReplayPointer; |
|
5308 |
else if (mode == @symbol(replayKeyboard)) |
|
5309 |
_mode = ReplayKeyboard; |
|
5310 |
else |
|
5311 |
ok = 0; |
|
5312 |
||
5313 |
if (ok) { |
|
5314 |
BEGIN_INTERRUPTSBLOCKED |
|
5315 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5316 |
END_INTERRUPTSBLOCKED |
|
5317 |
RETURN (self); |
|
5318 |
} |
|
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5319 |
%}. |
295 | 5320 |
self primitiveFailed |
5321 |
! |
|
5322 |
||
5323 |
grabKeyboardIn:aWindowId |
|
5324 |
"grab the keyboard" |
|
5325 |
||
5326 |
%{ /* NOCONTEXT */ |
|
5327 |
int result, ok; |
|
5328 |
||
5329 |
if (__isExternalAddress(aWindowId)) { |
|
5330 |
BEGIN_INTERRUPTSBLOCKED |
|
5331 |
result = XGrabKeyboard(myDpy, |
|
5332 |
_WindowVal(aWindowId), |
|
5333 |
True /* False */, |
|
5334 |
GrabModeAsync, |
|
5335 |
GrabModeAsync, |
|
5336 |
CurrentTime); |
|
5337 |
END_INTERRUPTSBLOCKED |
|
5338 |
ok = 0; |
|
5339 |
switch(result) { |
|
5340 |
case AlreadyGrabbed: |
|
5341 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5342 |
break; |
|
5343 |
case GrabNotViewable: |
|
5344 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5345 |
break; |
|
5346 |
case GrabInvalidTime: |
|
5347 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5348 |
break; |
|
5349 |
case GrabFrozen: |
|
5350 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5351 |
break; |
|
5352 |
default: |
|
5353 |
ok = 1; |
|
5354 |
break; |
|
5355 |
} |
|
5356 |
if (! ok) { |
|
5357 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5358 |
RETURN (false); |
|
5359 |
} |
|
5360 |
||
5361 |
RETURN ( true ); |
|
5362 |
} |
|
5363 |
%} |
|
5364 |
. |
|
5365 |
self primitiveFailed |
|
5366 |
! |
|
5367 |
||
5368 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5369 |
"grap the pointer - return true if ok" |
|
5370 |
||
5371 |
%{ /* NOCONTEXT */ |
|
5372 |
||
5373 |
int result, ok; |
|
5374 |
Window confineWin; |
|
5375 |
Cursor curs; |
|
5376 |
int pointer_mode, keyboard_mode; |
|
5377 |
||
5378 |
if (__isExternalAddress(aWindowId)) { |
|
5379 |
if (__isExternalAddress(confineId)) |
|
5380 |
confineWin = _WindowVal(confineId); |
|
5381 |
else |
|
5382 |
confineWin = (Window) None; |
|
5383 |
||
5384 |
if (__isExternalAddress(aCursorId)) |
|
5385 |
curs = _CursorVal(aCursorId); |
|
5386 |
else |
|
5387 |
curs = (Cursor) None; |
|
5388 |
||
5389 |
if (pMode == @symbol(sync)) |
|
5390 |
pointer_mode = GrabModeSync; |
|
5391 |
else |
|
5392 |
pointer_mode = GrabModeAsync; |
|
5393 |
||
5394 |
if (kMode == @symbol(sync)) |
|
5395 |
keyboard_mode = GrabModeSync; |
|
5396 |
else |
|
5397 |
keyboard_mode = GrabModeAsync; |
|
5398 |
||
5399 |
BEGIN_INTERRUPTSBLOCKED |
|
5400 |
result = XGrabPointer(myDpy, |
|
5401 |
_WindowVal(aWindowId), |
|
5402 |
False, |
|
5403 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5404 |
pointer_mode, keyboard_mode, |
|
5405 |
confineWin, |
|
5406 |
curs, |
|
5407 |
CurrentTime); |
|
5408 |
END_INTERRUPTSBLOCKED |
|
5409 |
||
5410 |
ok = 0; |
|
5411 |
switch (result) { |
|
5412 |
case AlreadyGrabbed: |
|
5413 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5414 |
break; |
|
5415 |
case GrabNotViewable: |
|
5416 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5417 |
break; |
|
5418 |
case GrabInvalidTime: |
|
5419 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5420 |
break; |
|
5421 |
case GrabFrozen: |
|
5422 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5423 |
break; |
|
5424 |
default: |
|
5425 |
ok = 1; |
|
5426 |
break; |
|
5427 |
} |
|
5428 |
||
5429 |
if (! ok) { |
|
5430 |
XUngrabPointer(myDpy, CurrentTime); |
|
5431 |
RETURN (false); |
|
5432 |
} |
|
5433 |
RETURN ( true ); |
|
5434 |
} |
|
5435 |
%} |
|
5436 |
. |
|
5437 |
self primitiveFailed |
|
5438 |
! |
|
5439 |
||
5440 |
ungrabKeyboard |
|
5441 |
"release the keyboard" |
|
5442 |
||
5443 |
%{ /* NOCONTEXT */ |
|
5444 |
||
5445 |
if (ISCONNECTED) { |
|
5446 |
BEGIN_INTERRUPTSBLOCKED |
|
5447 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5448 |
XSync(myDpy, 0); |
|
5449 |
END_INTERRUPTSBLOCKED |
|
5450 |
} |
|
5451 |
%}. |
|
5452 |
activeKeyboardGrab := nil |
|
5453 |
! |
|
5454 |
||
5455 |
ungrabPointer |
|
5456 |
"release the pointer" |
|
5457 |
||
5458 |
%{ /* NOCONTEXT */ |
|
5459 |
||
5460 |
if (ISCONNECTED) { |
|
5461 |
BEGIN_INTERRUPTSBLOCKED |
|
5462 |
XUngrabPointer(myDpy, CurrentTime); |
|
5463 |
XSync(myDpy, 0); |
|
5464 |
END_INTERRUPTSBLOCKED |
|
5465 |
} |
|
5466 |
%}. |
|
5467 |
activePointerGrab := nil |
|
5468 |
! ! |
|
5469 |
||
5470 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5471 |
||
5472 |
noClipIn:aGCId |
|
5473 |
"disable clipping rectangle" |
|
5474 |
||
5475 |
%{ /* NOCONTEXT */ |
|
5476 |
||
5477 |
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
|
5478 |
GC gc; |
295 | 5479 |
|
5480 |
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
|
5481 |
gc = _GCVal(aGCId); |
295 | 5482 |
gcv.clip_mask = None; |
5483 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5484 |
RETURN ( self ); |
|
5485 |
} |
|
5486 |
%}. |
|
5487 |
self primitiveFailed |
|
5488 |
! |
|
5489 |
||
5490 |
setBackground:bgColorIndex in:aGCId |
|
5491 |
"set background color to be drawn with" |
|
5492 |
||
5493 |
%{ /* NOCONTEXT */ |
|
5494 |
||
5495 |
if (__isExternalAddress(aGCId) |
|
5496 |
&& __isSmallInteger(bgColorIndex)) { |
|
555 | 5497 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
295 | 5498 |
RETURN ( self ); |
5499 |
} |
|
5500 |
%}. |
|
5501 |
self primitiveFailed |
|
5502 |
! |
|
5503 |
||
5504 |
setBitmapMask:aBitmapId in:aGCId |
|
5505 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5506 |
||
5507 |
%{ /* NOCONTEXT */ |
|
5508 |
||
5509 |
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
|
5510 |
GC gc; |
295 | 5511 |
Pixmap bitmap; |
5512 |
||
5513 |
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
|
5514 |
gc = _GCVal(aGCId); |
295 | 5515 |
if (__isExternalAddress(aBitmapId)) { |
5516 |
bitmap = _PixmapVal(aBitmapId); |
|
5517 |
XSetStipple(dpy, gc, bitmap); |
|
5518 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5519 |
RETURN ( self ); |
|
5520 |
} |
|
5521 |
if (aBitmapId == nil) { |
|
5522 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5523 |
RETURN ( self ); |
|
5524 |
} |
|
5525 |
} |
|
5526 |
%}. |
|
5527 |
self primitiveFailed |
|
5528 |
! |
|
5529 |
||
5530 |
setClipByChildren:aBool in:aGCId |
|
5531 |
"enable/disable drawing into child views" |
|
5532 |
||
5533 |
%{ /* NOCONTEXT */ |
|
5534 |
||
5535 |
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
|
5536 |
GC gc; |
295 | 5537 |
|
5538 |
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
|
5539 |
gc = _GCVal(aGCId); |
295 | 5540 |
if (aBool == true) |
5541 |
gcv.subwindow_mode = ClipByChildren; |
|
5542 |
else |
|
5543 |
gcv.subwindow_mode = IncludeInferiors; |
|
5544 |
||
5545 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5546 |
RETURN ( self ); |
|
5547 |
} |
|
5548 |
%}. |
|
5549 |
self primitiveFailed |
|
5550 |
! |
|
5551 |
||
5552 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5553 |
"clip to a rectangle" |
|
5554 |
||
5555 |
%{ /* NOCONTEXT */ |
|
5556 |
||
5557 |
XRectangle r; |
|
5558 |
||
5559 |
if (__isExternalAddress(aGCId) |
|
5560 |
&& __bothSmallInteger(clipX, clipY) |
|
5561 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
555 | 5562 |
r.x = __intVal(clipX); |
5563 |
r.y = __intVal(clipY); |
|
5564 |
r.width = __intVal(clipWidth); |
|
5565 |
r.height = __intVal(clipHeight); |
|
295 | 5566 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
5567 |
RETURN ( self ); |
|
5568 |
} |
|
5569 |
%}. |
|
5570 |
self primitiveFailed |
|
5571 |
! |
|
5572 |
||
788 | 5573 |
setDashes:dashList dashOffset:offset in:aGCId |
5574 |
"set line attributes" |
|
5575 |
||
5576 |
%{ /* NOCONTEXT */ |
|
5577 |
||
5578 |
if (__isExternalAddress(aGCId) |
|
5579 |
&& __isSmallInteger(offset) |
|
5580 |
&& __isByteArray(dashList)) { |
|
850 | 5581 |
XSetDashes(myDpy, _GCVal(aGCId), |
5582 |
__intVal(offset), |
|
5583 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
5584 |
__byteArraySize(dashList)); |
|
5585 |
RETURN ( self ); |
|
788 | 5586 |
} |
5587 |
bad: ; |
|
5588 |
%}. |
|
5589 |
" |
|
5590 |
either aGCId is invalid, |
|
5591 |
and/or dashList is not a byteArray |
|
5592 |
and/or offset is not a smallInteger |
|
5593 |
" |
|
5594 |
self primitiveFailed |
|
5595 |
! |
|
5596 |
||
295 | 5597 |
setFont:aFontId in:aGCId |
5598 |
"set font to be drawn in" |
|
5599 |
||
5600 |
%{ /* NOCONTEXT */ |
|
5601 |
||
5602 |
XFontStruct *f; |
|
5603 |
||
5604 |
if (__isExternalAddress(aFontId) |
|
5605 |
&& __isExternalAddress(aGCId)) { |
|
5606 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5607 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5608 |
RETURN ( self ); |
|
5609 |
} |
|
5610 |
%}. |
|
5611 |
" |
|
5612 |
aGCId and/or aFontId are invalid |
|
5613 |
" |
|
5614 |
self primitiveFailed |
|
5615 |
! |
|
5616 |
||
5617 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5618 |
"set foreground and background colors to be drawn with" |
|
5619 |
||
5620 |
%{ /* NOCONTEXT */ |
|
5621 |
||
5622 |
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
|
5623 |
GC gc; |
295 | 5624 |
|
5625 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5626 |
&& __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
|
5627 |
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
|
5628 |
|
555 | 5629 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
5630 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
295 | 5631 |
RETURN ( self ); |
5632 |
} |
|
5633 |
%}. |
|
5634 |
self primitiveFailed |
|
5635 |
! |
|
5636 |
||
5637 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5638 |
"set foreground and background colors to be drawn with using mask or |
|
5639 |
solid (if aBitmapId is nil)" |
|
5640 |
||
5641 |
%{ /* NOCONTEXT */ |
|
5642 |
||
5643 |
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
|
5644 |
GC gc; |
295 | 5645 |
|
5646 |
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
|
5647 |
gc = _GCVal(aGCId); |
295 | 5648 |
if (__isSmallInteger(fgColor)) |
555 | 5649 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5650 |
if (__isSmallInteger(bgColor)) |
555 | 5651 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5652 |
|
5653 |
if (__isExternalAddress(aBitmapId)) { |
|
5654 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5655 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5656 |
RETURN ( self ); |
|
5657 |
} |
|
5658 |
if (aBitmapId == nil) { |
|
5659 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5660 |
RETURN ( self ); |
|
5661 |
} |
|
5662 |
} |
|
5663 |
%}. |
|
5664 |
self primitiveFailed |
|
5665 |
! |
|
5666 |
||
5667 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5668 |
"set foreground and background colors to be drawn with using mask or |
|
5669 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5670 |
||
5671 |
%{ /* NOCONTEXT */ |
|
5672 |
||
5673 |
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
|
5674 |
GC gc; |
295 | 5675 |
|
5676 |
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
|
5677 |
gc = _GCVal(aGCId); |
295 | 5678 |
if (__isSmallInteger(lw)) { |
555 | 5679 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
295 | 5680 |
LineSolid, CapNotLast, JoinMiter); |
5681 |
} |
|
5682 |
if (__isSmallInteger(fgColor)) |
|
555 | 5683 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5684 |
if (__isSmallInteger(bgColor)) |
555 | 5685 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5686 |
|
5687 |
if (__isExternalAddress(aBitmapId)) { |
|
5688 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5689 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5690 |
RETURN ( self ); |
|
5691 |
} |
|
5692 |
if (aBitmapId == nil) { |
|
5693 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5694 |
RETURN ( self ); |
|
5695 |
} |
|
5696 |
} |
|
5697 |
%}. |
|
5698 |
self primitiveFailed |
|
5699 |
! |
|
5700 |
||
5701 |
setForeground:fgColorIndex in:aGCId |
|
5702 |
"set foreground color to be drawn with" |
|
5703 |
||
5704 |
%{ /* NOCONTEXT */ |
|
5705 |
||
5706 |
if (__isExternalAddress(aGCId) |
|
5707 |
&& __isSmallInteger(fgColorIndex)) { |
|
555 | 5708 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
295 | 5709 |
RETURN ( self ); |
5710 |
} |
|
5711 |
%}. |
|
5712 |
self primitiveFailed |
|
5713 |
! |
|
5714 |
||
5715 |
setFunction:aFunctionSymbol in:aGCId |
|
5716 |
"set alu function to be drawn with" |
|
5717 |
||
5718 |
%{ /* NOCONTEXT */ |
|
5719 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5720 |
GC gc; |
295 | 5721 |
int fun = -1; |
5722 |
||
5723 |
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
|
5724 |
gc = _GCVal(aGCId); |
295 | 5725 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5726 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5727 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5728 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5729 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5730 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5731 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5732 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5733 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5734 |
if (fun != -1) { |
|
5735 |
XSetFunction(myDpy, gc, fun); |
|
5736 |
RETURN ( self ); |
|
5737 |
} |
|
5738 |
} |
|
5739 |
%}. |
|
5740 |
" |
|
5741 |
either aGCId is not an integer, or an invalid symbol |
|
5742 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5743 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5744 |
" |
|
5745 |
self primitiveFailed |
|
5746 |
! |
|
5747 |
||
5748 |
setGraphicsExposures:aBoolean in:aGCId |
|
5749 |
"set or clear the graphics exposures flag" |
|
5750 |
||
5751 |
%{ /* NOCONTEXT */ |
|
5752 |
||
5753 |
if (__isExternalAddress(aGCId)) { |
|
5754 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5755 |
RETURN ( self ); |
|
5756 |
} |
|
5757 |
%} |
|
5758 |
. |
|
5759 |
self primitiveFailed |
|
5760 |
! |
|
5761 |
||
5762 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5763 |
"set line attributes" |
|
5764 |
||
5765 |
%{ /* NOCONTEXT */ |
|
5766 |
||
5767 |
int x_style, x_cap, x_join; |
|
5768 |
||
5769 |
if (__isExternalAddress(aGCId) |
|
5770 |
&& __isSmallInteger(aNumber)) { |
|
5771 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5772 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5773 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5774 |
else goto bad; |
|
5775 |
||
5776 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5777 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5778 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5779 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5780 |
else goto bad; |
|
5781 |
||
5782 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5783 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5784 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5785 |
else goto bad; |
|
5786 |
||
5787 |
XSetLineAttributes(myDpy, |
|
555 | 5788 |
_GCVal(aGCId), __intVal(aNumber), |
295 | 5789 |
x_style, x_cap, x_join); |
5790 |
RETURN ( self ); |
|
5791 |
} |
|
5792 |
bad: ; |
|
5793 |
%}. |
|
5794 |
" |
|
5795 |
either aGCId is invalid, |
|
5796 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5797 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5798 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5799 |
" |
|
5800 |
self primitiveFailed |
|
5801 |
! |
|
5802 |
||
5803 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5804 |
"set the mask origin" |
|
5805 |
||
5806 |
%{ /* NOCONTEXT */ |
|
5807 |
||
5808 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
555 | 5809 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
295 | 5810 |
RETURN ( self ); |
5811 |
} |
|
5812 |
%}. |
|
5813 |
self primitiveFailed |
|
5814 |
! |
|
5815 |
||
5816 |
setPixmapMask:aPixmapId in:aGCId |
|
5817 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5818 |
||
5819 |
%{ /* NOCONTEXT */ |
|
5820 |
||
5821 |
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
|
5822 |
GC gc; |
295 | 5823 |
Pixmap pixmap; |
5824 |
||
5825 |
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
|
5826 |
gc = _GCVal(aGCId); |
295 | 5827 |
if (__isExternalAddress(aPixmapId)) { |
5828 |
pixmap = _PixmapVal(aPixmapId); |
|
5829 |
XSetTile(dpy, gc, pixmap); |
|
5830 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5831 |
RETURN ( self ); |
|
5832 |
} |
|
5833 |
if (aPixmapId == nil) { |
|
5834 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5835 |
RETURN ( self ); |
|
5836 |
} |
|
5837 |
} |
|
5838 |
%}. |
|
5839 |
self primitiveFailed |
|
5840 |
! ! |
|
5841 |
||
5842 |
!XWorkstation methodsFor:'initialize / release'! |
|
5843 |
||
5844 |
close |
|
5845 |
"close down the connection to the X-server" |
|
5846 |
||
5847 |
%{ /* NOCONTEXT */ |
|
5848 |
||
5849 |
if (ISCONNECTED) { |
|
5850 |
BEGIN_INTERRUPTSBLOCKED |
|
5851 |
XCloseDisplay(myDpy); |
|
555 | 5852 |
__INST(displayId) = nil; |
295 | 5853 |
END_INTERRUPTSBLOCKED |
5854 |
} |
|
5855 |
%} |
|
5856 |
! |
|
5857 |
||
5858 |
initializeDefaultValues |
|
5859 |
buttonTranslation := ButtonTranslation. |
|
5860 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5861 |
||
5862 |
self initializeModifierMappings |
|
5863 |
! |
|
5864 |
||
5865 |
initializeEventBuffer |
|
5866 |
|sz| |
|
5867 |
||
5868 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5869 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5870 |
%}. |
5871 |
eventBuffer isNil ifTrue:[ |
|
5872 |
eventBuffer := ByteArray new:sz. |
|
5873 |
]. |
|
5874 |
! |
|
5875 |
||
5876 |
initializeFor:aDisplayName |
|
5877 |
"initialize the receiver for a connection to an X-Server; |
|
5878 |
the argument, aDisplayName may be nil (for the default server from |
|
5879 |
DISPLAY-variable or command line argument) or the name of the server |
|
5880 |
as hostname:number" |
|
5881 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5882 |
|dpyName index arguments| |
295 | 5883 |
|
5884 |
dpyName := aDisplayName. |
|
5885 |
dpyName isNil ifTrue:[ |
|
5886 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5887 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5888 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5889 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5890 |
dpyName := arguments at:index+1 |
295 | 5891 |
] |
5892 |
] |
|
5893 |
]. |
|
5894 |
%{ |
|
5895 |
int scr; |
|
5896 |
Display *dpy; |
|
5897 |
Visual *visual; |
|
5898 |
XVisualInfo viproto; |
|
5899 |
XVisualInfo *vip; /* retured info */ |
|
5900 |
int maxRGBDepth; |
|
5901 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5902 |
int rgbVisualID; |
|
5903 |
int nvi, i; |
|
5904 |
int shapeEventBase, shapeErrorBase; |
|
5905 |
int shmEventBase, shmErrorBase; |
|
5906 |
int faxEventBase, faxErrorBase; |
|
5907 |
char *type, *nm; |
|
5908 |
int dummy; |
|
5909 |
OBJ dpyID; |
|
5910 |
||
555 | 5911 |
if (__INST(displayId) != nil) { |
295 | 5912 |
/* |
5913 |
* already connected - you bad guy try to |
|
5914 |
* trick me manually ? |
|
5915 |
*/ |
|
5916 |
RETURN ( self ); |
|
5917 |
} |
|
5918 |
||
5919 |
BEGIN_INTERRUPTSBLOCKED |
|
5920 |
||
5921 |
if (__isString(dpyName)) |
|
5922 |
nm = (char *)_stringVal(dpyName); |
|
5923 |
else { |
|
5924 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5925 |
nm = NULL; |
|
5926 |
} |
|
5927 |
dpy = XOpenDisplay(nm); |
|
5928 |
||
5929 |
if (dpy) { |
|
555 | 5930 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 5931 |
|
5932 |
#ifdef SUPERDEBUG |
|
5933 |
XSynchronize(dpy, 1); |
|
5934 |
#endif |
|
5935 |
||
5936 |
XSetErrorHandler(__XErrorHandler__); |
|
5937 |
} |
|
5938 |
||
5939 |
END_INTERRUPTSBLOCKED |
|
5940 |
%}. |
|
5941 |
displayId isNil ifTrue:[ |
|
5942 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
5943 |
^ nil |
|
5944 |
]. |
|
5945 |
||
5946 |
dispatching := false. |
|
5947 |
dispatchingExpose := false. |
|
5948 |
isSlow := false. |
|
5949 |
shiftDown := false. |
|
5950 |
ctrlDown := false. |
|
5951 |
metaDown := false. |
|
5952 |
altDown := false. |
|
5953 |
motionEventCompression := true. |
|
5954 |
buttonsPressed := 0. |
|
5955 |
displayName := dpyName. |
|
5956 |
||
5957 |
protocolsAtom := nil. |
|
5958 |
deleteWindowAtom := nil. |
|
5959 |
saveYourselfAtom := nil. |
|
5960 |
quitAppAtom := nil. |
|
5961 |
||
5962 |
self initializeScreenProperties. |
|
5963 |
||
5964 |
self initializeDefaultValues. |
|
5965 |
self initializeEventBuffer. |
|
5966 |
self initializeSpecialFlags. |
|
5967 |
self initializeKeyboardMap. |
|
5968 |
||
5969 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
5970 |
! |
|
5971 |
||
5972 |
initializeModifierMappings |
|
5973 |
|map mod| |
|
5974 |
||
5975 |
"/ altModifiers := #(Alt_L Alt_R). |
|
5976 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
5977 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
5978 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
5979 |
||
5980 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
5981 |
altModifierMask := metaModifierMask := nil. |
|
5982 |
||
5983 |
map := self modifierMapping. |
|
342 | 5984 |
map isNil ifTrue:[ |
5985 |
"/ |
|
5986 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
5987 |
"/ setup some reasonable default. If that is not sufficient, |
|
5988 |
"/ you have to change things from your display.rc file. |
|
5989 |
"/ |
|
5990 |
altModifierMask := self modifier1Mask. |
|
5991 |
metaModifierMask := self modifier2Mask. |
|
5992 |
||
5993 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
5994 |
ctrlModifiers := #(Control_L Control_R Control). |
|
5995 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
5996 |
altModifiers := #(Alt_R Alt). |
|
5997 |
] ifFalse:[ |
|
5998 |
altModifierMask := 0. |
|
374 | 5999 |
metaModifierMask := 0. |
6000 |
||
6001 |
mod := map at:1. |
|
6002 |
mod notNil ifTrue:[ |
|
342 | 6003 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 6004 |
]. |
6005 |
mod := map at:3. |
|
6006 |
mod notNil ifTrue:[ |
|
342 | 6007 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 6008 |
]. |
6009 |
mod := map at:4. |
|
6010 |
mod notNil ifTrue:[ |
|
342 | 6011 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
6012 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 6013 |
]. |
6014 |
mod := map at:5. |
|
6015 |
mod notNil ifTrue:[ |
|
342 | 6016 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
6017 |
altModifierMask := 1 bitShift:(5-1). |
|
6018 |
] |
|
295 | 6019 |
]. |
6020 |
||
6021 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6022 |
! |
|
6023 |
||
6024 |
initializeScreenProperties |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6025 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6026 |
|
295 | 6027 |
%{ /* NOCONTEXT */ |
6028 |
||
6029 |
Display *dpy = myDpy; |
|
6030 |
int scr; |
|
6031 |
Visual *visual; |
|
6032 |
XVisualInfo viproto; |
|
6033 |
XVisualInfo *vip; /* retured info */ |
|
6034 |
int maxRGBDepth; |
|
6035 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6036 |
int rgbVisualID; |
|
6037 |
int nvi, i; |
|
6038 |
int shapeEventBase, shapeErrorBase; |
|
6039 |
int shmEventBase, shmErrorBase; |
|
6040 |
int faxEventBase, faxErrorBase; |
|
6041 |
char *type, *nm; |
|
6042 |
int dummy; |
|
6043 |
int mask, shift, nBits; |
|
6044 |
||
6045 |
if (ISCONNECTED) { |
|
850 | 6046 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
6047 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6048 |
||
6049 |
BEGIN_INTERRUPTSBLOCKED |
|
6050 |
||
6051 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6052 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6053 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6054 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6055 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6056 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6057 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6058 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6059 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6060 |
|
6061 |
#ifdef SHAPE |
|
850 | 6062 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
6063 |
__INST(hasShapeExtension) = true; |
|
6064 |
else |
|
295 | 6065 |
#endif |
850 | 6066 |
__INST(hasShapeExtension) = false; |
295 | 6067 |
|
6068 |
#ifdef SHM |
|
850 | 6069 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
6070 |
__INST(hasShmExtension) = true; |
|
6071 |
else |
|
295 | 6072 |
#endif |
850 | 6073 |
__INST(hasShmExtension) = false; |
295 | 6074 |
|
6075 |
#ifdef DPS |
|
850 | 6076 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6077 |
__INST(hasDPSExtension) = true; |
|
6078 |
else |
|
295 | 6079 |
#endif |
850 | 6080 |
__INST(hasDPSExtension) = false; |
295 | 6081 |
|
6082 |
#ifdef XVIDEO |
|
850 | 6083 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6084 |
__INST(hasXVideoExtension) = true; |
|
6085 |
else |
|
295 | 6086 |
#endif |
850 | 6087 |
__INST(hasXVideoExtension) = false; |
295 | 6088 |
|
6089 |
#ifdef MBUF |
|
850 | 6090 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6091 |
__INST(hasMbufExtension) = true; |
|
6092 |
else |
|
295 | 6093 |
#endif |
850 | 6094 |
__INST(hasMbufExtension) = false; |
295 | 6095 |
|
6096 |
#ifdef PEX5 |
|
850 | 6097 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6098 |
__INST(hasPEXExtension) = true; |
|
6099 |
else |
|
295 | 6100 |
#endif |
850 | 6101 |
__INST(hasPEXExtension) = false; |
295 | 6102 |
|
6103 |
#ifdef XIE |
|
850 | 6104 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6105 |
__INST(hasImageExtension) = true; |
|
6106 |
else |
|
295 | 6107 |
#endif |
850 | 6108 |
__INST(hasImageExtension) = false; |
295 | 6109 |
|
6110 |
#ifdef XI |
|
850 | 6111 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6112 |
__INST(hasInputExtension) = true; |
|
6113 |
else |
|
295 | 6114 |
#endif |
850 | 6115 |
__INST(hasInputExtension) = false; |
6116 |
||
6117 |
/* |
|
6118 |
* look for RGB visual |
|
6119 |
*/ |
|
6120 |
nvi = 0; |
|
6121 |
viproto.screen = scr; |
|
6122 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6123 |
maxRGBDepth = 0; |
|
6124 |
for (i = 0; i < nvi; i++) { |
|
6125 |
switch (vip[i].class) { |
|
6126 |
case TrueColor: |
|
6127 |
if (vip[i].depth > maxRGBDepth) { |
|
6128 |
maxRGBDepth = vip[i].depth; |
|
6129 |
rgbRedMask = vip[i].red_mask; |
|
6130 |
rgbGreenMask = vip[i].green_mask; |
|
6131 |
rgbBlueMask = vip[i].blue_mask; |
|
6132 |
rgbVisualID = vip[i].visualid; |
|
6133 |
} |
|
6134 |
break; |
|
6135 |
} |
|
6136 |
} |
|
6137 |
if (vip) XFree ((char *) vip); |
|
6138 |
||
6139 |
if (maxRGBDepth) { |
|
6140 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6141 |
} |
|
6142 |
||
6143 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6144 |
__INST(monitorType) = @symbol(unknown); |
|
6145 |
__INST(hasColors) = true; |
|
6146 |
__INST(hasGreyscales) = true; |
|
6147 |
switch (visual->class) { |
|
6148 |
case StaticGray: |
|
6149 |
__INST(visualType) = @symbol(StaticGray); |
|
6150 |
__INST(hasColors) = false; |
|
6151 |
__INST(monitorType) = @symbol(monochrome); |
|
6152 |
break; |
|
6153 |
case GrayScale: |
|
6154 |
__INST(visualType) = @symbol(GrayScale); |
|
6155 |
__INST(hasColors) = false; |
|
6156 |
__INST(monitorType) = @symbol(monochrome); |
|
6157 |
break; |
|
6158 |
case StaticColor: |
|
6159 |
__INST(visualType) = @symbol(StaticColor); |
|
6160 |
break; |
|
6161 |
case PseudoColor: |
|
6162 |
__INST(visualType) = @symbol(PseudoColor); |
|
6163 |
break; |
|
6164 |
case TrueColor: |
|
6165 |
__INST(visualType) = @symbol(TrueColor); |
|
6166 |
break; |
|
6167 |
case DirectColor: |
|
6168 |
__INST(visualType) = @symbol(DirectColor); |
|
6169 |
break; |
|
6170 |
} |
|
6171 |
if (DisplayCells(dpy, scr) == 2) { |
|
6172 |
__INST(hasColors) = false; |
|
6173 |
__INST(hasGreyscales) = false; |
|
6174 |
__INST(monitorType) = @symbol(monochrome); |
|
6175 |
} |
|
6176 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
6177 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6178 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6179 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
6180 |
switch (visual->class) { |
|
6181 |
case TrueColor: |
|
6182 |
/* extract number of bits and shift counts */ |
|
6183 |
mask = visual->red_mask; |
|
6184 |
shift = 0; |
|
6185 |
while (mask && ((mask & 1) == 0)) { |
|
6186 |
mask >>= 1; |
|
6187 |
shift++; |
|
6188 |
} |
|
6189 |
__INST(redShift) = __MKSMALLINT(shift); |
|
6190 |
nBits = 0; |
|
6191 |
while (mask) { |
|
6192 |
mask >>= 1; |
|
6193 |
nBits++; |
|
6194 |
} |
|
6195 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
6196 |
||
6197 |
mask = visual->green_mask; |
|
6198 |
shift = 0; |
|
6199 |
while (mask && ((mask & 1) == 0)) { |
|
6200 |
mask >>= 1; |
|
6201 |
shift++; |
|
6202 |
} |
|
6203 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
6204 |
nBits = 0; |
|
6205 |
while (mask) { |
|
6206 |
mask >>= 1; |
|
6207 |
nBits++; |
|
6208 |
} |
|
6209 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
6210 |
||
6211 |
mask = visual->blue_mask; |
|
6212 |
shift = 0; |
|
6213 |
while (mask && ((mask & 1) == 0)) { |
|
6214 |
mask >>= 1; |
|
6215 |
shift++; |
|
6216 |
} |
|
6217 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
6218 |
nBits = 0; |
|
6219 |
while (mask) { |
|
6220 |
mask >>= 1; |
|
6221 |
nBits++; |
|
6222 |
} |
|
6223 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
6224 |
break; |
|
6225 |
} |
|
295 | 6226 |
|
6227 |
#ifndef XA_PRIMARY |
|
850 | 6228 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6229 |
#else |
850 | 6230 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6231 |
#endif |
6232 |
#ifndef XA_SECONDARY |
|
850 | 6233 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6234 |
#else |
850 | 6235 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6236 |
#endif |
6237 |
#ifndef XA_CUT_BUFFER0 |
|
850 | 6238 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6239 |
#else |
850 | 6240 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6241 |
#endif |
6242 |
#ifndef XA_STRING |
|
850 | 6243 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6244 |
#else |
850 | 6245 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6246 |
#endif |
6247 |
#ifndef XA_LENGTH |
|
850 | 6248 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6249 |
#else |
850 | 6250 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6251 |
#endif |
6252 |
||
850 | 6253 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6254 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6255 |
%}. |
295 | 6256 |
! |
6257 |
||
6258 |
initializeSpecialFlags |
|
6259 |
"perform additional special server implementation flags" |
|
6260 |
||
6261 |
"/ |
|
6262 |
"/ assume we have it ... (should check) |
|
6263 |
"/ |
|
6264 |
hasSaveUnder := true. |
|
6265 |
ignoreBackingStore := false. |
|
6266 |
||
6267 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
6268 |
"/ |
|
6269 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6270 |
"/ which does not correctly handle saveUnder |
|
6271 |
"/ |
|
6272 |
hasSaveUnder := false. |
|
6273 |
]. |
|
6274 |
! |
|
6275 |
||
6276 |
reinitialize |
|
6277 |
virtualRootId := rootId := nil. |
|
6278 |
super reinitialize. |
|
6279 |
dispatchingExpose := nil |
|
6280 |
! ! |
|
6281 |
||
6282 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6283 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6284 |
altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6285 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6286 |
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
|
6287 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6288 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6289 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6290 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6291 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6292 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6293 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6294 |
|
341 | 6295 |
altModifierMask:aSmallInteger |
6296 |
"define which key takes the role of an alt-key. |
|
6297 |
By default, this is X's modifier1, which is the ALT key on |
|
6298 |
most keyboards. However, there may be exceptions to this, |
|
6299 |
and the setting can be changed with: |
|
6300 |
Display altModifierMask:(Display modifier2Mask) |
|
6301 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
6302 |
" |
|
6303 |
||
6304 |
altModifierMask := aSmallInteger |
|
6305 |
! |
|
6306 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6307 |
metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6308 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6309 |
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
|
6310 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6311 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6312 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6313 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6314 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6315 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6316 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6317 |
|
341 | 6318 |
metaModifierMask:aSmallInteger |
6319 |
"define which key takes the role of a meta key. |
|
6320 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6321 |
most keyboards (if present at all). |
|
6322 |
However, there may be exceptions to this, and the setting can |
|
6323 |
be changed with: |
|
6324 |
Display metaModifierMask:(Display modifier1Mask) |
|
6325 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
6326 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6327 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6328 |
all the time. On those, you should disable the meta key by setting |
|
6329 |
the mask to 0. |
|
6330 |
" |
|
6331 |
||
6332 |
metaModifierMask := aSmallInteger |
|
6333 |
! |
|
6334 |
||
6335 |
modifier1Mask |
|
6336 |
"return the Xlib mask bit for the 1st modifier key. |
|
6337 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6338 |
this could be used." |
|
6339 |
||
6340 |
%{ /* NOCONTEXT */ |
|
6341 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6342 |
%} |
|
6343 |
! |
|
6344 |
||
6345 |
modifier2Mask |
|
6346 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6347 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6348 |
this could be used." |
|
6349 |
||
6350 |
%{ /* NOCONTEXT */ |
|
6351 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6352 |
%} |
|
6353 |
! |
|
6354 |
||
6355 |
modifierMapping |
|
6356 |
"Get the Modifier Mapping. |
|
6357 |
We return an array of arrays of keycodes" |
|
6358 |
||
6359 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6360 |
||
6361 |
%{ |
|
6362 |
Display *dpy = myDpy; |
|
6363 |
XModifierKeymap *modmap; |
|
6364 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6365 |
||
6366 |
if (ISCONNECTED) { |
|
6367 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6368 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6369 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6370 |
if (modifierKeyMap != nil) { |
|
6371 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6372 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6373 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6374 |
} |
|
6375 |
XFreeModifiermap(modmap); |
|
6376 |
} |
|
6377 |
} |
|
6378 |
%}. |
|
6379 |
||
6380 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6381 |
||
6382 |
ret := Array new:8. |
|
6383 |
nextKey := 1. |
|
6384 |
1 to:8 do:[ :i | |
|
6385 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6386 |
|mod| |
|
6387 |
||
6388 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6389 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6390 |
key ~= 0 ifTrue:[ |
|
6391 |
mod add:key |
|
6392 |
]. |
|
6393 |
]. |
|
6394 |
ret at:i put:mod. |
|
6395 |
]. |
|
6396 |
nextKey := nextKey+maxKeyPerMod. |
|
6397 |
]. |
|
6398 |
||
6399 |
^ ret |
|
6400 |
||
6401 |
" |
|
6402 |
Display modifierMapping |
|
6403 |
" |
|
6404 |
! |
|
6405 |
||
6406 |
stringFromKeycode:code |
|
6407 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6408 |
||
6409 |
|str| |
|
6410 |
||
6411 |
%{ |
|
6412 |
Display *dpy = myDpy; |
|
6413 |
KeySym keysym; |
|
6414 |
char *keystring; |
|
6415 |
||
6416 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6417 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6418 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6419 |
str = __MKSTRING(keystring); |
|
6420 |
} |
|
6421 |
%}. |
|
6422 |
^ str |
|
6423 |
||
6424 |
" |
|
6425 |
Display stringFromKeycode:28 |
|
6426 |
" |
|
6427 |
! |
|
6428 |
||
295 | 6429 |
translateKey:untranslatedKey |
6430 |
"Return the key translated via the translation table. |
|
6431 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6432 |
which gets further processed in the superclasses translation method." |
|
6433 |
||
6434 |
|key| |
|
6435 |
||
6436 |
(key := untranslatedKey) isString ifTrue:[ |
|
6437 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6438 |
key := key asSymbol. |
|
6439 |
]. |
|
6440 |
^ super translateKey:key |
|
6441 |
! ! |
|
6442 |
||
6443 |
!XWorkstation methodsFor:'misc'! |
|
6444 |
||
6445 |
beep |
|
6446 |
"output an audible beep or bell" |
|
6447 |
||
6448 |
self beep:50 |
|
6449 |
! |
|
6450 |
||
6451 |
beep:volumeInPercent |
|
6452 |
"output an audible beep" |
|
6453 |
%{ |
|
6454 |
int volume; |
|
6455 |
||
6456 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6457 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
555 | 6458 |
volume = __intVal(volumeInPercent) * 2 - 100; |
295 | 6459 |
if (volume < -100) volume = -100; |
6460 |
else if (volume > 100) volume = 100; |
|
6461 |
BEGIN_INTERRUPTSBLOCKED |
|
6462 |
XBell(myDpy, volume); |
|
6463 |
END_INTERRUPTSBLOCKED |
|
6464 |
} |
|
6465 |
%} |
|
6466 |
! |
|
6467 |
||
6468 |
buffered |
|
6469 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6470 |
This is the default anyway. |
6471 |
See #unBuffered for additional info." |
|
295 | 6472 |
|
6473 |
%{ /* NOCONTEXT */ |
|
6474 |
||
6475 |
if (ISCONNECTED) { |
|
6476 |
BEGIN_INTERRUPTSBLOCKED |
|
6477 |
XSynchronize(myDpy, 0); |
|
6478 |
END_INTERRUPTSBLOCKED |
|
6479 |
} |
|
6480 |
%} |
|
374 | 6481 |
" |
6482 |
Display buffered |
|
6483 |
" |
|
295 | 6484 |
! |
6485 |
||
6486 |
flush |
|
6487 |
"send all buffered drawing to the display. |
|
6488 |
This may be required to make certain, that all previous operations |
|
6489 |
are really sent to the display before continuing. For example, |
|
6490 |
after a cursor-change with a followup long computation. |
|
374 | 6491 |
(otherwise, the cursor change request may still be in the output buffer) |
6492 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6493 |
|
6494 |
%{ /* NOCONTEXT */ |
|
6495 |
||
6496 |
if (ISCONNECTED) { |
|
6497 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6498 |
XFlush(myDpy); |
6499 |
END_INTERRUPTSBLOCKED |
|
6500 |
} |
|
6501 |
%} |
|
6502 |
! |
|
6503 |
||
295 | 6504 |
flushDpsContext:aDPSContext |
6505 |
||
6506 |
%{ /* NOCONTEXT */ |
|
6507 |
#ifdef DPS |
|
6508 |
if (__isExternalAddress(aDPSContext)) { |
|
6509 |
BEGIN_INTERRUPTSBLOCKED |
|
6510 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6511 |
END_INTERRUPTSBLOCKED |
|
6512 |
RETURN ( self ); |
|
6513 |
} |
|
6514 |
#endif |
|
374 | 6515 |
%}. |
295 | 6516 |
self primitiveFailed |
6517 |
! |
|
6518 |
||
6519 |
refreshKeyboardMapping:eB |
|
6520 |
%{ |
|
6521 |
XMappingEvent *ev; |
|
6522 |
||
6523 |
if (__isByteArray(eB)) { |
|
555 | 6524 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 6525 |
XRefreshKeyboardMapping(ev); |
6526 |
} |
|
6527 |
%} |
|
6528 |
! |
|
6529 |
||
6530 |
setInputFocusTo:aWindowId |
|
6531 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6532 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6533 |
! |
|
6534 |
||
6535 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6536 |
"set the focus to the view as defined by aWindowId. |
|
6537 |
Passing nil set the focus to no window and lets the display discard all |
|
6538 |
input until a new focus is set. |
|
6539 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6540 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6541 |
given to the parent view, the root view or no view." |
|
6542 |
||
6543 |
%{ /* NOCONTEXT */ |
|
6544 |
int arg; |
|
6545 |
Window focusWindow; |
|
6546 |
||
6547 |
if (ISCONNECTED) { |
|
6548 |
if (__isExternalAddress(aWindowId)) { |
|
6549 |
focusWindow = _WindowVal(aWindowId); |
|
6550 |
} else { |
|
6551 |
focusWindow = None; |
|
6552 |
} |
|
6553 |
if (revertSymbol == @symbol(parent)) |
|
6554 |
arg = RevertToParent; |
|
6555 |
else if (revertSymbol == @symbol(root)) |
|
6556 |
arg = RevertToPointerRoot; |
|
6557 |
else |
|
6558 |
arg = RevertToNone; |
|
6559 |
||
6560 |
BEGIN_INTERRUPTSBLOCKED |
|
6561 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6562 |
END_INTERRUPTSBLOCKED |
|
6563 |
RETURN ( self ); |
|
6564 |
} |
|
6565 |
%}. |
|
6566 |
self primitiveFailed |
|
6567 |
! |
|
6568 |
||
341 | 6569 |
sync |
6570 |
"send all buffered drawing to the display AND wait until the display |
|
6571 |
has finished drawing it. |
|
6572 |
This is almost never needed, except if you are about to read previously |
|
374 | 6573 |
drawn pixels back from the display screen, or you want to wait for a beep |
6574 |
to be finished. See also #flush." |
|
341 | 6575 |
|
6576 |
%{ /* NOCONTEXT */ |
|
6577 |
||
6578 |
if (ISCONNECTED) { |
|
6579 |
BEGIN_INTERRUPTSBLOCKED |
|
6580 |
XSync(myDpy, 0); |
|
6581 |
END_INTERRUPTSBLOCKED |
|
6582 |
} |
|
6583 |
%} |
|
6584 |
! |
|
6585 |
||
295 | 6586 |
unBuffered |
374 | 6587 |
"make all drawing be sent immediately to the display. |
6588 |
This makes all graphics synchronous and turns off any buffering |
|
6589 |
(i.e. each individual draw-request is sent immediately without |
|
6590 |
packing multiple requests into a larger message buffer). |
|
6591 |
Be prepared, that this slows down graphics considerably. |
|
6592 |
However, it allows display errors to be handled immediately and |
|
6593 |
may be useful if you get Xdisplay errors and want to find the request |
|
6594 |
which was responsiblefor it. See also #buffered." |
|
295 | 6595 |
|
6596 |
%{ /* NOCONTEXT */ |
|
6597 |
||
6598 |
if (ISCONNECTED) { |
|
6599 |
BEGIN_INTERRUPTSBLOCKED |
|
6600 |
XSynchronize(myDpy, 1); |
|
6601 |
END_INTERRUPTSBLOCKED |
|
6602 |
} |
|
6603 |
%} |
|
6604 |
"Display unbuffered" |
|
6605 |
! ! |
|
6606 |
||
6607 |
!XWorkstation methodsFor:'pointer queries '! |
|
6608 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6609 |
anyButtonStateMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6610 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6611 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6612 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6613 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6614 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6615 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6616 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6617 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6618 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6619 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6620 |
|
295 | 6621 |
buttonStates |
6622 |
"return an integer representing the state of the pointer buttons; |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6623 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6624 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6625 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 6626 |
|
6627 |
%{ /* NOCONTEXT*/ |
|
6628 |
Display *dpy = myDpy; |
|
6629 |
Window w; |
|
555 | 6630 |
int screen = __intVal(__INST(screen)); |
295 | 6631 |
Window rootRet, childRet; |
6632 |
int rootX, rootY, winX, winY; |
|
6633 |
unsigned int mask; |
|
6634 |
||
6635 |
BEGIN_INTERRUPTSBLOCKED |
|
6636 |
#ifdef VIRTUAL_ROOT |
|
6637 |
w = getRootWindow(myDpy, screen); |
|
6638 |
#else |
|
6639 |
w = RootWindow(dpy, screen); |
|
6640 |
#endif |
|
6641 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
850 | 6642 |
&rootX, &rootY, |
6643 |
&winX, &winY, |
|
6644 |
&mask); |
|
295 | 6645 |
END_INTERRUPTSBLOCKED |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6646 |
RETURN (__MKSMALLINT(mask)); |
295 | 6647 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6648 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6649 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6650 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6651 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6652 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6653 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6654 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6655 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6656 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6657 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6658 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6659 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6660 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6661 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6662 |
" |
295 | 6663 |
! |
6664 |
||
6665 |
leftButtonStateMask |
|
6666 |
"return an integer for masking out the left button from a |
|
6667 |
buttonStates value" |
|
6668 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6669 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6670 |
|
295 | 6671 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6672 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6673 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 6674 |
! |
6675 |
||
6676 |
middleButtonStateMask |
|
6677 |
"return an integer for masking out the middle button from a |
|
6678 |
buttonStates value" |
|
6679 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6680 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6681 |
|
295 | 6682 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6683 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6684 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 6685 |
! |
6686 |
||
6687 |
pointerPosition |
|
6688 |
"return the current pointer position in root-window coordinates" |
|
6689 |
||
6690 |
|xpos ypos| |
|
6691 |
||
6692 |
%{ |
|
6693 |
Display *dpy = myDpy; |
|
6694 |
Window w; |
|
555 | 6695 |
int screen = __intVal(__INST(screen)); |
295 | 6696 |
Window rootRet, childRet; |
6697 |
int rootX, rootY, winX, winY; |
|
6698 |
unsigned int mask; |
|
6699 |
||
6700 |
BEGIN_INTERRUPTSBLOCKED |
|
6701 |
#ifdef VIRTUAL_ROOT |
|
6702 |
w = getRootWindow(myDpy, screen); |
|
6703 |
#else |
|
6704 |
w = RootWindow(dpy, screen); |
|
6705 |
#endif |
|
6706 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6707 |
&rootX, &rootY, |
|
6708 |
&winX, &winY, |
|
6709 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6710 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6711 |
ypos = __MKSMALLINT(rootY); |
295 | 6712 |
END_INTERRUPTSBLOCKED |
6713 |
%} |
|
6714 |
. |
|
6715 |
^ xpos @ ypos |
|
6716 |
! |
|
6717 |
||
6718 |
rightButtonStateMask |
|
6719 |
"return an integer for masking out the right button from a |
|
6720 |
buttonStates value" |
|
6721 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6722 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6723 |
|
295 | 6724 |
^ 1024 |
540
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 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 6727 |
! |
6728 |
||
6729 |
rootPositionOfLastEvent |
|
6730 |
"return the position in root-window coordinates |
|
6731 |
of the last button, key or pointer event" |
|
6732 |
||
6733 |
^ eventRootX @ eventRootY |
|
6734 |
! ! |
|
6735 |
||
6736 |
!XWorkstation methodsFor:'resources'! |
|
6737 |
||
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6738 |
atomIDOf:aStringOrSymbol |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6739 |
"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
|
6740 |
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
|
6741 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6742 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6743 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6744 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6745 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6746 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6747 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6748 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6749 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6750 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6751 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6752 |
atomIDOf:aStringOrSymbol create:create |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6753 |
"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
|
6754 |
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
|
6755 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6756 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6757 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6758 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6759 |
if (ISCONNECTED) { |
850 | 6760 |
if (__isString(aStringOrSymbol) |
6761 |
|| __isSymbol(aStringOrSymbol)) { |
|
6762 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
6763 |
(create == true) ? False : True); |
|
6764 |
if (prop == None) { |
|
6765 |
RETURN (nil); |
|
6766 |
} |
|
6767 |
RETURN ( __MKATOMOBJ(prop) ); |
|
6768 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6769 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6770 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6771 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6772 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6773 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6774 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6775 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6776 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6777 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6778 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6779 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6780 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6781 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6782 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6783 |
atomIDOfCUTBUFFER0 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6784 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6785 |
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
|
6786 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6787 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6788 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6789 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6790 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6791 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6792 |
atomIDOfLENGTH |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6793 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6794 |
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
|
6795 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6796 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6797 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6798 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6799 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6800 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6801 |
atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6802 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6803 |
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
|
6804 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6805 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6806 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6807 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6808 |
! |
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 |
atomIDOfSECONDARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6811 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6812 |
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
|
6813 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6814 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6815 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6816 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
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 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6819 |
atomIDOfSTRING |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6820 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6821 |
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
|
6822 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6823 |
^ stringAtom |
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 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6826 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6827 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6828 |
atomName:anAtomID |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6829 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6830 |
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
|
6831 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6832 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6833 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6834 |
char *name; |
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 |
if (ISCONNECTED) { |
850 | 6837 |
if (__isAtomID(anAtomID)) { |
6838 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
6839 |
if (name == 0) { |
|
6840 |
RETURN (nil); |
|
6841 |
} |
|
6842 |
str = __MKSTRING(name COMMA_CON); |
|
6843 |
XFree(name); |
|
6844 |
RETURN ( str ); |
|
6845 |
} |
|
487
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 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6849 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6850 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6851 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6852 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6853 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6854 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6855 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6856 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6857 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6858 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6859 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6860 |
" |
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 |
|
295 | 6863 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6864 |
"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
|
6865 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6866 |
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
|
6867 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6868 |
Notice: |
850 | 6869 |
we do not plan to use X's resources for ST/X's defaults, |
6870 |
styles or resources. This would make porting of applications |
|
6871 |
to different platforms much more difficult (Windows has no resource |
|
6872 |
database). If you stay within ST/X's resource files, these can be |
|
6873 |
easily transported to other platforms. |
|
487
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 |
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
|
6876 |
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
|
6877 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6878 |
|
295 | 6879 |
%{ |
6880 |
char *rslt; |
|
6881 |
||
6882 |
if ((__isString(name) || __isSymbol(name)) |
|
6883 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6884 |
&& ISCONNECTED) { |
|
850 | 6885 |
BEGIN_INTERRUPTSBLOCKED |
6886 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
6887 |
(char *)_stringVal(name)); |
|
6888 |
END_INTERRUPTSBLOCKED |
|
6889 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
|
487
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 |
%}. |
295 | 6892 |
self primitiveFailed. |
6893 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6894 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6895 |
"if your ~/.Xdefaults contains an entry such as: |
850 | 6896 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6897 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6898 |
|
850 | 6899 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6900 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6901 |
if your ~/.Xdefaults contains an entry such as: |
850 | 6902 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6903 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6904 |
|
850 | 6905 |
Display getResource:'beNiceToColormap' class:'any' |
6906 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6907 |
" |
295 | 6908 |
! ! |
6909 |
||
6910 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6911 |
||
6912 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6913 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6914 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6915 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6916 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6917 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6918 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6919 |
|rawInfo info| |
295 | 6920 |
|
6921 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6922 |
self primitiveFailed. |
|
6923 |
^ nil |
|
6924 |
]. |
|
6925 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6926 |
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
|
6927 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6928 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6929 |
"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
|
6930 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6931 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6932 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6933 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6934 |
"8 -> bits_per_pixel" |
295 | 6935 |
|
6936 |
"/ had to extract the getPixel call into a separate method, to specify |
|
6937 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
6938 |
"/ of temporary stack space |
|
6939 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6940 |
(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
|
6941 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6942 |
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
|
6943 |
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
|
6944 |
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
|
6945 |
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
|
6946 |
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
|
6947 |
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
|
6948 |
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
|
6949 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 6950 |
^ info |
6951 |
]. |
|
6952 |
" |
|
6953 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
6954 |
or is too small to hold the bits |
|
6955 |
" |
|
6956 |
^ self primitiveFailed |
|
6957 |
! |
|
6958 |
||
6959 |
getPixelX:x y:y from:aDrawableId |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6960 |
"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
|
6961 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 6962 |
|
6963 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
6964 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6965 |
Window win; |
295 | 6966 |
XImage *img; |
6967 |
int ret; |
|
6968 |
int xpos, ypos; |
|
6969 |
||
6970 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
850 | 6971 |
win = _WindowVal(aDrawableId); |
6972 |
xpos = __intVal(x); |
|
6973 |
ypos = __intVal(y); |
|
6974 |
if ((xpos < 0) || (ypos < 0)) { |
|
6975 |
RETURN ( __MKSMALLINT(0) ); |
|
6976 |
} |
|
6977 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
6978 |
if (img != 0) { |
|
6979 |
ret = XGetPixel(img, 0, 0); |
|
6980 |
XDestroyImage(img); |
|
6981 |
RETURN ( __MKSMALLINT(ret) ); |
|
6982 |
} |
|
295 | 6983 |
} |
6984 |
%}. |
|
6985 |
^ nil |
|
6986 |
! |
|
6987 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6988 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 6989 |
"since XGetImage may allocate huge amount of stack space |
6990 |
(some implementations use alloca), this must run with unlimited stack." |
|
6991 |
||
6992 |
%{ /* UNLIMITEDSTACK */ |
|
6993 |
||
6994 |
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
|
6995 |
Window win; |
295 | 6996 |
XImage *image = (XImage *)0; |
6997 |
int pad, bytes_per_line, numBytes; |
|
6998 |
||
6999 |
if (__isExternalAddress(aDrawableId) |
|
7000 |
&& __bothSmallInteger(srcx, srcy) |
|
7001 |
&& __bothSmallInteger(w, h) |
|
7002 |
&& __isArray(info) |
|
7003 |
&& __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
|
7004 |
win = _WindowVal(aDrawableId); |
555 | 7005 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
7006 |
__intVal(w), __intVal(h), |
|
295 | 7007 |
(unsigned)AllPlanes, ZPixmap); |
7008 |
||
378 | 7009 |
if (! image) { |
7010 |
RETURN ( false ); |
|
7011 |
} |
|
7012 |
||
295 | 7013 |
pad = image->bitmap_pad; |
7014 |
#ifdef SUPERDEBUG |
|
7015 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
7016 |
#endif |
|
7017 |
switch (image->depth) { |
|
7018 |
case 1: |
|
7019 |
case 2: |
|
7020 |
case 4: |
|
7021 |
case 8: |
|
7022 |
case 16: |
|
7023 |
case 24: |
|
7024 |
case 32: |
|
7025 |
numBytes = image->bytes_per_line * image->height; |
|
7026 |
break; |
|
7027 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7028 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7029 |
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
|
7030 |
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
|
7031 |
break; |
295 | 7032 |
} |
7033 |
||
7034 |
#ifdef SUPERDEBUG |
|
555 | 7035 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 7036 |
#endif |
7037 |
||
555 | 7038 |
if (numBytes > __byteArraySize(imageBits)) { |
295 | 7039 |
/* imageBits too small */ |
378 | 7040 |
printf("provided byteArray too small\n"); |
295 | 7041 |
goto fail; |
7042 |
} |
|
7043 |
if (image->bitmap_bit_order == MSBFirst) |
|
555 | 7044 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
295 | 7045 |
else |
555 | 7046 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
7047 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
7048 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
295 | 7049 |
if (image->byte_order == MSBFirst) |
555 | 7050 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
295 | 7051 |
else |
555 | 7052 |
__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
|
7053 |
if (image->format == XYBitmap) |
555 | 7054 |
__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
|
7055 |
else if (image->format == XYPixmap) |
555 | 7056 |
__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
|
7057 |
else if (image->format == ZPixmap) |
555 | 7058 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7059 |
|
555 | 7060 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
7061 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
7062 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
7063 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
295 | 7064 |
XDestroyImage(image); |
7065 |
RETURN ( true ); |
|
7066 |
} |
|
7067 |
fail: |
|
7068 |
if (image) { |
|
7069 |
XDestroyImage(image); |
|
7070 |
} |
|
7071 |
%}. |
|
7072 |
^ false |
|
7073 |
! ! |
|
7074 |
||
7075 |
!XWorkstation methodsFor:'selections'! |
|
7076 |
||
7077 |
getObjectProperty:propertyID from:aWindowID |
|
7078 |
"get an object property; return object or nil" |
|
7079 |
||
7080 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7081 |
type == stringAtom ifTrue:[ |
|
7082 |
^ value |
|
7083 |
]. |
|
7084 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7085 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7086 |
] |
|
7087 |
]. |
|
7088 |
^ nil |
|
7089 |
! |
|
7090 |
||
7091 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7092 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7093 |
||
7094 |
|val typeID cls| |
|
7095 |
||
7096 |
cls := ByteArray. |
|
7097 |
%{ |
|
7098 |
Display *dpy = myDpy; |
|
7099 |
Window window; |
|
7100 |
Atom property; |
|
7101 |
char *cp, *cp2; |
|
7102 |
Atom actual_type; |
|
7103 |
int actual_format,i; |
|
7104 |
unsigned long nitems, bytes_after, nread; |
|
7105 |
unsigned char *data; |
|
7106 |
int ok = 1; |
|
7107 |
# define PROP_SIZE 2048 |
|
7108 |
||
7109 |
if (__isAtomID(propertyID)) { |
|
7110 |
property = _AtomVal(propertyID); |
|
7111 |
if (__isExternalAddress(aWindowID)) { |
|
7112 |
window = _WindowVal(aWindowID); |
|
7113 |
} else { |
|
7114 |
window = DefaultRootWindow(dpy); |
|
7115 |
} |
|
7116 |
||
7117 |
nread = 0; |
|
7118 |
cp = 0; |
|
7119 |
/* |
|
7120 |
fprintf(stderr, "getProperty: "); |
|
7121 |
*/ |
|
7122 |
do { |
|
7123 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7124 |
AnyPropertyType,&actual_type,&actual_format, |
|
7125 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7126 |
!= Success) { |
|
7127 |
ok = 0; |
|
7128 |
break; |
|
7129 |
} |
|
7130 |
typeID = __MKATOMOBJ(actual_type); |
|
7131 |
if (! cp) { |
|
7132 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7133 |
} else { |
|
7134 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7135 |
cp2 = cp + nread; |
|
7136 |
} |
|
7137 |
if (! cp) goto fail; |
|
7138 |
||
7139 |
nread += nitems; |
|
7140 |
bcopy(data, cp2, nitems); |
|
7141 |
XFree(data); |
|
7142 |
/* |
|
7143 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7144 |
*/ |
|
7145 |
} while (bytes_after > 0); |
|
7146 |
/* |
|
7147 |
fprintf(stderr, "\n"); |
|
7148 |
*/ |
|
7149 |
||
7150 |
if (ok) { |
|
7151 |
if (actual_type == XA_STRING) { |
|
7152 |
cp[nread] = '\0'; |
|
7153 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
7154 |
} else { |
|
7155 |
val = __new(nread + OHDR_SIZE); |
|
7156 |
val->o_class = cls; |
|
555 | 7157 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
295 | 7158 |
} |
7159 |
} |
|
7160 |
if (cp) |
|
7161 |
free(cp); |
|
7162 |
} |
|
7163 |
fail: ; |
|
7164 |
%}. |
|
7165 |
typeID isNil ifTrue:[ |
|
7166 |
^ false |
|
7167 |
]. |
|
7168 |
aTwoArgBlock value:typeID value:val. |
|
7169 |
^ true |
|
7170 |
! |
|
7171 |
||
7172 |
getSelectionFor:drawableId |
|
7173 |
"get the object selection - either immediate, or asynchronous. |
|
7174 |
Returns nil, if async request is on its way" |
|
7175 |
||
7176 |
|selProp sel| |
|
7177 |
||
7178 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7179 |
"no primary selection - use cut buffer" |
|
7180 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7181 |
^ sel |
|
7182 |
]. |
|
7183 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7184 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7185 |
^ nil |
|
7186 |
! |
|
7187 |
||
7188 |
getSelectionOwnerOf:selectionAtomID |
|
7189 |
"get the owner of a selection" |
|
7190 |
||
7191 |
%{ /* NOCONTEXT */ |
|
7192 |
Display *dpy = myDpy; |
|
7193 |
Atom selection; |
|
7194 |
Window window; |
|
7195 |
||
7196 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
7197 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7198 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
7199 |
} |
|
7200 |
%}. |
|
7201 |
self primitiveFailed. |
|
7202 |
^ nil |
|
7203 |
! |
|
7204 |
||
7205 |
getTextProperty:propertyID from:aWindowID |
|
7206 |
"get a text property; return string or nil" |
|
7207 |
||
7208 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7209 |
type == stringAtom ifTrue:[ |
|
7210 |
^ value |
|
7211 |
] |
|
7212 |
]. |
|
7213 |
^ nil |
|
7214 |
! |
|
7215 |
||
7216 |
getTextSelectionFor:drawableId |
|
7217 |
"get the text selection - either immediate, or asynchronous. |
|
7218 |
Returns nil, if async request is on its way" |
|
7219 |
||
7220 |
|selProp sel| |
|
7221 |
||
7222 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7223 |
"no primary selection - use cut buffer" |
|
7224 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7225 |
^ sel |
|
7226 |
]. |
|
7227 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7228 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7229 |
^ nil |
|
7230 |
! |
|
7231 |
||
7232 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
7233 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7234 |
will later receive a SelectionNotify event for it." |
|
7235 |
||
7236 |
^ self requestSelection:selectionID |
|
7237 |
property:propertyID |
|
7238 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7239 |
for:aWindowId |
|
7240 |
! |
|
7241 |
||
7242 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
7243 |
"ask the server to send us the selection - the view with id aWindowID |
|
7244 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7245 |
with the selections value)." |
|
7246 |
||
7247 |
%{ /* NOCONTEXT */ |
|
7248 |
Display *dpy = myDpy; |
|
7249 |
Atom sel_prop; |
|
7250 |
char *cp; |
|
7251 |
||
7252 |
if (__isExternalAddress(aWindowId) |
|
7253 |
&& ISCONNECTED |
|
7254 |
&& __isSmallInteger(typeID) |
|
7255 |
&& __isAtomID(selectionID)) { |
|
7256 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7257 |
/* |
|
7258 |
* no owner of primary selection |
|
7259 |
*/ |
|
7260 |
RETURN (false); |
|
7261 |
} |
|
7262 |
/* |
|
7263 |
* PRIMARY selection |
|
7264 |
*/ |
|
7265 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7266 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7267 |
RETURN (true); |
|
7268 |
} |
|
7269 |
%}. |
|
7270 |
self primitiveFailed. |
|
7271 |
^ false |
|
7272 |
||
7273 |
" |
|
7274 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
7275 |
property:(Display atomIDOf:'VT_SELECTION') |
|
7276 |
for:0 |
|
7277 |
" |
|
7278 |
! |
|
7279 |
||
7280 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
7281 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7282 |
will later receive a SelectionNotify event for it." |
|
7283 |
||
7284 |
^ self requestSelection:selectionID |
|
7285 |
property:propertyID |
|
7286 |
type:stringAtom |
|
7287 |
for:aWindowId |
|
7288 |
! |
|
7289 |
||
7290 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
7291 |
"send aString back from a SelectionRequest" |
|
7292 |
||
7293 |
self |
|
7294 |
sendSelection:something |
|
7295 |
selection:primaryAtom |
|
7296 |
property:propertyID |
|
7297 |
target:targetID |
|
7298 |
from:windowID |
|
7299 |
to:requestorID |
|
7300 |
! |
|
7301 |
||
7302 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7303 |
"send aString back from a SelectionRequest" |
|
7304 |
||
7305 |
self |
|
7306 |
setProperty:propertyID |
|
7307 |
type:targetID |
|
7308 |
value:something |
|
7309 |
for:requestorID. |
|
7310 |
self |
|
7311 |
sendSelectionNotifySelection:selectionID |
|
7312 |
property:propertyID |
|
7313 |
target:targetID |
|
7314 |
from:requestorID |
|
7315 |
to:requestorID. |
|
7316 |
! |
|
7317 |
||
7318 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7319 |
"send a selectionNotify back from a SelectionRequest" |
|
7320 |
||
7321 |
%{ /* NOCONTEXT */ |
|
7322 |
Display *dpy = myDpy; |
|
7323 |
||
7324 |
if (__isAtomID(propertyID) |
|
7325 |
&& __isExternalAddress(requestorID) |
|
7326 |
&& ISCONNECTED |
|
7327 |
&& __isAtomID(targetID) |
|
7328 |
&& __isAtomID(selectionID)) { |
|
7329 |
XEvent ev; |
|
7330 |
Window requestor = _WindowVal(requestorID); |
|
7331 |
Atom property = _AtomVal(propertyID); |
|
7332 |
Atom target = _AtomVal(targetID); |
|
7333 |
Atom selection = _AtomVal(selectionID); |
|
7334 |
Status result; |
|
7335 |
||
7336 |
ev.xselection.type = SelectionNotify; |
|
7337 |
ev.xselection.selection = selection; |
|
7338 |
ev.xselection.target = target; |
|
7339 |
if (__isExternalAddress(windowID)) |
|
7340 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7341 |
else |
|
7342 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7343 |
ev.xselection.time = CurrentTime; |
|
7344 |
if (property == None) |
|
7345 |
ev.xselection.property = target; |
|
7346 |
else |
|
7347 |
ev.xselection.property = property; |
|
7348 |
||
7349 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7350 |
ev.xselection.selection, |
|
7351 |
ev.xselection.property, |
|
7352 |
ev.xselection.target, |
|
7353 |
ev.xselection.requestor, |
|
7354 |
requestor)); |
|
7355 |
||
7356 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7357 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7358 |
DPRINTF(("bad status\n")); |
|
382 | 7359 |
RETURN (false); |
295 | 7360 |
} |
382 | 7361 |
RETURN (true) |
7362 |
} |
|
7363 |
%}. |
|
7364 |
self primitiveFailed. |
|
7365 |
^ false |
|
295 | 7366 |
! |
7367 |
||
7368 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7369 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
7370 |
! |
|
7371 |
||
7372 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7373 |
|s| |
|
7374 |
||
7375 |
(anObject isMemberOf:String) ifTrue:[ |
|
7376 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7377 |
]. |
|
7378 |
s := WriteStream on:(ByteArray new:200). |
|
7379 |
anObject storeBinaryOn:s. |
|
7380 |
^ self |
|
7381 |
setProperty:propertyID |
|
7382 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7383 |
value:(s contents) |
|
7384 |
for:aWindowID |
|
7385 |
! |
|
7386 |
||
7387 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7388 |
||
7389 |
%{ /* UNLIMITEDSTACK */ |
|
7390 |
||
7391 |
Display *dpy = myDpy; |
|
7392 |
Atom prop, type; |
|
7393 |
Window window; |
|
7394 |
unsigned int value; |
|
7395 |
||
7396 |
if (__isAtomID(propertyID) |
|
7397 |
&& __isAtomID(typeID) |
|
7398 |
&& ISCONNECTED |
|
7399 |
&& (__isString(anObject) |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7400 |
|| __isSmallInteger(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7401 |
|| __isSymbol(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7402 |
|| __isByteArray(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7403 |
|| __isWords(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7404 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7405 |
prop = _AtomVal(propertyID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7406 |
type = _AtomVal(typeID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7407 |
if (__isExternalAddress(aWindowID)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7408 |
window = _WindowVal(aWindowID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7409 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7410 |
window = DefaultRootWindow(dpy); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7411 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7412 |
if (__isSmallInteger(anObject)) { |
555 | 7413 |
value = __intVal(anObject); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7414 |
XChangeProperty(dpy, window, prop, type, 32, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7415 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7416 |
(unsigned char *)(&value), sizeof(unsigned int)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7417 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7418 |
if (__isByteArray(anObject)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7419 |
XChangeProperty(dpy, window, prop, type, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7420 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7421 |
__ByteArrayInstPtr(anObject)->ba_element, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7422 |
__byteArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7423 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7424 |
/* 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
|
7425 |
if (__isWords(__qClass(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7426 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7427 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7428 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7429 |
__wordArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7430 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7431 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7432 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7433 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7434 |
strlen(__stringVal(anObject))); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7435 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7436 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7437 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7438 |
RETURN (true); |
295 | 7439 |
} |
7440 |
%}. |
|
7441 |
^ false |
|
7442 |
! |
|
7443 |
||
7444 |
setSelection:anObject owner:aWindowId |
|
7445 |
"set the object selection, and make aWindowId be the owner. |
|
7446 |
This can be used by other Smalltalk(X) applications only." |
|
7447 |
||
7448 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7449 |
^ false |
|
7450 |
]. |
|
7451 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7452 |
^ true |
|
7453 |
! |
|
7454 |
||
7455 |
setSelectionOwner:aWindowId of:selectionID |
|
7456 |
"set the owner of a selection; return false if failed" |
|
7457 |
||
7458 |
%{ /* NOCONTEXT */ |
|
7459 |
Display *dpy = myDpy; |
|
7460 |
Window win; |
|
7461 |
||
7462 |
if (__isExternalAddress(aWindowId) |
|
7463 |
&& __isAtomID(selectionID) |
|
7464 |
&& ISCONNECTED) { |
|
7465 |
win = _WindowVal(aWindowId); |
|
7466 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7467 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7468 |
RETURN (false); |
|
7469 |
} |
|
7470 |
RETURN (true); |
|
7471 |
} |
|
7472 |
%} |
|
7473 |
. |
|
7474 |
self primitiveFailed. |
|
7475 |
^ nil |
|
7476 |
! |
|
7477 |
||
7478 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7479 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7480 |
! |
|
7481 |
||
7482 |
setTextSelection:aString owner:aWindowId |
|
7483 |
"set the text selection, and make aWindowId be the owner. |
|
7484 |
This can be used by any other X application." |
|
7485 |
||
7486 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7487 |
'ownerchange failed' errorPrintNL. |
|
7488 |
]. |
|
7489 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7490 |
! ! |
|
7491 |
||
7492 |
!XWorkstation methodsFor:'window stuff'! |
|
7493 |
||
7494 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7495 |
"clear a rectangular area to viewbackground" |
|
7496 |
||
7497 |
%{ /* NOCONTEXT */ |
|
7498 |
||
7499 |
int w, h; |
|
7500 |
||
7501 |
if (__isExternalAddress(aWindowId) |
|
7502 |
&& __bothSmallInteger(x, y) |
|
7503 |
&& __bothSmallInteger(width, height)) { |
|
555 | 7504 |
w = __intVal(width); |
7505 |
h = __intVal(height); |
|
295 | 7506 |
if (w < 0) w = 0; |
7507 |
if (h < 0) h = 0; |
|
555 | 7508 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
295 | 7509 |
RETURN ( self ); |
7510 |
} |
|
7511 |
%} |
|
7512 |
. |
|
7513 |
self primitiveFailed |
|
7514 |
! |
|
7515 |
||
7516 |
clearWindow:aWindowId |
|
7517 |
"clear a window to viewbackground" |
|
7518 |
||
7519 |
%{ /* NOCONTEXT */ |
|
7520 |
||
7521 |
if (__isExternalAddress(aWindowId)) { |
|
7522 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7523 |
RETURN ( self ); |
|
7524 |
} |
|
7525 |
%} |
|
7526 |
. |
|
7527 |
self primitiveFailed |
|
7528 |
! |
|
7529 |
||
7530 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7531 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7532 |
||
7533 |
%{ /* NOCONTEXT */ |
|
7534 |
||
7535 |
XWindowChanges chg; |
|
7536 |
int mask = CWSibling | CWStackMode; |
|
7537 |
||
7538 |
if (__isExternalAddress(aWindowId) |
|
7539 |
&& __isExternalAddress(siblingId)) { |
|
7540 |
if (modeSymbol == @symbol(above)) { |
|
7541 |
chg.stack_mode = Above; |
|
7542 |
} else if (modeSymbol == @symbol(below)) { |
|
7543 |
chg.stack_mode = Below; |
|
7544 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7545 |
chg.stack_mode = TopIf; |
|
7546 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7547 |
chg.stack_mode = BottomIf; |
|
7548 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7549 |
chg.stack_mode = Opposite; |
|
7550 |
} else { |
|
7551 |
mask = CWSibling; |
|
7552 |
} |
|
7553 |
||
7554 |
chg.sibling = _WindowVal(siblingId); |
|
7555 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7556 |
mask, &chg); |
|
7557 |
RETURN ( self ); |
|
7558 |
} |
|
7559 |
bad: ; |
|
7560 |
%} |
|
7561 |
. |
|
7562 |
self primitiveFailed |
|
7563 |
! |
|
7564 |
||
7565 |
lowerWindow:aWindowId |
|
7566 |
"bring a window to back" |
|
7567 |
||
7568 |
%{ /* NOCONTEXT */ |
|
7569 |
||
7570 |
if (__isExternalAddress(aWindowId)) { |
|
7571 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7572 |
RETURN ( self ); |
|
7573 |
} |
|
7574 |
%} |
|
7575 |
. |
|
7576 |
self primitiveFailed |
|
7577 |
! |
|
7578 |
||
7579 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7580 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7581 |
||
7582 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7583 |
||
7584 |
aBoolean ifTrue:[ |
|
7585 |
wicon := aView icon. |
|
7586 |
wicon notNil ifTrue:[ |
|
7587 |
wiconId := wicon id |
|
7588 |
]. |
|
7589 |
wiconView := aView iconView. |
|
7590 |
wiconView notNil ifTrue:[ |
|
7591 |
wiconViewId := wiconView id |
|
7592 |
]. |
|
7593 |
wlabel := aView label. |
|
7594 |
]. |
|
7595 |
%{ |
|
7596 |
||
7597 |
XWMHints wmhints; |
|
7598 |
XSizeHints szhints; |
|
7599 |
Display *dpy = myDpy; |
|
7600 |
Window win; |
|
7601 |
||
7602 |
if (__isExternalAddress(aWindowId)) { |
|
7603 |
win = _WindowVal(aWindowId); |
|
7604 |
||
7605 |
szhints.flags = 0; |
|
7606 |
if (__bothSmallInteger(xPos, yPos)) { |
|
555 | 7607 |
szhints.x = __intVal(xPos); |
7608 |
szhints.y = __intVal(yPos); |
|
295 | 7609 |
szhints.flags |= USPosition; |
7610 |
} |
|
7611 |
if (__bothSmallInteger(w, h)) { |
|
555 | 7612 |
szhints.width = __intVal(w); |
7613 |
szhints.height = __intVal(h); |
|
295 | 7614 |
szhints.flags |= USSize; |
7615 |
} |
|
7616 |
||
7617 |
if (aBoolean == true) { |
|
7618 |
char *windowName; |
|
7619 |
Pixmap iconBitmap = (Pixmap)0; |
|
7620 |
Window iconWindow; |
|
7621 |
||
7622 |
if (__isExternalAddress(wiconId)) |
|
7623 |
iconBitmap = _PixmapVal(wiconId); |
|
7624 |
else |
|
7625 |
iconBitmap = (Pixmap)0; |
|
7626 |
||
7627 |
if (__isExternalAddress(wiconViewId)) |
|
7628 |
iconWindow = _WindowVal(wiconViewId); |
|
7629 |
else |
|
7630 |
iconWindow = (Window)0; |
|
7631 |
||
7632 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7633 |
windowName = (char *)_stringVal(wlabel); |
|
7634 |
else |
|
7635 |
windowName = ""; |
|
7636 |
||
7637 |
if (iconBitmap || windowName) { |
|
7638 |
XSetStandardProperties(dpy, win, |
|
7639 |
windowName, windowName, |
|
7640 |
iconBitmap, |
|
7641 |
0, 0, &szhints); |
|
7642 |
} |
|
7643 |
||
7644 |
wmhints.flags = 0; |
|
7645 |
if (iconBitmap) { |
|
7646 |
wmhints.flags |= IconPixmapHint; |
|
7647 |
wmhints.icon_pixmap = iconBitmap; |
|
7648 |
} |
|
7649 |
if (iconWindow) { |
|
7650 |
wmhints.flags |= IconWindowHint; |
|
7651 |
wmhints.icon_window = iconWindow; |
|
7652 |
} |
|
7653 |
||
7654 |
wmhints.initial_state = IconicState; |
|
7655 |
wmhints.flags |= StateHint; |
|
7656 |
XSetWMHints(dpy, win, &wmhints); |
|
7657 |
} |
|
7658 |
||
7659 |
if (szhints.flags) { |
|
7660 |
XSetNormalHints(dpy, win, &szhints); |
|
7661 |
} |
|
7662 |
||
7663 |
XMapWindow(dpy, win); |
|
7664 |
RETURN ( self ); |
|
7665 |
} |
|
7666 |
%} |
|
7667 |
. |
|
7668 |
self primitiveFailed |
|
7669 |
! |
|
7670 |
||
7671 |
mapWindow:aWindowId |
|
7672 |
"make a window visible" |
|
7673 |
||
7674 |
%{ /* NOCONTEXT */ |
|
7675 |
||
7676 |
if (__isExternalAddress(aWindowId)) { |
|
7677 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7678 |
RETURN ( self ); |
|
7679 |
} |
|
7680 |
%} |
|
7681 |
. |
|
7682 |
self primitiveFailed |
|
7683 |
! |
|
7684 |
||
7685 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7686 |
"move and resize a window" |
|
7687 |
||
7688 |
%{ /* NOCONTEXT */ |
|
7689 |
||
7690 |
int newWidth, newHeight; |
|
7691 |
||
7692 |
if (__isExternalAddress(aWindowId) |
|
7693 |
&& __bothSmallInteger(w, h) |
|
7694 |
&& __bothSmallInteger(x, y)) { |
|
555 | 7695 |
newWidth = __intVal(w); |
7696 |
newHeight = __intVal(h); |
|
295 | 7697 |
if (newWidth < 1) newWidth = 1; |
7698 |
if (newHeight < 1) newHeight = 1; |
|
7699 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
555 | 7700 |
__intVal(x), __intVal(y), |
295 | 7701 |
newWidth, newHeight); |
7702 |
RETURN ( self ); |
|
7703 |
} |
|
7704 |
%} |
|
7705 |
. |
|
7706 |
self primitiveFailed |
|
7707 |
! |
|
7708 |
||
7709 |
moveWindow:aWindowId x:x y:y |
|
7710 |
"move a window" |
|
7711 |
||
7712 |
%{ /* NOCONTEXT */ |
|
7713 |
||
7714 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
555 | 7715 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
295 | 7716 |
RETURN ( self ); |
7717 |
} |
|
7718 |
%} |
|
7719 |
. |
|
7720 |
self primitiveFailed |
|
7721 |
! |
|
7722 |
||
7723 |
raiseWindow:aWindowId |
|
7724 |
"bring a window to front" |
|
7725 |
||
7726 |
%{ /* NOCONTEXT */ |
|
7727 |
||
7728 |
if (__isExternalAddress(aWindowId)) { |
|
7729 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7730 |
RETURN ( self ); |
|
7731 |
} |
|
7732 |
%} |
|
7733 |
. |
|
7734 |
self primitiveFailed |
|
7735 |
! |
|
7736 |
||
7737 |
resizeWindow:aWindowId width:w height:h |
|
7738 |
"resize a window" |
|
7739 |
||
7740 |
%{ /* NOCONTEXT */ |
|
7741 |
||
7742 |
int newWidth, newHeight; |
|
7743 |
||
7744 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
555 | 7745 |
newWidth = __intVal(w); |
7746 |
newHeight = __intVal(h); |
|
295 | 7747 |
if (newWidth < 1) newWidth = 1; |
7748 |
if (newHeight < 1) newHeight = 1; |
|
7749 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7750 |
RETURN ( self ); |
|
7751 |
} |
|
7752 |
%} |
|
7753 |
. |
|
7754 |
self primitiveFailed |
|
7755 |
! |
|
7756 |
||
7757 |
setBackingStore:how in:aWindowId |
|
7758 |
"turn on/off backing-store for a window" |
|
7759 |
||
7760 |
%{ /* NOCONTEXT */ |
|
7761 |
||
7762 |
XSetWindowAttributes wa; |
|
7763 |
||
7764 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7765 |
if (__INST(ignoreBackingStore) != true) { |
295 | 7766 |
if (how == @symbol(always)) wa.backing_store = Always; |
7767 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7768 |
else if (how == true) wa.backing_store = Always; |
|
7769 |
else wa.backing_store = 0; |
|
7770 |
BEGIN_INTERRUPTSBLOCKED |
|
7771 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7772 |
END_INTERRUPTSBLOCKED |
|
7773 |
} |
|
7774 |
RETURN ( self ); |
|
7775 |
} |
|
7776 |
%}. |
|
7777 |
self primitiveFailed |
|
7778 |
! |
|
7779 |
||
7780 |
setBitGravity:how in:aWindowId |
|
7781 |
"set bit gravity for a window" |
|
7782 |
||
7783 |
%{ /* NOCONTEXT */ |
|
7784 |
||
7785 |
XSetWindowAttributes wa; |
|
7786 |
||
7787 |
if (__isExternalAddress(aWindowId)) { |
|
7788 |
if (how == @symbol(NorthWest)) { |
|
7789 |
wa.bit_gravity = NorthWestGravity; |
|
7790 |
} else if (how == @symbol(NorthEast)) { |
|
7791 |
wa.bit_gravity = NorthEastGravity; |
|
7792 |
} else if (how == @symbol(SouthWest)) { |
|
7793 |
wa.bit_gravity = SouthWestGravity; |
|
7794 |
} else if (how == @symbol(SouthEast)) { |
|
7795 |
wa.bit_gravity = SouthEastGravity; |
|
7796 |
} else if (how == @symbol(Center)) { |
|
7797 |
wa.bit_gravity = CenterGravity; |
|
7798 |
} else if (how == @symbol(North)) { |
|
7799 |
wa.bit_gravity = NorthGravity; |
|
7800 |
} else if (how == @symbol(South)) { |
|
7801 |
wa.bit_gravity = SouthGravity; |
|
7802 |
} else if (how == @symbol(West)) { |
|
7803 |
wa.bit_gravity = WestGravity; |
|
7804 |
} else if (how == @symbol(East)) { |
|
7805 |
wa.bit_gravity = EastGravity; |
|
7806 |
} else { |
|
7807 |
wa.bit_gravity = NorthWestGravity; |
|
7808 |
} |
|
7809 |
||
7810 |
BEGIN_INTERRUPTSBLOCKED |
|
7811 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7812 |
END_INTERRUPTSBLOCKED |
|
7813 |
RETURN ( self ); |
|
7814 |
} |
|
7815 |
%}. |
|
7816 |
self primitiveFailed |
|
7817 |
! |
|
7818 |
||
7819 |
setCursor:aCursorId in:aWindowId |
|
7820 |
"define a windows cursor" |
|
7821 |
||
7822 |
%{ /* NOCONTEXT */ |
|
7823 |
||
7824 |
Display *dpy = myDpy; |
|
7825 |
||
7826 |
if (__isExternalAddress(aWindowId) |
|
7827 |
&& __isExternalAddress(aCursorId)) { |
|
7828 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7829 |
RETURN ( self ); |
|
7830 |
} |
|
7831 |
%}. |
|
7832 |
self primitiveFailed |
|
7833 |
! |
|
7834 |
||
7835 |
setIconName:aString in:aWindowId |
|
7836 |
"define a windows iconname" |
|
7837 |
||
7838 |
%{ /* NOCONTEXT */ |
|
7839 |
||
7840 |
if (__isExternalAddress(aWindowId) |
|
7841 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7842 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7843 |
RETURN ( self ); |
|
7844 |
} |
|
7845 |
%}. |
|
7846 |
self primitiveFailed |
|
7847 |
! |
|
7848 |
||
7849 |
setSaveUnder:yesOrNo in:aWindowId |
|
7850 |
"turn on/off save-under for a window" |
|
7851 |
||
7852 |
%{ /* NOCONTEXT */ |
|
7853 |
||
7854 |
XSetWindowAttributes wa; |
|
7855 |
||
7856 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7857 |
if (__INST(hasSaveUnder) == true) { |
295 | 7858 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
7859 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7860 |
} |
|
7861 |
RETURN ( self ); |
|
7862 |
} |
|
7863 |
%}. |
|
7864 |
self primitiveFailed |
|
7865 |
! |
|
7866 |
||
7867 |
setTransient:aWindowId for:aMainWindowId |
|
7868 |
"set aWindowId to be a transient of aMainWindow" |
|
7869 |
||
7870 |
%{ /* NOCONTEXT */ |
|
7871 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7872 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7873 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7874 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7875 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7876 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7877 |
} else { |
374 | 7878 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7879 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7880 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7881 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7882 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7883 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7884 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7885 |
RETURN ( self ); |
7886 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7887 |
getOutOfHere: ; |
295 | 7888 |
%}. |
7889 |
self primitiveFailed |
|
7890 |
! |
|
7891 |
||
7892 |
setWindowBackground:aColorIndex in:aWindowId |
|
7893 |
"set the windows background color. This is the color with which |
|
7894 |
the view is filled whenever exposed. Do not confuse this with |
|
7895 |
the background drawing color, which is used with opaque drawing." |
|
7896 |
||
7897 |
%{ /* NOCONTEXT */ |
|
7898 |
||
7899 |
if (__isExternalAddress(aWindowId) |
|
7900 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7901 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7902 |
RETURN ( self ); |
7903 |
} |
|
7904 |
%}. |
|
7905 |
self primitiveFailed |
|
7906 |
! |
|
7907 |
||
7908 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7909 |
"set the windows background pattern to be a form. |
|
7910 |
This is the pattern with which the view is filled whenever exposed. |
|
7911 |
Do not confuse this with the background drawing color, which is used |
|
7912 |
with opaque drawing." |
|
7913 |
||
7914 |
%{ /* NOCONTEXT */ |
|
7915 |
||
7916 |
if (__isExternalAddress(aWindowId) |
|
7917 |
&& __isExternalAddress(aPixmapId)) { |
|
7918 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7919 |
RETURN ( self ); |
|
7920 |
} |
|
7921 |
%}. |
|
7922 |
self primitiveFailed |
|
7923 |
! |
|
7924 |
||
7925 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7926 |
"set the windows border color" |
|
7927 |
||
7928 |
%{ /* NOCONTEXT */ |
|
7929 |
||
7930 |
if (__isExternalAddress(aWindowId) |
|
7931 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7932 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7933 |
RETURN ( self ); |
7934 |
} |
|
7935 |
%}. |
|
7936 |
self primitiveFailed |
|
7937 |
! |
|
7938 |
||
7939 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
7940 |
"set the windows border pattern" |
|
7941 |
||
7942 |
%{ /* NOCONTEXT */ |
|
7943 |
||
7944 |
if (__isExternalAddress(aWindowId) |
|
7945 |
&& __isExternalAddress(aPixmapId)) { |
|
7946 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7947 |
RETURN ( self ); |
|
7948 |
} |
|
7949 |
%} |
|
7950 |
. |
|
7951 |
self primitiveFailed |
|
7952 |
! |
|
7953 |
||
7954 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
7955 |
"set the windows border shape" |
|
7956 |
||
7957 |
hasShapeExtension ifFalse:[^ self]. |
|
7958 |
||
7959 |
%{ /* NOCONTEXT */ |
|
7960 |
||
7961 |
#ifdef SHAPE |
|
7962 |
if (__isExternalAddress(aWindowId) |
|
7963 |
&& __isExternalAddress(aPixmapId)) { |
|
7964 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
7965 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
7966 |
RETURN ( self ); |
|
7967 |
} |
|
7968 |
#endif |
|
7969 |
%}. |
|
7970 |
self primitiveFailed |
|
7971 |
! |
|
7972 |
||
7973 |
setWindowBorderWidth:aNumber in:aWindowId |
|
7974 |
"set the windows border width" |
|
7975 |
||
7976 |
%{ /* NOCONTEXT */ |
|
7977 |
||
7978 |
if (__isExternalAddress(aWindowId) |
|
7979 |
&& __isSmallInteger(aNumber)) { |
|
555 | 7980 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
295 | 7981 |
RETURN ( self ); |
7982 |
} |
|
7983 |
%}. |
|
7984 |
self primitiveFailed |
|
7985 |
! |
|
7986 |
||
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7987 |
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
|
7988 |
"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
|
7989 |
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
|
7990 |
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
|
7991 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7992 |
%{ |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7993 |
if (__isExternalAddress(aWindowId)) { |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7994 |
XClassHint classhint; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7995 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7996 |
classhint.res_class = classhint.res_name = 0; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7997 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7998 |
if (__isString(wClass) || __isSymbol(wClass)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
7999 |
classhint.res_class = (char *)_stringVal(wClass); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8000 |
} else if (wClass != nil) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8001 |
goto error; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8002 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8003 |
if (__isString(wName) || __isSymbol(wName)) { |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8004 |
classhint.res_name = (char *)_stringVal(wName); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8005 |
} else if (wName != nil) |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8006 |
goto error; |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8007 |
|
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8008 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
8009 |
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
|
8010 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8011 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8012 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8013 |
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
|
8014 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8015 |
|
295 | 8016 |
setWindowGravity:how in:aWindowId |
8017 |
"set window gravity for a window" |
|
8018 |
||
8019 |
%{ /* NOCONTEXT */ |
|
8020 |
||
8021 |
XSetWindowAttributes wa; |
|
8022 |
||
8023 |
if (__isExternalAddress(aWindowId)) { |
|
8024 |
if (how == @symbol(NorthWest)) { |
|
8025 |
wa.win_gravity = NorthWestGravity; |
|
8026 |
} else if (how == @symbol(NorthEast)) { |
|
8027 |
wa.win_gravity = NorthEastGravity; |
|
8028 |
} else if (how == @symbol(SouthWest)) { |
|
8029 |
wa.win_gravity = SouthWestGravity; |
|
8030 |
} else if (how == @symbol(SouthEast)) { |
|
8031 |
wa.win_gravity = SouthEastGravity; |
|
8032 |
} else if (how == @symbol(Center)) { |
|
8033 |
wa.win_gravity = CenterGravity; |
|
8034 |
} else if (how == @symbol(North)) { |
|
8035 |
wa.win_gravity = NorthGravity; |
|
8036 |
} else if (how == @symbol(South)) { |
|
8037 |
wa.win_gravity = SouthGravity; |
|
8038 |
} else if (how == @symbol(West)) { |
|
8039 |
wa.win_gravity = WestGravity; |
|
8040 |
} else if (how == @symbol(East)) { |
|
8041 |
wa.win_gravity = EastGravity; |
|
8042 |
} else { |
|
8043 |
wa.win_gravity = NorthWestGravity; |
|
8044 |
} |
|
8045 |
||
8046 |
BEGIN_INTERRUPTSBLOCKED |
|
8047 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8048 |
END_INTERRUPTSBLOCKED |
|
8049 |
RETURN ( self ); |
|
8050 |
} |
|
8051 |
%}. |
|
8052 |
self primitiveFailed |
|
8053 |
! |
|
8054 |
||
8055 |
setWindowIcon:aForm in:aWindowId |
|
8056 |
"define a bitmap to be used as icon" |
|
8057 |
||
8058 |
|iconId| |
|
8059 |
||
8060 |
aForm notNil ifTrue:[ |
|
8061 |
iconId := aForm id |
|
8062 |
]. |
|
8063 |
%{ |
|
8064 |
if (__isExternalAddress(iconId) |
|
8065 |
&& __isExternalAddress(aWindowId)) { |
|
8066 |
XWMHints hints; |
|
8067 |
||
8068 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8069 |
hints.flags = IconPixmapHint; |
|
8070 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8071 |
RETURN ( self ); |
|
8072 |
} |
|
8073 |
%}. |
|
8074 |
self primitiveFailed |
|
8075 |
! |
|
8076 |
||
8077 |
setWindowIconWindow:aView in:aWindowId |
|
8078 |
"define a window to be used as icon" |
|
8079 |
||
8080 |
|iconWindowId| |
|
8081 |
||
8082 |
aView notNil ifTrue:[ |
|
8083 |
iconWindowId := aView id |
|
8084 |
]. |
|
8085 |
%{ |
|
8086 |
if (__isExternalAddress(iconWindowId) |
|
8087 |
&& __isExternalAddress(aWindowId)) { |
|
8088 |
XWMHints wmhints; |
|
8089 |
||
8090 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
8091 |
wmhints.flags = IconWindowHint; |
|
8092 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
8093 |
RETURN ( self ); |
|
8094 |
} |
|
8095 |
%}. |
|
8096 |
self primitiveFailed |
|
8097 |
! |
|
8098 |
||
8099 |
setWindowName:aString in:aWindowId |
|
8100 |
"define a windows name" |
|
8101 |
||
8102 |
%{ /* NOCONTEXT */ |
|
8103 |
||
8104 |
if (__isExternalAddress(aWindowId) |
|
8105 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
8106 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
8107 |
RETURN ( self ); |
|
8108 |
} |
|
8109 |
%}. |
|
8110 |
self primitiveFailed |
|
8111 |
! |
|
8112 |
||
8113 |
setWindowShape:aPixmapId in:aWindowId |
|
8114 |
"set the windows shape" |
|
8115 |
||
8116 |
hasShapeExtension ifFalse:[^ self]. |
|
8117 |
||
8118 |
%{ /* NOCONTEXT */ |
|
8119 |
||
8120 |
#ifdef SHAPE |
|
8121 |
if (__isExternalAddress(aWindowId) |
|
8122 |
&& __isExternalAddress(aPixmapId)) { |
|
8123 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
8124 |
0, 0, |
|
8125 |
_PixmapVal(aPixmapId), ShapeSet); |
|
8126 |
RETURN ( self ); |
|
8127 |
} |
|
8128 |
#endif |
|
8129 |
%}. |
|
8130 |
self primitiveFailed |
|
8131 |
! |
|
8132 |
||
8133 |
unmapWindow:aWindowId |
|
8134 |
"make a window invisible" |
|
8135 |
||
8136 |
%{ /* NOCONTEXT */ |
|
8137 |
||
8138 |
if (__isExternalAddress(aWindowId)) { |
|
8139 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
8140 |
RETURN ( self ); |
|
8141 |
} |
|
8142 |
%} |
|
8143 |
. |
|
8144 |
self primitiveFailed |
|
8145 |
! ! |
|
8146 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
8147 |
!XWorkstation class methodsFor:'documentation'! |
295 | 8148 |
|
8149 |
version |
|
995
2f2c0b2bff1a
check fontStruct args - could be nil (but only if caller is wrong)
Claus Gittinger <cg@exept.de>
parents:
994
diff
changeset
|
8150 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.161 1996-07-24 11:50:07 cg Exp $' |
295 | 8151 |
! ! |
8152 |
XWorkstation initialize! |