author | Claus Gittinger <cg@exept.de> |
Wed, 02 Apr 1997 20:46:45 +0200 | |
changeset 1521 | 23aacd62bbac |
parent 1511 | 978a3b73b657 |
child 1533 | 18e7a458b625 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1344 | 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 |
|
1344 | 14 |
instanceVariableNames:'screen hasShapeExtension hasShmExtension hasDPSExtension |
15 |
hasMbufExtension hasXVideoExtension hasSaveUnder hasPEXExtension |
|
16 |
hasImageExtension hasInputExtension ignoreBackingStore blackpixel |
|
17 |
whitepixel protocolsAtom deleteWindowAtom saveYourselfAtom |
|
18 |
quitAppAtom primaryAtom secondaryAtom cutBuffer0Atom stringAtom |
|
19 |
lengthAtom listOfXFonts buttonsPressed eventRootX eventRootY |
|
20 |
displayName eventTrace dispatchingExpose rgbVisual virtualRootId |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
21 |
rootId eventBuffer altModifierMask metaModifierMask |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
22 |
multiClickTime' |
1344 | 23 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
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 |
|
1062 | 31 |
#ifdef LINUX |
32 |
# define SHM |
|
33 |
#endif |
|
34 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
35 |
#define COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
36 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
37 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
38 |
static int __cnt_color = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
39 |
static int __cnt_bitmap = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
40 |
static int __cnt_view = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
41 |
static int __cnt_gc = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
42 |
static int __cnt_cursor = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
43 |
static int __cnt_font = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
44 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
45 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
46 |
|
46 | 47 |
/* |
48 |
* x does a typedef Time - I need Object Time ... |
|
49 |
*/ |
|
0 | 50 |
#define Time XTime |
51 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
52 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
53 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
54 |
* 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
|
55 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
56 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
57 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
58 |
|
37 | 59 |
#ifdef memset |
60 |
# undef memset |
|
61 |
#endif |
|
62 |
||
0 | 63 |
#include <stdio.h> |
64 |
#include <X11/Xlib.h> |
|
65 |
#include <X11/Xutil.h> |
|
66 |
#include <X11/Xatom.h> |
|
67 |
||
150 | 68 |
#define XK_MISCELLANY |
69 |
#include <X11/keysymdef.h> |
|
70 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
71 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
72 |
|
90 | 73 |
/* |
74 |
* this define adds support for two-byte-strings. |
|
75 |
* leaving it undefined does not really save you much |
|
76 |
* (the define will vanish) |
|
77 |
*/ |
|
36 | 78 |
#define TWOBYTESTRINGS |
79 |
||
0 | 80 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
81 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
82 |
* 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
|
83 |
* 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
|
84 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
85 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
86 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
87 |
/* |
0 | 88 |
* shape support works; enabled by -DSHAPE in makefile |
89 |
* see RoundClock and RoundGlobe examples |
|
90 |
*/ |
|
91 |
#ifdef SHAPE |
|
92 |
# include <X11/extensions/shape.h> |
|
93 |
#endif |
|
94 |
||
95 |
/* |
|
150 | 96 |
* shared memory extension access is currently not supported |
0 | 97 |
* (only query is implemented) |
98 |
*/ |
|
99 |
#ifdef SHM |
|
100 |
# include <X11/extensions/XShm.h> |
|
101 |
#endif |
|
102 |
||
103 |
/* |
|
150 | 104 |
* multiBuffer extension access is currently not supported |
105 |
* (only query is implemented) |
|
106 |
*/ |
|
107 |
#ifdef MBUF |
|
108 |
# include <X11/extensions/multibuf.h> |
|
109 |
#endif |
|
110 |
||
111 |
/* |
|
112 |
* XVideo extension access is currently not supported |
|
113 |
* (only query is implemented) |
|
114 |
*/ |
|
115 |
#ifdef XVIDEO |
|
116 |
# include <X11/extensions/Xv.h> |
|
117 |
#endif |
|
118 |
||
119 |
/* |
|
186 | 120 |
* PEX extension - if available |
121 |
*/ |
|
122 |
#ifdef PEX5 |
|
123 |
# include <PEX5/PEX.h> |
|
124 |
#endif |
|
125 |
||
126 |
/* |
|
127 |
* XImage extension - if available |
|
128 |
*/ |
|
129 |
#ifdef XIE |
|
130 |
# include <X11/extensions/XIE.h> |
|
131 |
#endif |
|
132 |
||
133 |
/* |
|
90 | 134 |
* when I have more time to check it out, I will support display-PS |
0 | 135 |
*/ |
136 |
#ifdef DPS |
|
137 |
# ifdef sgi |
|
138 |
# include <X11/extensions/XDPS.h> |
|
139 |
# include <X11/extensions/XDPSlib.h> |
|
140 |
# include <X11/extensions/dpsXclient.h> |
|
141 |
# else |
|
142 |
# include <DPS/XDPS.h> |
|
143 |
# include <DPS/XDPSlib.h> |
|
144 |
# include <DPS/dpsXclient.h> |
|
145 |
# endif |
|
146 |
#endif |
|
147 |
||
90 | 148 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
149 |
/* |
|
150 |
* accessing private data in Display ... sorry |
|
151 |
*/ |
|
152 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
153 |
#else |
|
154 |
# define DISPLAYACCESS(d) d |
|
155 |
#endif |
|
156 |
||
78 | 157 |
/* |
158 |
* some defines - tired of typing ... |
|
159 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
160 |
#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
|
161 |
#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
|
162 |
#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
|
163 |
#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
|
164 |
#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
|
165 |
#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
|
166 |
#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
|
167 |
|
211 | 168 |
#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
|
169 |
#define _AtomVal(o) __intVal(o) |
211 | 170 |
#define __isAtomID(o) __isSmallInteger(o) |
171 |
||
555 | 172 |
#define myDpy _DisplayVal(__INST(displayId)) |
173 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 174 |
|
175 |
#ifndef THISCONTEXT_IN_REGISTER |
|
1098 | 176 |
|
78 | 177 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
178 |
# define END_INTERRUPTSBLOCKED /* */ |
|
1098 | 179 |
|
78 | 180 |
#else |
1098 | 181 |
|
78 | 182 |
# define BEGIN_INTERRUPTSBLOCKED \ |
183 |
{ \ |
|
1344 | 184 |
int needUnblock = 0; \ |
185 |
\ |
|
186 |
__BEGIN_PROTECT_REGISTERS__ \ |
|
187 |
if (!__interruptsBlocked) { \ |
|
188 |
__BLOCKINTERRUPTS(); \ |
|
189 |
needUnblock = 1; \ |
|
190 |
} |
|
78 | 191 |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
192 |
# define END_INTERRUPTSBLOCKED_NOW \ |
1344 | 193 |
__END_PROTECT_REGISTERS__ \ |
194 |
if (needUnblock) { \ |
|
195 |
__UNBLOCKINTERRUPTS(); \ |
|
196 |
} \ |
|
78 | 197 |
} |
198 |
||
1103
8378530a4e8d
XShmQueryExtension -> XQueryExtension
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
199 |
# define END_INTERRUPTSBLOCKED \ |
1344 | 200 |
__END_PROTECT_REGISTERS__ |
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
201 |
|
78 | 202 |
#endif |
203 |
%} |
|
204 |
! ! |
|
205 |
||
206 |
!XWorkstation primitiveVariables! |
|
207 |
%{ |
|
0 | 208 |
/* |
146 | 209 |
* remembered info from private error handler |
0 | 210 |
*/ |
2 | 211 |
static char lastErrorMsg[80] = ""; |
212 |
static unsigned lastRequestCode = 0; |
|
213 |
static unsigned lastMinorCode = 0; |
|
214 |
static unsigned lastResource = 0; |
|
129 | 215 |
|
216 |
static int __debug__ = 0; |
|
217 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 218 |
%} |
219 |
! ! |
|
220 |
||
221 |
!XWorkstation primitiveFunctions! |
|
222 |
%{ |
|
1062 | 223 |
|
1081 | 224 |
#ifdef __GNUC__ |
225 |
VOLATILE |
|
226 |
#endif |
|
227 |
||
228 |
static |
|
1062 | 229 |
dummyToForceLoading() { |
1344 | 230 |
XCreateSimpleWindow(0, 0, 0, 0, 0, 0, 0, 0, 0); |
231 |
XCloseDisplay(0); |
|
232 |
XCreateImage(0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0); |
|
233 |
XSetWindowColormap(0, 0, 0); |
|
234 |
XQueryColors(0,0,0,0); |
|
1062 | 235 |
#ifdef SHM |
1344 | 236 |
XShmAttach(0, 0); |
237 |
XShmCreateImage(0, 0, 0, 0, 0, 0, 0 ,0); |
|
238 |
XShmDetach(0, 0); |
|
239 |
XShmPutImage(0, 0, 0, 0 , 0,0,0,0,0,0,0); |
|
240 |
shmctl(0,0,0); |
|
241 |
fgetc(0); |
|
1062 | 242 |
#endif |
243 |
} |
|
244 |
||
18 | 245 |
/* |
144 | 246 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
247 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 248 |
* the implementation below is somewhat wrong: it will |
78 | 249 |
* report all errors for Display, even though there could be |
162 | 250 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
251 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 252 |
*/ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
253 |
|
12 | 254 |
__XErrorHandler__(dpy, event) |
0 | 255 |
Display *dpy; |
256 |
XErrorEvent *event; |
|
257 |
{ |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
258 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 79); |
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
259 |
lastErrorMsg[79] = '\0'; |
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
260 |
|
0 | 261 |
if (lastErrorMsg[0] == '\0') { |
1344 | 262 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 263 |
} |
2 | 264 |
lastRequestCode = event->request_code; |
265 |
lastMinorCode = event->minor_code; |
|
266 |
lastResource = event->resourceid; |
|
911 | 267 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
1344 | 268 |
/* |
269 |
* this is a BadWindow error for X_DestroyWindow. |
|
270 |
* ignore it here, since it results from the GC freeing windows |
|
271 |
* in non bottom-up window order. |
|
272 |
*/ |
|
273 |
return 0; |
|
911 | 274 |
} |
2 | 275 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
276 |
if (@global(ErrorPrinting) == true) { |
1344 | 277 |
fprintf(stderr, "XWorkstation [error]: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
278 |
event->request_code, event->request_code, |
|
279 |
event->minor_code, event->minor_code, event->resourceid); |
|
280 |
fprintf(stderr, "XWorkstation [error]: 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
|
281 |
} |
43 | 282 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
283 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 284 |
return 0; |
285 |
} |
|
286 |
||
90 | 287 |
#ifdef VIRTUAL_ROOT |
0 | 288 |
/* |
18 | 289 |
* added since RootWindow-macro is not suficient |
290 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
291 |
*/ |
|
292 |
static Window |
|
293 |
getRootWindow(dpy, screen) |
|
294 |
Display *dpy; |
|
295 |
{ |
|
296 |
Window root; |
|
297 |
Atom vRootAtom = None; |
|
298 |
int i; |
|
299 |
Window rootReturn, parentReturn; |
|
1050
b2c03e24d56c
another memoryLeak, due to an ommited XFree
Claus Gittinger <cg@exept.de>
parents:
1049
diff
changeset
|
300 |
Window* children = (Window *)0; |
18 | 301 |
unsigned int numChildren; |
302 |
||
303 |
root = RootWindow(dpy, screen); |
|
304 |
/* |
|
305 |
* on IRIS, this creates a badwindow error - why ? |
|
306 |
* children contains a funny window (000034) |
|
307 |
*/ |
|
90 | 308 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 309 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
1344 | 310 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
311 |
if (vRootAtom != None) { |
|
312 |
for (i=0; i < numChildren; i++) { |
|
313 |
Atom actual_type; |
|
314 |
int actual_format; |
|
315 |
unsigned long nitems, bytesafter; |
|
316 |
Window* newRoot = (Window*) 0; |
|
317 |
||
318 |
if (children[i]) { |
|
319 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
320 |
0L, 1L, False, XA_WINDOW, |
|
321 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
322 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
323 |
root = *newRoot; |
|
324 |
XFree(newRoot); /* XXX */ |
|
325 |
break; |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
} |
|
330 |
if (children) XFree( children ); |
|
18 | 331 |
} |
90 | 332 |
# endif |
18 | 333 |
return root; |
334 |
} |
|
90 | 335 |
#endif |
0 | 336 |
%} |
78 | 337 |
! ! |
0 | 338 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
339 |
!XWorkstation class methodsFor:'documentation'! |
295 | 340 |
|
341 |
copyright |
|
342 |
" |
|
343 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1344 | 344 |
All Rights Reserved |
295 | 345 |
|
346 |
This software is furnished under a license and may be used |
|
347 |
only in accordance with the terms of that license and with the |
|
348 |
inclusion of the above copyright notice. This software may not |
|
349 |
be provided or otherwise made available to, or used by, any |
|
350 |
other person. No title to or ownership of the software is |
|
351 |
hereby transferred. |
|
352 |
" |
|
353 |
! |
|
354 |
||
355 |
documentation |
|
356 |
" |
|
357 |
this class provides the interface to X11. It redefines all required methods |
|
358 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
359 |
limited to one display - in theory, you can create Views on many displays |
|
360 |
simultanously. However, the default setup is for one display only. |
|
361 |
To support multiple displays, you will have to start another event dispatcher |
|
362 |
process for the other display(s) and create the other views with a slightly |
|
363 |
different protocol. However, 'normal' applications do not have to care for |
|
364 |
all of this ... |
|
365 |
||
366 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 367 |
|
368 |
[author:] |
|
1344 | 369 |
Claus Gittinger |
295 | 370 |
" |
371 |
! ! |
|
372 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
373 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
374 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
375 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
376 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
377 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
378 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
379 |
|
386 | 380 |
RawKeysymTranslation isNil ifTrue:[ |
1344 | 381 |
"/ the following table maps X-keyevents to ST/X |
382 |
"/ device independed events. |
|
383 |
"/ It is NOT meant as a keyboardMap replacement. |
|
384 |
||
385 |
RawKeysymTranslation := d := Dictionary new. |
|
386 |
d at:'Delete_line' put:#DeleteLine. |
|
387 |
d at:'Delete_word' put:#DeleteWord. |
|
388 |
d at:'Down' put:#CursorDown. |
|
389 |
d at:'Up' put:#CursorUp. |
|
390 |
d at:'Left' put:#CursorLeft. |
|
391 |
d at:'Right' put:#CursorRight. |
|
386 | 392 |
] |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
393 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
394 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
395 |
!XWorkstation class methodsFor:'error handling'! |
2 | 396 |
|
129 | 397 |
debug:aBoolean |
398 |
%{ /* NOCONTEXT */ |
|
399 |
||
400 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
401 |
%} |
|
402 |
! |
|
403 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
404 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
405 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
406 |
#ifdef COUNT_RESOURCES |
1404 | 407 |
printf("colors:%d bitmaps:%d views:%d gc:%d cursors:%d fonts:%d\n", |
408 |
__cnt_color, __cnt_bitmap, |
|
409 |
__cnt_view, __cnt_gc, __cnt_cursor, __cnt_font); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
410 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
411 |
%} |
1404 | 412 |
|
413 |
" |
|
414 |
XWorkstation debugResources |
|
415 |
" |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
416 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
417 |
|
78 | 418 |
errorStringOfLastError |
419 |
%{ |
|
1065
fdc5b9059d82
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
420 |
RETURN ( __MKSTRING(lastErrorMsg) ); |
78 | 421 |
%} |
422 |
! |
|
423 |
||
135 | 424 |
lastErrorString |
2 | 425 |
"return the last X-error string - |
426 |
when buffering is on, this may be |
|
427 |
an error for a long-ago operation" |
|
78 | 428 |
|
429 |
|string requestCode s match line| |
|
430 |
||
431 |
string := self errorStringOfLastError. |
|
432 |
requestCode := self requestCodeOfLastError. |
|
433 |
" |
|
434 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
435 |
and append the name of the corresponding X-request |
|
436 |
" |
|
437 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
438 |
s notNil ifTrue:[ |
|
1344 | 439 |
match := 'XRequest.' , requestCode printString. |
440 |
line := s peekForLineStartingWith:match. |
|
441 |
line notNil ifTrue:[ |
|
442 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
443 |
]. |
|
444 |
s close. |
|
78 | 445 |
]. |
446 |
^ string |
|
295 | 447 |
! |
448 |
||
449 |
minorCodeOfLastError |
|
450 |
%{ /* NOCONTEXT */ |
|
451 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
452 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 453 |
%} |
454 |
! |
|
455 |
||
456 |
requestCodeOfLastError |
|
152 | 457 |
%{ /* NOCONTEXT */ |
458 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
459 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 460 |
%} |
135 | 461 |
! |
462 |
||
295 | 463 |
resourceIdOfLastError |
0 | 464 |
%{ /* NOCONTEXT */ |
295 | 465 |
|
466 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 467 |
%} |
468 |
! ! |
|
469 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
470 |
!XWorkstation class methodsFor:'queries'! |
104 | 471 |
|
472 |
platformName |
|
133 | 473 |
"ST-80 compatibility. |
474 |
Return a string describing the display systems platform." |
|
475 |
||
715 | 476 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
477 |
||
478 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 479 |
! ! |
480 |
||
0 | 481 |
!XWorkstation methodsFor:'accessing & queries'! |
482 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
483 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
484 |
"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
|
485 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
486 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
487 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
488 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
489 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
490 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
491 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
492 |
|
295 | 493 |
blackpixel |
494 |
"return the colornumber of black" |
|
495 |
||
496 |
^ blackpixel |
|
497 |
! |
|
498 |
||
499 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
500 |
"return the state-mask for button1 in motion events' state-field. |
295 | 501 |
For backward compatibility." |
502 |
||
503 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
504 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 505 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
506 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
507 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
508 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
509 |
" |
295 | 510 |
! |
511 |
||
512 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
513 |
"return the state-mask for button2 in motion events' state-field |
295 | 514 |
For backward compatibility." |
515 |
||
516 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
517 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 518 |
%} |
519 |
! |
|
520 |
||
521 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
522 |
"return the state-mask for button3 in motion events' state-field |
295 | 523 |
For backward compatibility." |
524 |
||
525 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
526 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 527 |
%} |
528 |
! |
|
529 |
||
530 |
buttonMotionMask:aButton |
|
531 |
"return the state-mask for button1 in motion events state-field. |
|
532 |
This is the devices mask." |
|
533 |
||
534 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
535 |
if (aButton == __MKSMALLINT(1)) { |
1344 | 536 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
537 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
538 |
if (aButton == __MKSMALLINT(2)) { |
1344 | 539 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
540 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
541 |
if (aButton == __MKSMALLINT(3)) { |
1344 | 542 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 543 |
} |
544 |
%}. |
|
545 |
^ nil |
|
546 |
! |
|
547 |
||
382 | 548 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
549 |
"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
|
550 |
|
382 | 551 |
%{ /* NOCONTEXT */ |
552 |
RETURN (__MKSMALLINT(ControlMask)); |
|
553 |
%} |
|
554 |
! |
|
555 |
||
295 | 556 |
defaultEventMask |
557 |
"return a mask to enable some events by default." |
|
558 |
||
559 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
560 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
1344 | 561 |
KeyPressMask | KeyReleaseMask | |
562 |
EnterWindowMask | LeaveWindowMask | |
|
563 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
295 | 564 |
%} |
565 |
! |
|
566 |
||
0 | 567 |
displayFileDescriptor |
568 |
"return the displays fileNumber - for select" |
|
569 |
||
570 |
%{ /* NOCONTEXT */ |
|
571 |
||
150 | 572 |
if (ISCONNECTED) { |
1344 | 573 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 574 |
} |
575 |
RETURN (nil); |
|
0 | 576 |
%} |
577 |
! |
|
578 |
||
133 | 579 |
displayName |
580 |
"return the X-connections display name. |
|
581 |
This is (currently) nil for the default display, |
|
582 |
something like foo:0 for any other remote display. |
|
583 |
Future versions may return non-nil strings for the default display as well." |
|
584 |
||
585 |
^ displayName |
|
586 |
! |
|
587 |
||
341 | 588 |
protocolVersion |
589 |
"return the X-servers protocol version - should normally not be of |
|
590 |
any interest" |
|
591 |
||
592 |
%{ /* NOCONTEXT */ |
|
593 |
if (ISCONNECTED) { |
|
1344 | 594 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
341 | 595 |
} |
596 |
RETURN (nil); |
|
597 |
%} |
|
598 |
||
599 |
" |
|
600 |
Display protocolVersion |
|
601 |
" |
|
602 |
! |
|
603 |
||
604 |
serverVendor |
|
605 |
"return the X-server vendor string - this should normally not be of |
|
606 |
any interest, but can be for special cases |
|
607 |
(to avoid bugs in certain implementations)" |
|
608 |
%{ |
|
609 |
if (ISCONNECTED) { |
|
1344 | 610 |
RETURN ( __MKSTRING(XServerVendor(myDpy)) ); |
341 | 611 |
} |
612 |
RETURN (nil); |
|
613 |
%} |
|
614 |
||
615 |
" |
|
616 |
Display serverVendor |
|
617 |
" |
|
618 |
! |
|
619 |
||
382 | 620 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
621 |
"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
|
622 |
|
382 | 623 |
%{ /* NOCONTEXT */ |
624 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
625 |
%} |
|
626 |
! |
|
627 |
||
341 | 628 |
translatePoint:aPoint from:windowId1 to:windowId2 |
629 |
"given a point in window1, return the coordinate in window2. |
|
630 |
This expects a device coordinate (relative to the first views origin) |
|
631 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
632 |
- use to xlate points from a window to rootwindow" |
|
633 |
||
634 |
|x1 y1 x2 y2| |
|
635 |
||
636 |
x1 := x2 := aPoint x truncated. |
|
637 |
y1 := y2 := aPoint y truncated. |
|
638 |
%{ |
|
639 |
int xpos, ypos; |
|
640 |
Window w1, w2, child_return; |
|
555 | 641 |
int screen = __intVal(__INST(screen)); |
1209 | 642 |
|
643 |
if (ISCONNECTED |
|
644 |
&& __isExternalAddress(windowId1) |
|
341 | 645 |
&& __isExternalAddress(windowId2) |
646 |
&& __bothSmallInteger(x1, y1)) { |
|
1344 | 647 |
Display *dpy = myDpy; |
648 |
||
649 |
w1 = _WindowVal(windowId1); |
|
650 |
w2 = _WindowVal(windowId2); |
|
341 | 651 |
#ifdef VIRTUAL_ROOT |
1344 | 652 |
if ((w1 == RootWindow(dpy, screen)) |
653 |
|| (w2 == RootWindow(dpy, screen))) { |
|
654 |
if (w1 == RootWindow(dpy, screen)) { |
|
655 |
w1 = getRootWindow(dpy, screen); |
|
656 |
} |
|
657 |
if (w2 == RootWindow(dpy, screen)) { |
|
658 |
w2 = getRootWindow(dpy, screen); |
|
659 |
} |
|
660 |
} |
|
341 | 661 |
#endif |
1344 | 662 |
BEGIN_INTERRUPTSBLOCKED |
663 |
XTranslateCoordinates(dpy, w1, w2, |
|
664 |
__intVal(x1), __intVal(y1), |
|
665 |
&xpos, &ypos, &child_return); |
|
666 |
END_INTERRUPTSBLOCKED |
|
667 |
x2 = __MKSMALLINT(xpos); |
|
668 |
y2 = __MKSMALLINT(ypos); |
|
341 | 669 |
} |
670 |
%}. |
|
671 |
||
672 |
^ (x2 @ y2) |
|
673 |
! |
|
674 |
||
675 |
vendorRelease |
|
676 |
"return the X-servers vendor release - should normally not be of |
|
677 |
any interest, but can be for special cases. |
|
678 |
(to avoid bugs in certain implementations)" |
|
679 |
||
680 |
%{ /* NOCONTEXT */ |
|
681 |
if (ISCONNECTED) { |
|
1344 | 682 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
341 | 683 |
} |
684 |
RETURN (nil); |
|
685 |
%} |
|
686 |
||
687 |
" |
|
688 |
Display vendorRelease |
|
689 |
" |
|
690 |
! |
|
691 |
||
692 |
viewIdFromPoint:aPoint in:windowId |
|
693 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
694 |
hit by this coordinate. Return nil if no view was hit. |
|
695 |
The returned id may be the id of a non ST view. |
|
696 |
- used to find the window to drop objects after a cross-view drag." |
|
697 |
||
698 |
%{ /* NOCONTEXT */ |
|
699 |
||
555 | 700 |
int screen = __intVal(__INST(screen)); |
341 | 701 |
OBJ xp, yp; |
702 |
int xpos, ypos; |
|
703 |
Window child_return; |
|
704 |
||
1209 | 705 |
if (ISCONNECTED |
706 |
&& __isExternalAddress(windowId) |
|
341 | 707 |
&& __isPoint(aPoint)) { |
1344 | 708 |
Display *dpy = myDpy; |
709 |
||
710 |
xp = _point_X(aPoint); |
|
711 |
yp = _point_Y(aPoint); |
|
712 |
if (__bothSmallInteger(xp, yp)) { |
|
713 |
BEGIN_INTERRUPTSBLOCKED |
|
714 |
XTranslateCoordinates(dpy, |
|
715 |
RootWindow(dpy, screen), |
|
716 |
_WindowVal(windowId), |
|
717 |
__intVal(xp), __intVal(yp), |
|
718 |
&xpos, &ypos, &child_return); |
|
719 |
END_INTERRUPTSBLOCKED |
|
720 |
if (child_return) { |
|
721 |
RETURN ( __MKOBJ(child_return) ); |
|
722 |
} |
|
723 |
RETURN ( nil ); |
|
724 |
} |
|
341 | 725 |
} |
726 |
%}. |
|
727 |
windowId notNil ifTrue:[ |
|
1344 | 728 |
aPoint isPoint ifTrue:[ |
729 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
730 |
] |
|
341 | 731 |
]. |
732 |
||
733 |
^ nil |
|
734 |
! |
|
735 |
||
736 |
virtualExtent |
|
737 |
"return the virtual extent of the display (in pixels). |
|
738 |
On most systems, this is the same as the physical width; |
|
739 |
except, if a window manager with a virtual desktop like olvwm |
|
740 |
(simulating a bigger screen) is running." |
|
741 |
||
742 |
%{ |
|
1209 | 743 |
if (ISCONNECTED |
744 |
&& (__INST(rootId) != __INST(virtualRootId)) |
|
555 | 745 |
&& __isExternalAddress(__INST(virtualRootId))) { |
1344 | 746 |
Window vRootWin; |
747 |
Window root; |
|
748 |
int x, y; |
|
749 |
unsigned int width, height; |
|
750 |
unsigned int dummy; |
|
751 |
||
752 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
|
753 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
754 |
&dummy, &dummy)) { |
|
755 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
756 |
} |
|
341 | 757 |
} |
758 |
%}. |
|
759 |
^ width @ height |
|
760 |
! |
|
761 |
||
762 |
whitepixel |
|
763 |
"return the colornumber of white" |
|
764 |
||
765 |
^ whitepixel |
|
766 |
! ! |
|
767 |
||
768 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
769 |
||
0 | 770 |
hasDPS |
186 | 771 |
"return true, if this workstation supports display postscript. |
772 |
Both the server must support it, and the feature must have been |
|
773 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 774 |
|
775 |
^ hasDPSExtension |
|
186 | 776 |
|
777 |
" |
|
778 |
Display hasDPS |
|
779 |
" |
|
780 |
! |
|
781 |
||
150 | 782 |
hasExtension:extensionString |
783 |
"query for an X extension. The argument, extensionString |
|
784 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 785 |
Return true, if that extension is available in the server. |
786 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 787 |
|
788 |
%{ |
|
789 |
int dummy; |
|
790 |
||
791 |
if (__isString(extensionString) && ISCONNECTED) { |
|
1344 | 792 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
793 |
RETURN ( true ); |
|
794 |
} |
|
150 | 795 |
} |
796 |
%}. |
|
797 |
^ false |
|
186 | 798 |
|
799 |
" |
|
800 |
Display hasExtension:'XVideo' |
|
801 |
Display hasExtension:'Input' |
|
802 |
Display hasExtension:'GLX' |
|
803 |
Display hasExtension:'X3D-PEX' |
|
804 |
Display hasExtension:'XInputExtension' |
|
805 |
Display hasExtension:'SHAPE' |
|
806 |
Display hasExtension:'MIT-SHM' |
|
807 |
Display hasExtension:'SGIFullScreenStereo' |
|
808 |
" |
|
150 | 809 |
! |
810 |
||
295 | 811 |
hasImageExtension |
812 |
"return true, if this workstation supports the X image extension. |
|
813 |
Both the server must support it, and the feature must have been |
|
814 |
enabled in the smalltalk system, for true to be returned." |
|
815 |
||
816 |
^ hasImageExtension |
|
817 |
||
818 |
" |
|
819 |
Display hasImageExtension |
|
820 |
" |
|
821 |
! |
|
822 |
||
823 |
hasInputExtension |
|
824 |
"return true, if this workstation supports the X input extension. |
|
825 |
Both the server must support it, and the feature must have been |
|
826 |
enabled in the smalltalk system, for true to be returned." |
|
827 |
||
828 |
^ hasInputExtension |
|
829 |
||
830 |
" |
|
831 |
Display hasInputExtension |
|
832 |
" |
|
833 |
! |
|
834 |
||
835 |
hasMultibuffer |
|
836 |
"return true, if this workstation supports the multibuffer extension. |
|
837 |
Both the server must support it, and the feature must have been |
|
838 |
enabled in the smalltalk system, for true to be returned." |
|
839 |
||
840 |
^ hasMbufExtension |
|
841 |
||
842 |
" |
|
843 |
Display hasMultibuffer |
|
844 |
" |
|
845 |
! |
|
846 |
||
847 |
hasPEX |
|
848 |
"return true, if this workstation supports PEX 3D graphics. |
|
849 |
Both the server must support it, and the feature must have been |
|
850 |
enabled in the smalltalk system, for true to be returned." |
|
851 |
||
852 |
^ hasPEXExtension |
|
853 |
||
854 |
" |
|
855 |
Display hasPEX |
|
856 |
" |
|
857 |
! |
|
858 |
||
859 |
hasShape |
|
860 |
"return true, if this workstation supports non-rectangular windows. |
|
861 |
Both the server must support it, and the feature must have been |
|
862 |
enabled in the smalltalk system, for true to be returned." |
|
863 |
||
864 |
^ hasShapeExtension |
|
865 |
||
866 |
" |
|
867 |
Display hasShape |
|
868 |
" |
|
869 |
! |
|
870 |
||
871 |
hasShm |
|
872 |
"return true, if this workstation supports the shared pixmap extension. |
|
873 |
Both the server must support it, and the feature must have been |
|
874 |
enabled in the smalltalk system, for true to be returned." |
|
875 |
||
876 |
^ hasShmExtension |
|
877 |
||
878 |
" |
|
879 |
Display hasShm |
|
880 |
" |
|
881 |
! |
|
882 |
||
883 |
hasXVideo |
|
884 |
"return true, if this workstation supports the XVideo extension. |
|
885 |
Both the server must support it, and the feature must have been |
|
886 |
enabled in the smalltalk system, for true to be returned." |
|
887 |
||
888 |
^ hasXVideoExtension |
|
889 |
||
890 |
" |
|
891 |
Display hasXVideo |
|
892 |
" |
|
893 |
! |
|
894 |
||
895 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
896 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 897 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 898 |
|
899 |
|xIconSizes count ret| |
|
900 |
||
901 |
%{ |
|
555 | 902 |
int screen = __intVal(__INST(screen)); |
295 | 903 |
XIconSize *sizeList; |
904 |
int cnt; |
|
905 |
||
906 |
if (ISCONNECTED) { |
|
1344 | 907 |
Display *dpy = myDpy; |
908 |
||
909 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
|
910 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
911 |
count = __MKSMALLINT(cnt); |
|
912 |
} |
|
295 | 913 |
} |
914 |
%}. |
|
915 |
xIconSizes isNil ifTrue:[^ nil]. |
|
916 |
||
917 |
ret := OrderedCollection new:count. |
|
918 |
1 to:count do:[ :i | |
|
1344 | 919 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 920 |
|
921 |
%{ |
|
1344 | 922 |
XIconSize *slp; |
923 |
||
924 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
925 |
minWidth = __MKSMALLINT(slp->min_width); |
|
926 |
minHeight = __MKSMALLINT(slp->min_height); |
|
927 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
928 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
929 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
930 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 931 |
%}. |
1344 | 932 |
d := IdentityDictionary new. |
933 |
d at:#minWidth put:minWidth. |
|
934 |
d at:#maxWidth put:maxWidth. |
|
935 |
d at:#widthStep put:widthStep. |
|
936 |
d at:#minHeight put:minHeight. |
|
937 |
d at:#maxHeight put:maxHeight. |
|
938 |
d at:#heightStep put:heightStep. |
|
939 |
||
940 |
ret add:d |
|
295 | 941 |
]. |
942 |
||
943 |
xIconSizes free. |
|
944 |
^ ret |
|
945 |
||
946 |
" |
|
819 | 947 |
Display iconSizes |
295 | 948 |
" |
949 |
! |
|
950 |
||
341 | 951 |
ignoreBackingStore:aBoolean |
952 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
953 |
no backing store used - this can be used on servers where backing store is |
|
954 |
very slow or is broken (can be put into display-rc-file)" |
|
955 |
||
956 |
ignoreBackingStore := aBoolean |
|
295 | 957 |
! |
958 |
||
823 | 959 |
preferredIconSize |
960 |
"return the displays preferred size for icons. |
|
961 |
Redefined to return a special value on SGI servers." |
|
962 |
||
963 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
1344 | 964 |
^ 86@68 |
823 | 965 |
]. |
966 |
^ super preferredIconSize |
|
967 |
||
968 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
969 |
! |
|
970 |
||
1025 | 971 |
scrollsAsynchronous |
1008
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
972 |
"return true, if this display asynchronously sends expose events after a |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
973 |
scroll operation. False otherwise. Asynchronous expose events are an X |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
974 |
speciality, which affects a few methods outside of the display class (sorry)" |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
975 |
|
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
976 |
^ true |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
977 |
! |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
978 |
|
43 | 979 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
980 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
981 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
982 |
depth, bitsPerPixel and padding values." |
43 | 983 |
|
150 | 984 |
|nFormats "{ Class: SmallInteger }" |
985 |
formatArray| |
|
43 | 986 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
987 |
Display *dpy; |
150 | 988 |
|
989 |
if (! ISCONNECTED) { |
|
1344 | 990 |
RETURN (nil); |
150 | 991 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
992 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
993 |
dpy = myDpy; |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
994 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 995 |
%}. |
996 |
formatArray := Array new:nFormats. |
|
150 | 997 |
1 to:nFormats do:[:index | |
1344 | 998 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
999 |
||
1000 |
i := index. |
|
43 | 1001 |
%{ |
1344 | 1002 |
ScreenFormat *format; |
1003 |
Display *dpy = myDpy; |
|
1004 |
||
1005 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
|
1006 |
format += (__intVal(i)-1); |
|
1007 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
|
1008 |
depthInfo = __MKSMALLINT(format->depth); |
|
1009 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
|
43 | 1010 |
%}. |
1344 | 1011 |
info := IdentityDictionary new. |
1012 |
info at:#depth put:depthInfo. |
|
1013 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
|
1014 |
info at:#padding put:paddingInfo. |
|
1015 |
formatArray at:index put:info. |
|
43 | 1016 |
]. |
1017 |
^ formatArray |
|
1018 |
||
1019 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1020 |
Display supportedImageFormats |
43 | 1021 |
" |
1022 |
! |
|
1023 |
||
823 | 1024 |
supportsIconViews |
1025 |
"return true, if this device supports views as icons. |
|
1026 |
Only Xservers (currently) support this." |
|
1027 |
||
1028 |
^ true |
|
1029 |
||
1030 |
" |
|
1031 |
Display supportsIconViews |
|
1032 |
" |
|
1033 |
||
1034 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1035 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1036 |
! |
|
1037 |
||
81 | 1038 |
supportsViewGravity |
1039 |
"return true, if this device supports gravity attributes. |
|
82 | 1040 |
We do not depend on it being implemented, but some resizing operations |
81 | 1041 |
are faster, it is is." |
1042 |
||
1043 |
^ true |
|
0 | 1044 |
! ! |
1045 |
||
1046 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1047 |
||
295 | 1048 |
createBitmapFromArray:anArray width:w height:h |
1049 |
|bitmapId| |
|
1050 |
||
1051 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1052 |
bitmapId isNil ifTrue:[ |
|
1344 | 1053 |
self primitiveFailed |
295 | 1054 |
]. |
1055 |
^ bitmapId |
|
1056 |
! |
|
1057 |
||
1058 |
createBitmapFromFile:aString for:aForm |
|
1059 |
|id w h| |
|
1060 |
||
1061 |
%{ |
|
555 | 1062 |
int screen = __intVal(__INST(screen)); |
295 | 1063 |
Pixmap newBitmap; |
1064 |
char *filename; |
|
1065 |
unsigned b_width, b_height; |
|
1066 |
int b_x_hot, b_y_hot; |
|
1067 |
int status; |
|
1068 |
||
1069 |
if (ISCONNECTED) { |
|
1344 | 1070 |
Display *dpy = myDpy; |
1071 |
||
1072 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1073 |
filename = (char *)_stringVal(aString); |
|
1074 |
||
1075 |
BEGIN_INTERRUPTSBLOCKED |
|
1076 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1077 |
filename, &b_width, &b_height, &newBitmap, |
|
1078 |
&b_x_hot, &b_y_hot); |
|
1079 |
END_INTERRUPTSBLOCKED |
|
1080 |
||
1081 |
if ((status == BitmapSuccess) && newBitmap) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1082 |
#ifdef COUNT_RESOURCES |
1344 | 1083 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1084 |
#endif |
1344 | 1085 |
w = __MKSMALLINT(b_width); |
1086 |
h = __MKSMALLINT(b_height); |
|
1087 |
id = __MKOBJ(newBitmap); |
|
1088 |
} |
|
1089 |
} |
|
295 | 1090 |
} |
1091 |
%}. |
|
1092 |
id notNil ifTrue:[ |
|
1344 | 1093 |
aForm setWidth:w height:h |
295 | 1094 |
]. |
1095 |
^ id |
|
1096 |
! |
|
1097 |
||
1098 |
createBitmapWidth:w height:h |
|
1099 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1100 |
(i.e. random). Return a bitmap id or nil" |
|
1101 |
||
1102 |
%{ /* NOCONTEXT */ |
|
1103 |
||
555 | 1104 |
int screen = __intVal(__INST(screen)); |
295 | 1105 |
Pixmap newBitmap; |
1106 |
||
1107 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1344 | 1108 |
Display *dpy = myDpy; |
1109 |
||
1110 |
BEGIN_INTERRUPTSBLOCKED |
|
1111 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1112 |
__intVal(w), __intVal(h), 1); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1113 |
#ifdef COUNT_RESOURCES |
1344 | 1114 |
if (newBitmap) |
1115 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1116 |
#endif |
1344 | 1117 |
END_INTERRUPTSBLOCKED |
1118 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
295 | 1119 |
} |
1120 |
%} |
|
1121 |
. |
|
1122 |
self primitiveFailed. |
|
1123 |
^ nil |
|
1124 |
! |
|
1125 |
||
0 | 1126 |
createPixmapWidth:w height:h depth:d |
1127 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1128 |
(i.e. random). Return a bitmap id or nil" |
|
1129 |
||
1130 |
%{ /* NOCONTEXT */ |
|
1131 |
||
555 | 1132 |
int screen = __intVal(__INST(screen)); |
0 | 1133 |
Pixmap newBitmap; |
1134 |
||
150 | 1135 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
1344 | 1136 |
Display *dpy = myDpy; |
1137 |
||
1138 |
BEGIN_INTERRUPTSBLOCKED |
|
1139 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1140 |
__intVal(w), __intVal(h), __intVal(d)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1141 |
#ifdef COUNT_RESOURCES |
1344 | 1142 |
if (newBitmap) |
1143 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1144 |
#endif |
1344 | 1145 |
END_INTERRUPTSBLOCKED |
1146 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1147 |
} |
1424 | 1148 |
%}. |
43 | 1149 |
self primitiveFailed. |
1150 |
^ nil |
|
0 | 1151 |
! |
1152 |
||
1468
9832c4017a70
added type argument to createWindowFor - prepare for native window support (windows)
Claus Gittinger <cg@exept.de>
parents:
1462
diff
changeset
|
1153 |
createWindowFor:aView type:typeSymbol |
1344 | 1154 |
origin:origin |
1155 |
extent:extent |
|
1156 |
minExtent:minExt |
|
1157 |
maxExtent:maxExt |
|
1158 |
borderWidth:bWidth |
|
1159 |
subViewOf:wsuperView |
|
1160 |
onTop:wisPopUpView |
|
1161 |
inputOnly:winputOnly |
|
1162 |
label:wlabel |
|
1163 |
cursor:wcursor |
|
1424 | 1164 |
icon:wicon iconMask:wiconMask |
1344 | 1165 |
iconView:wiconView |
46 | 1166 |
|
1167 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1424 | 1168 |
bColorId wsuperViewId wcursorId wiconId wiconMaskId windowId |
46 | 1169 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
150 | 1170 |
vBgForm deepForm preferredVisual preferredDepth| |
1171 |
||
1172 |
displayId isNil ifTrue:[ |
|
1344 | 1173 |
self primitiveFailed. |
1174 |
^ nil |
|
150 | 1175 |
]. |
0 | 1176 |
|
46 | 1177 |
origin notNil ifTrue:[ |
1344 | 1178 |
xpos := origin x. |
1179 |
ypos := origin y. |
|
46 | 1180 |
] ifFalse:[ |
1344 | 1181 |
xpos := ypos := 0. |
0 | 1182 |
]. |
46 | 1183 |
extent notNil ifTrue:[ |
1344 | 1184 |
wwidth := extent x. |
1185 |
wheight := extent y. |
|
46 | 1186 |
] ifFalse:[ |
1344 | 1187 |
wwidth := wheight := 100. |
46 | 1188 |
]. |
1189 |
minExt notNil ifTrue:[ |
|
1344 | 1190 |
minWidth := minExt x. |
1191 |
minHeight := minExt y |
|
0 | 1192 |
]. |
46 | 1193 |
maxExt notNil ifTrue:[ |
1344 | 1194 |
maxWidth := maxExt x. |
1195 |
maxHeight := maxExt y |
|
46 | 1196 |
]. |
1197 |
||
0 | 1198 |
wsuperView notNil ifTrue:[ |
1344 | 1199 |
wsuperViewId := wsuperView id |
0 | 1200 |
]. |
1201 |
wcursor isNil ifTrue:[ |
|
1344 | 1202 |
'XWorkstation [info]: cursor nil - defaulted' infoPrintCR |
0 | 1203 |
] ifFalse:[ |
1344 | 1204 |
wcursorId := wcursor id |
0 | 1205 |
]. |
1206 |
||
1207 |
wicon notNil ifTrue:[ |
|
1424 | 1208 |
wiconId := wicon id. |
1209 |
wiconMask notNil ifTrue:[ |
|
1210 |
wiconMaskId := wiconMask id |
|
1211 |
] |
|
0 | 1212 |
]. |
1213 |
wiconView notNil ifTrue:[ |
|
1344 | 1214 |
wiconViewId := wiconView id |
0 | 1215 |
]. |
1216 |
weventMask := aView eventMask. |
|
1217 |
||
150 | 1218 |
preferredVisual := aView preferredVisual. |
1219 |
preferredDepth := aView preferredDepth. |
|
23 | 1220 |
|
72 | 1221 |
%{ /* STACK:16000 */ |
0 | 1222 |
Display *dpy = myDpy; |
555 | 1223 |
int screen = __intVal(__INST(screen)); |
0 | 1224 |
Visual visual; |
1225 |
XGCValues xgcv; |
|
1226 |
XSetWindowAttributes xswa; |
|
1227 |
XSizeHints sizehints; |
|
1228 |
XWMHints wmhints; |
|
46 | 1229 |
int bw, bd, bg; |
0 | 1230 |
Window newWindow, parentWindow; |
1231 |
char *windowName; |
|
1232 |
XFontStruct *f; |
|
1233 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1234 |
int flags = 0, depth, ioClass; |
|
1235 |
Window iconWindow; |
|
1236 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1237 |
Atom WmQuitAppAtom; |
|
1238 |
Atom atoms[3]; |
|
1239 |
int atomCount = 0, isTopWindow = 0; |
|
1240 |
||
1241 |
sizehints.flags = 0; |
|
1242 |
sizehints.width = 100; |
|
1243 |
sizehints.height = 100; |
|
1244 |
sizehints.x = 0; |
|
1245 |
sizehints.y = 0; |
|
1246 |
||
97 | 1247 |
if (__bothSmallInteger(wwidth, wheight)) { |
1344 | 1248 |
sizehints.flags |= PSize; |
1249 |
sizehints.width = __intVal(wwidth); |
|
1250 |
sizehints.height = __intVal(wheight); |
|
0 | 1251 |
} |
97 | 1252 |
if (__bothSmallInteger(xpos, ypos)) { |
1344 | 1253 |
sizehints.flags |= PPosition; |
1254 |
sizehints.x = __intVal(xpos); |
|
1255 |
sizehints.y = __intVal(ypos); |
|
0 | 1256 |
} |
97 | 1257 |
if (__bothSmallInteger(minWidth, minHeight)) { |
1344 | 1258 |
sizehints.flags |= PMinSize; |
1259 |
sizehints.min_width = __intVal(minWidth); |
|
1260 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1261 |
} |
97 | 1262 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
1344 | 1263 |
sizehints.flags |= PMaxSize; |
1264 |
sizehints.max_width = __intVal(maxWidth); |
|
1265 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1266 |
} |
1267 |
||
37 | 1268 |
bg = WhitePixel(dpy, screen); |
0 | 1269 |
|
97 | 1270 |
if (__isSmallInteger(bWidth)) { |
1344 | 1271 |
bw = __intVal(bWidth); |
46 | 1272 |
} else { |
1344 | 1273 |
bw = 0; |
0 | 1274 |
} |
1275 |
||
72 | 1276 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1277 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1278 |
if (__isExternalAddress(wsuperViewId)) { |
1344 | 1279 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1280 |
} else { |
1344 | 1281 |
parentWindow = RootWindow(dpy, screen); |
1282 |
isTopWindow = 1; |
|
0 | 1283 |
} |
1284 |
||
157 | 1285 |
if (wisPopUpView == true) |
1344 | 1286 |
xswa.override_redirect = 1; |
0 | 1287 |
else |
1344 | 1288 |
xswa.override_redirect = 0; |
0 | 1289 |
|
1290 |
if (winputOnly == true) |
|
1344 | 1291 |
ioClass = InputOnly; |
0 | 1292 |
else |
1344 | 1293 |
ioClass = InputOutput; |
0 | 1294 |
|
97 | 1295 |
if (__isSmallInteger(weventMask)) { |
1344 | 1296 |
xswa.event_mask = __intVal(weventMask); |
0 | 1297 |
} else { |
1344 | 1298 |
xswa.event_mask = 0; |
0 | 1299 |
} |
1300 |
||
1301 |
if (ioClass == InputOnly) { |
|
1344 | 1302 |
bw = 0; |
1303 |
depth = 0; |
|
1304 |
flags |= CWEventMask; |
|
0 | 1305 |
} else { |
1344 | 1306 |
depth = DefaultDepth(dpy,screen); |
1307 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1308 |
||
1309 |
if (backPixmap != (Pixmap)0) { |
|
1310 |
xswa.background_pixmap = backPixmap; |
|
1311 |
flags |= CWBackPixmap; |
|
1312 |
} else { |
|
1313 |
xswa.background_pixel = bg; |
|
1314 |
flags |= CWBackPixel; |
|
1315 |
} |
|
1316 |
xswa.border_pixel = bd; |
|
0 | 1317 |
} |
23 | 1318 |
|
0 | 1319 |
visual.visualid = CopyFromParent; |
150 | 1320 |
if (__isSmallInteger(preferredDepth)) { |
1344 | 1321 |
depth = __intVal(preferredDepth); |
23 | 1322 |
} |
54 | 1323 |
|
1324 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1325 |
if (preferredVisual != nil) { |
1344 | 1326 |
XVisualInfo vi; |
1327 |
int cls; |
|
1328 |
||
1329 |
if (preferredVisual == @symbol(StaticGray)) |
|
1330 |
cls = StaticGray; |
|
1331 |
else if (preferredVisual == @symbol(GrayScale)) |
|
1332 |
cls = GrayScale; |
|
1333 |
else if (preferredVisual == @symbol(StaticColor)) |
|
1334 |
cls = StaticColor; |
|
1335 |
else if (preferredVisual == @symbol(PseudoColor)) |
|
1336 |
cls = PseudoColor; |
|
1337 |
else if (preferredVisual == @symbol(TrueColor)) |
|
1338 |
cls = TrueColor; |
|
1339 |
else if (preferredVisual == @symbol(DirectColor)) |
|
1340 |
cls = DirectColor; |
|
1341 |
else |
|
1342 |
cls = PseudoColor; |
|
1343 |
||
1344 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
|
1345 |
visual.visualid = vi.visualid; |
|
163 | 1346 |
/* |
1344 | 1347 |
printf("visualId=%x\n", vi.visualid); |
163 | 1348 |
*/ |
1344 | 1349 |
} |
23 | 1350 |
} |
0 | 1351 |
|
1352 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
1344 | 1353 |
sizehints.x, sizehints.y, |
1354 |
sizehints.width, sizehints.height, |
|
1355 |
bw, depth, ioClass, &visual, |
|
1356 |
flags, &xswa); |
|
54 | 1357 |
END_INTERRUPTSBLOCKED |
0 | 1358 |
|
1359 |
if (! newWindow) { |
|
1344 | 1360 |
RETURN ( nil ); |
0 | 1361 |
} |
1362 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1363 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1364 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1365 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1366 |
|
54 | 1367 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1368 |
/* |
1369 |
* define its cursor |
|
1370 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1371 |
if (__isExternalAddress(wcursorId)) { |
1344 | 1372 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1373 |
} |
1374 |
||
1375 |
/* |
|
1376 |
* define its icon and name |
|
1377 |
* (only makes sense for topWindows) |
|
1378 |
*/ |
|
1379 |
if (isTopWindow) { |
|
1344 | 1380 |
if (__isExternalAddress(wiconId)) |
1381 |
iconBitmap = _PixmapVal(wiconId); |
|
1382 |
else |
|
1383 |
iconBitmap = (Pixmap)0; |
|
1384 |
||
1385 |
if (__isExternalAddress(wiconViewId)) |
|
1386 |
iconWindow = _WindowVal(wiconViewId); |
|
1387 |
else |
|
1388 |
iconWindow = (Window)0; |
|
1389 |
||
1390 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1391 |
windowName = (char *)_stringVal(wlabel); |
|
1392 |
else |
|
1393 |
windowName = ""; |
|
1394 |
||
1395 |
if (iconBitmap || windowName) { |
|
1396 |
XSetStandardProperties(dpy, newWindow, |
|
1397 |
windowName, windowName, |
|
1398 |
iconBitmap, |
|
1399 |
0, 0, &sizehints); |
|
1400 |
||
1401 |
} |
|
1402 |
||
1403 |
wmhints.flags = 0; |
|
1404 |
if (iconBitmap) { |
|
1405 |
wmhints.flags |= IconPixmapHint; |
|
1406 |
wmhints.icon_pixmap = iconBitmap; |
|
1407 |
} |
|
1408 |
if (iconWindow) { |
|
1409 |
wmhints.flags |= IconWindowHint; |
|
1410 |
wmhints.icon_window = iconWindow; |
|
1411 |
} |
|
0 | 1412 |
/* |
1344 | 1413 |
wmhints.flags |= InputHint; |
1414 |
wmhints.input = True; |
|
0 | 1415 |
*/ |
1344 | 1416 |
XSetWMHints(dpy, newWindow, &wmhints); |
1417 |
||
1418 |
/* |
|
1419 |
* tell window manager to not kill us but send an event instead |
|
1420 |
*/ |
|
1421 |
/* |
|
1422 |
* get atoms first (if not already known) |
|
1423 |
*/ |
|
1424 |
if (__INST(protocolsAtom) == nil) { |
|
1425 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
1426 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
|
0 | 1427 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1428 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
1429 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
|
0 | 1430 |
#endif |
1431 |
#ifdef USE_QUIT_APP_ATOM |
|
1344 | 1432 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
1433 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
|
0 | 1434 |
#endif |
1344 | 1435 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1436 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
|
1437 |
} else { |
|
0 | 1438 |
#ifdef USE_QUIT_APP_ATOM |
1344 | 1439 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1440 |
#else |
1344 | 1441 |
WmQuitAppAtom = 0; |
0 | 1442 |
#endif |
1344 | 1443 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1444 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1445 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1446 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1447 |
#else |
1344 | 1448 |
WmSaveYourselfAtom = 0; |
0 | 1449 |
#endif |
1344 | 1450 |
} |
1451 |
||
1452 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1453 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1454 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1455 |
#endif |
1456 |
#ifdef USE_QUIT_APP_ATOM |
|
1344 | 1457 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1458 |
#endif |
1344 | 1459 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1460 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1461 |
} |
1462 |
||
54 | 1463 |
END_INTERRUPTSBLOCKED |
1464 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1465 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1466 |
%}. |
0 | 1467 |
self addKnownView:aView withId:windowId. |
1468 |
^ windowId |
|
1469 |
! |
|
1470 |
||
1471 |
destroyGC:aGCId |
|
1472 |
||
1473 |
%{ /* NOCONTEXT */ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1474 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1475 |
if (! ISCONNECTED) { |
1344 | 1476 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1477 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1478 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1479 |
if (__isExternalAddress(aGCId)) { |
1344 | 1480 |
GC gc = _GCVal(aGCId); |
1481 |
||
1482 |
if (gc) { |
|
1483 |
BEGIN_INTERRUPTSBLOCKED |
|
1484 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1485 |
#ifdef COUNT_RESOURCES |
1344 | 1486 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1487 |
#endif |
1344 | 1488 |
END_INTERRUPTSBLOCKED |
1489 |
} |
|
1490 |
RETURN ( self ); |
|
0 | 1491 |
} |
118 | 1492 |
%}. |
0 | 1493 |
self primitiveFailed |
1494 |
! |
|
1495 |
||
295 | 1496 |
destroyPixmap:aDrawableId |
0 | 1497 |
|
1498 |
%{ /* NOCONTEXT */ |
|
1499 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1500 |
if (! ISCONNECTED) { |
1344 | 1501 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1502 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1503 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1504 |
if (__isExternalAddress(aDrawableId)) { |
1344 | 1505 |
Pixmap pix = _PixmapVal(aDrawableId); |
1506 |
||
1507 |
if (pix) { |
|
1508 |
BEGIN_INTERRUPTSBLOCKED |
|
1509 |
XFreePixmap(myDpy, pix); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1510 |
#ifdef COUNT_RESOURCES |
1344 | 1511 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1512 |
#endif |
1344 | 1513 |
END_INTERRUPTSBLOCKED |
1514 |
} |
|
1515 |
RETURN ( self ); |
|
0 | 1516 |
} |
118 | 1517 |
%}. |
295 | 1518 |
self primitiveFailed |
1519 |
! |
|
1520 |
||
1521 |
destroyView:aView withId:aWindowId |
|
1522 |
%{ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1523 |
if (! ISCONNECTED) { |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1524 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1525 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1526 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1527 |
if (__isExternalAddress(aWindowId)) { |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1528 |
Window win = _WindowVal(aWindowId); |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1529 |
|
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1530 |
if (win) { |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1531 |
BEGIN_INTERRUPTSBLOCKED |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1532 |
XDestroyWindow(myDpy, win); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1533 |
#ifdef COUNT_RESOURCES |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1534 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1535 |
#endif |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1536 |
END_INTERRUPTSBLOCKED |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1537 |
} |
295 | 1538 |
} |
1539 |
%}. |
|
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1540 |
self removeKnownView:aView withId:aWindowId |
0 | 1541 |
! |
1542 |
||
1543 |
dpsContextFor:aDrawableId and:aGCId |
|
1544 |
||
1545 |
%{ /* NOCONTEXT */ |
|
1546 |
#ifdef XXDPS |
|
555 | 1547 |
int screen = __intVal(__INST(screen)); |
0 | 1548 |
DPSContext dps; |
1549 |
int height; |
|
1550 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1551 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1552 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1553 |
&& ISCONNECTED) { |
1344 | 1554 |
BEGIN_INTERRUPTSBLOCKED |
1555 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1556 |
_GCVal(aGCId), |
|
1557 |
0, height, 0, colormap, NULL, 0, |
|
1558 |
XDPSDefaultTextBackstop, |
|
1559 |
XDPSDefaultErrorProc, |
|
1560 |
NULL); |
|
1561 |
END_INTERRUPTSBLOCKED |
|
1562 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
|
0 | 1563 |
} |
1564 |
#endif |
|
1565 |
%} |
|
1566 |
. |
|
43 | 1567 |
self primitiveFailed. |
1568 |
^ nil |
|
295 | 1569 |
! |
1570 |
||
1571 |
gcFor:aDrawableId |
|
132 | 1572 |
|
1573 |
%{ /* NOCONTEXT */ |
|
555 | 1574 |
int screen = __intVal(__INST(screen)); |
295 | 1575 |
GC gc; |
1576 |
||
1577 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1344 | 1578 |
BEGIN_INTERRUPTSBLOCKED |
1579 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1580 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1581 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1582 |
#ifdef COUNT_RESOURCES |
1344 | 1583 |
if (gc) |
1584 |
__cnt_gc++; |
|
1089 | 1585 |
#endif |
1586 |
||
1344 | 1587 |
END_INTERRUPTSBLOCKED |
1588 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1589 |
} |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1590 |
%}. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1591 |
self primitiveFailed. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1592 |
^ nil |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1593 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1594 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1595 |
gcForBitmap:aDrawableId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1596 |
"with X, this is the same as a normal gc" |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1597 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1598 |
%{ /* NOCONTEXT */ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1599 |
int screen = __intVal(__INST(screen)); |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1600 |
GC gc; |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1601 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1602 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
1344 | 1603 |
BEGIN_INTERRUPTSBLOCKED |
1604 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1605 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1606 |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1607 |
#ifdef COUNT_RESOURCES |
1344 | 1608 |
if (gc) |
1609 |
__cnt_gc++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1610 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1611 |
|
1344 | 1612 |
END_INTERRUPTSBLOCKED |
1613 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1614 |
} |
1615 |
%}. |
|
1616 |
self primitiveFailed. |
|
1617 |
^ nil |
|
295 | 1618 |
! |
1619 |
||
1620 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1621 |
|
1622 |
%{ /* UNLIMITEDSTACK */ |
|
1623 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1624 |
Display *dpy; |
555 | 1625 |
int screen = __intVal(__INST(screen)); |
295 | 1626 |
Pixmap newBitmap; |
1627 |
unsigned int b_width, b_height; |
|
1628 |
REGISTER unsigned char *cp; |
|
1629 |
REGISTER unsigned char *pBits; |
|
1630 |
unsigned char *b_bits, *allocatedBits; |
|
1631 |
int index, row; |
|
1632 |
REGISTER int col; |
|
1633 |
unsigned bits; |
|
1634 |
static char reverseBitTable[256]; |
|
1635 |
static firstCall = 1; |
|
1636 |
int nBytes; |
|
1637 |
unsigned char fastBits[10000]; |
|
1638 |
OBJ num, *op; |
|
1639 |
int bytesPerRow; |
|
1640 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1641 |
if (! ISCONNECTED) { |
1344 | 1642 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1643 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1644 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1645 |
dpy = myDpy; |
295 | 1646 |
if (firstCall) { |
1344 | 1647 |
for (index=0; index < 256; index++) { |
1648 |
reverseBitTable[index] = 0; |
|
1649 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1650 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1651 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1652 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1653 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1654 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1655 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1656 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1657 |
} |
|
1658 |
firstCall = 0; |
|
295 | 1659 |
} |
1660 |
||
1661 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1344 | 1662 |
newBitmap = (Pixmap)0; |
1663 |
b_width = __intVal(w); |
|
1664 |
b_height = __intVal(h); |
|
1665 |
bytesPerRow = (b_width + 7) / 8; |
|
1666 |
nBytes = b_height * bytesPerRow; |
|
1667 |
if (nBytes < sizeof(fastBits)) { |
|
1668 |
cp = b_bits = fastBits; |
|
1669 |
allocatedBits = 0; |
|
1670 |
} else { |
|
1671 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1672 |
if (! cp) goto fail; |
|
1673 |
} |
|
1674 |
||
1675 |
if (__qClass(anArray) == @global(Array)) { |
|
1676 |
index = 1; |
|
1677 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1678 |
for (row = b_height; row; row--) { |
|
1679 |
for (col = bytesPerRow; col; col--) { |
|
1680 |
num = *op++; |
|
1681 |
if (! __isSmallInteger(num)) goto fail; |
|
1682 |
bits = __intVal(num); |
|
1683 |
*cp++ = reverseBitTable[bits]; |
|
1684 |
} |
|
1685 |
} |
|
1686 |
} else { |
|
1687 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1688 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1689 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1690 |
*cp++ = reverseBitTable[*pBits++]; |
|
1691 |
} |
|
1692 |
} else { |
|
1693 |
goto fail; |
|
1694 |
} |
|
1695 |
} |
|
1696 |
||
1697 |
BEGIN_INTERRUPTSBLOCKED |
|
1698 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1699 |
(char *)b_bits, |
|
1700 |
b_width, b_height); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1701 |
#ifdef COUNT_RESOURCES |
1344 | 1702 |
if (newBitmap) |
1703 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1704 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1705 |
|
1344 | 1706 |
END_INTERRUPTSBLOCKED |
295 | 1707 |
fail: ; |
1344 | 1708 |
if (allocatedBits) |
1709 |
free(allocatedBits); |
|
1710 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1711 |
} |
1712 |
%} |
|
295 | 1713 |
! |
1714 |
||
1715 |
realRootWindowFor:aView |
|
1716 |
"the name of this method is historic; |
|
1717 |
- it will vanish" |
|
1718 |
||
1719 |
|id| |
|
1720 |
||
1721 |
id := self realRootWindowId. |
|
1722 |
self addKnownView:aView withId:id. |
|
1723 |
^ id |
|
1724 |
! |
|
1725 |
||
1726 |
realRootWindowId |
|
1727 |
"return the id of the real root window. |
|
1728 |
This may not be the window you see as background, |
|
1729 |
since some window managers install a virtual root window on top |
|
1730 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1731 |
care of any virtual root." |
|
0 | 1732 |
|
1733 |
%{ /* NOCONTEXT */ |
|
1734 |
||
555 | 1735 |
int screen = __intVal(__INST(screen)); |
295 | 1736 |
Window root; |
1737 |
OBJ id; |
|
1738 |
||
555 | 1739 |
if (__INST(rootId) != nil) { |
1344 | 1740 |
RETURN (__INST(rootId)); |
295 | 1741 |
} |
0 | 1742 |
|
150 | 1743 |
if (ISCONNECTED) { |
1344 | 1744 |
root = RootWindow(myDpy, screen); |
1745 |
if (! root) { |
|
1746 |
id = nil; |
|
1747 |
} else { |
|
1748 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
|
1749 |
} |
|
1750 |
RETURN (id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1751 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1752 |
%}. |
295 | 1753 |
self primitiveFailed |
1754 |
! |
|
1755 |
||
1756 |
rootWindowFor:aView |
|
1757 |
|id| |
|
1758 |
||
1759 |
id := self rootWindowId. |
|
1760 |
self addKnownView:aView withId:id. |
|
0 | 1761 |
^ id |
1762 |
! |
|
1763 |
||
295 | 1764 |
rootWindowId |
1765 |
"return the id of the root window. |
|
1766 |
This is the window you see as background, |
|
1767 |
however, it may or may not be the real physical root window, |
|
1768 |
since some window managers install a virtual root window on top |
|
1769 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1770 |
|
0 | 1771 |
%{ /* NOCONTEXT */ |
555 | 1772 |
int screen = __intVal(__INST(screen)); |
295 | 1773 |
Window rootWin, vRootWin; |
1774 |
OBJ id; |
|
1775 |
||
555 | 1776 |
if (__INST(virtualRootId) != nil) { |
1344 | 1777 |
RETURN (__INST(virtualRootId)); |
295 | 1778 |
} |
0 | 1779 |
|
169 | 1780 |
if (ISCONNECTED) { |
1344 | 1781 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
295 | 1782 |
#ifndef IRIS |
1344 | 1783 |
BEGIN_INTERRUPTSBLOCKED |
1784 |
/* |
|
1785 |
* on IRIS, this creates a badwindow error - why ? |
|
1786 |
* children contains a funny window (000034) |
|
1787 |
*/ |
|
1788 |
||
1789 |
/* |
|
1790 |
* care for virtual root windows (tvtwm & friends) |
|
1791 |
*/ |
|
1792 |
{ |
|
1793 |
Atom vRootAtom = None; |
|
1794 |
int i; |
|
1795 |
Window rootReturn, parentReturn; |
|
1796 |
Window* children = (Window *)0; |
|
1797 |
unsigned int numChildren; |
|
1798 |
||
1799 |
if (XQueryTree(myDpy, rootWin, |
|
1800 |
&rootReturn, &parentReturn, |
|
1801 |
&children, &numChildren)) { |
|
1802 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1803 |
if (vRootAtom != None) { |
|
1804 |
for (i=0; i < numChildren; i++) { |
|
1805 |
Atom actual_type; |
|
1806 |
int actual_format; |
|
1807 |
unsigned long nitems, bytesafter; |
|
1808 |
Window* newRoot = (Window*) 0; |
|
1809 |
||
1810 |
if (children[i]) { |
|
1811 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1812 |
0L, 1L, False, XA_WINDOW, |
|
1813 |
&actual_type, &actual_format, |
|
1814 |
&nitems, &bytesafter, |
|
1815 |
(unsigned char**) &newRoot |
|
1816 |
) == Success && newRoot) { |
|
1817 |
vRootWin = *newRoot; |
|
1818 |
XFree(newRoot); /* XXX */ |
|
1819 |
break; |
|
1820 |
} |
|
1821 |
} |
|
1822 |
} |
|
1823 |
} |
|
1824 |
if (children) XFree( children ); |
|
1825 |
} |
|
1826 |
} |
|
1827 |
END_INTERRUPTSBLOCKED |
|
295 | 1828 |
#endif |
1829 |
} |
|
1830 |
||
1831 |
/* cannot happen */ |
|
1832 |
if (! vRootWin) { |
|
1344 | 1833 |
vRootWin = rootWin; |
1834 |
if (! rootWin) { |
|
1835 |
RETURN ( nil ); |
|
1836 |
} |
|
295 | 1837 |
} |
555 | 1838 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1839 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1840 |
RETURN ( id ); |
63 | 1841 |
%} |
0 | 1842 |
! ! |
1843 |
||
1844 |
!XWorkstation methodsFor:'color stuff'! |
|
1845 |
||
295 | 1846 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1847 |
"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
|
1848 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1849 |
|
1850 |
%{ /* NOCONTEXT */ |
|
1851 |
||
555 | 1852 |
int screen = __intVal(__INST(screen)); |
295 | 1853 |
XColor color; |
1854 |
unsigned long dummy; |
|
1855 |
Status ok; |
|
1856 |
||
1209 | 1857 |
if (ISCONNECTED) { |
1344 | 1858 |
Display *dpy = myDpy; |
1859 |
||
1860 |
BEGIN_INTERRUPTSBLOCKED |
|
1861 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1862 |
&dummy, 0, &color.pixel, 1); |
|
1863 |
END_INTERRUPTSBLOCKED |
|
1864 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1865 |
#ifdef COUNT_RESOURCES |
1344 | 1866 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1867 |
#endif |
1344 | 1868 |
RETURN ( __MKSMALLINT(color.pixel) ); |
1869 |
} |
|
0 | 1870 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1871 |
%}. |
43 | 1872 |
^ nil |
0 | 1873 |
! |
1874 |
||
1875 |
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
|
1876 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1877 |
Dont use this method, colornames are mostly X specific" |
1878 |
||
1879 |
%{ /* NOCONTEXT */ |
|
1880 |
||
1881 |
char *colorname; |
|
1882 |
XColor scolor, ecolor; |
|
555 | 1883 |
int screen = __intVal(__INST(screen)); |
850 | 1884 |
int id; |
54 | 1885 |
Status ok; |
0 | 1886 |
|
150 | 1887 |
if (ISCONNECTED) { |
1344 | 1888 |
Display *dpy = myDpy; |
1889 |
||
1890 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1891 |
colorname = (char *)_stringVal(aString); |
|
1892 |
||
1893 |
BEGIN_INTERRUPTSBLOCKED |
|
1894 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1895 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1896 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1897 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1898 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1899 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1900 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1901 |
RETURN ( __MKSMALLINT(id) ); |
|
1902 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1903 |
#endif |
1344 | 1904 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1905 |
} |
|
1906 |
END_INTERRUPTSBLOCKED |
|
1907 |
if (! ok) { |
|
1908 |
RETURN ( nil ); |
|
1909 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1910 |
#ifdef COUNT_RESOURCES |
1344 | 1911 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1912 |
#endif |
1344 | 1913 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1914 |
} |
|
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 |
%}. |
43 | 1917 |
self primitiveFailed. |
1918 |
^ nil |
|
0 | 1919 |
! |
1920 |
||
295 | 1921 |
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
|
1922 |
"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
|
1923 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1924 |
|
1925 |
|r g b| |
|
1926 |
||
1927 |
r := self percentToXColorValue:redVal. |
|
1928 |
g := self percentToXColorValue:greenVal. |
|
1929 |
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
|
1930 |
^ 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
|
1931 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1932 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1933 |
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
|
1934 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1935 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1936 |
Display *dpy; |
295 | 1937 |
XColor ecolor; |
555 | 1938 |
int screen = __intVal(__INST(screen)); |
295 | 1939 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1940 |
int id; |
295 | 1941 |
|
1942 |
if (__bothSmallInteger(r, g) |
|
1943 |
&& __isSmallInteger(b) |
|
1944 |
&& ISCONNECTED) { |
|
1344 | 1945 |
ecolor.red = __intVal(r); |
1946 |
ecolor.green= __intVal(g); |
|
1947 |
ecolor.blue = __intVal(b); |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1948 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1949 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1950 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1951 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1952 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1953 |
RETURN ( __MKSMALLINT(id) ); |
|
1954 |
} |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1955 |
#endif |
1344 | 1956 |
dpy = myDpy; |
1957 |
BEGIN_INTERRUPTSBLOCKED |
|
1958 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1959 |
END_INTERRUPTSBLOCKED |
|
1960 |
if (! ok) { |
|
1961 |
RETURN ( nil ); |
|
1962 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1963 |
#ifdef COUNT_RESOURCES |
1344 | 1964 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1965 |
#endif |
1344 | 1966 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1967 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1968 |
%}. |
295 | 1969 |
self primitiveFailed. |
1970 |
^ nil |
|
1971 |
! |
|
1972 |
||
1973 |
freeColor:colorIndex |
|
1974 |
"free a display color when its no longer needed" |
|
0 | 1975 |
|
1976 |
%{ /* NOCONTEXT */ |
|
1977 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1978 |
Display *dpy; |
295 | 1979 |
unsigned long color; |
555 | 1980 |
int screen = __intVal(__INST(screen)); |
295 | 1981 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1982 |
#ifdef QUICK_TRUE_COLORS |
555 | 1983 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1344 | 1984 |
/* no need to do anything on TrueColor displays ... */ |
1985 |
RETURN (self); |
|
295 | 1986 |
} |
1987 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1988 |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1989 |
if (! ISCONNECTED) { |
1344 | 1990 |
RETURN (self); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1991 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1992 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1993 |
if (__isSmallInteger(colorIndex)) { |
1344 | 1994 |
dpy = myDpy; |
1995 |
color = (long) __intVal(colorIndex); |
|
1996 |
BEGIN_INTERRUPTSBLOCKED |
|
1997 |
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
|
1998 |
#ifdef COUNT_RESOURCES |
1344 | 1999 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2000 |
#endif |
1344 | 2001 |
END_INTERRUPTSBLOCKED |
2002 |
RETURN ( self ); |
|
0 | 2003 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2004 |
%}. |
295 | 2005 |
self primitiveFailed |
2006 |
! |
|
2007 |
||
2008 |
getRGBFrom:index into:aBlock |
|
2009 |
"get rgb components (0..100) of color in map at:index, |
|
2010 |
and evaluate the 3-arg block, aBlock with them" |
|
2011 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2012 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2013 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2014 |
self getScaledRGBFrom:index into:[:r :g :b | |
1344 | 2015 |
val := aBlock |
2016 |
value:(r * 100.0 / 16rFFFF) |
|
2017 |
value:(g * 100.0 / 16rFFFF) |
|
2018 |
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
|
2019 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2020 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2021 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2022 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2023 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2024 |
"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
|
2025 |
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
|
2026 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2027 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2028 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
1430 | 2029 |
r isNil ifTrue:[ |
2030 |
^ nil |
|
2031 |
]. |
|
2032 |
val := aBlock |
|
2033 |
value:(r * 100.0 / 16rFFFF) |
|
2034 |
value:(g * 100.0 / 16rFFFF) |
|
2035 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2036 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2037 |
^ val |
1056 | 2038 |
|
1430 | 2039 |
"Modified: 6.3.1997 / 02:36:43 / cg" |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2040 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2041 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2042 |
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
|
2043 |
"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
|
2044 |
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
|
2045 |
|
295 | 2046 |
|r g b| |
2047 |
%{ |
|
555 | 2048 |
int screen = __intVal(__INST(screen)); |
295 | 2049 |
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
|
2050 |
int sr, sg, sb; |
295 | 2051 |
int bits, scale, shift; |
2052 |
||
1209 | 2053 |
if (ISCONNECTED |
2054 |
&& __isSmallInteger(index)) { |
|
1344 | 2055 |
Display *dpy = myDpy; |
2056 |
||
2057 |
color.pixel = __intVal(index); |
|
2058 |
BEGIN_INTERRUPTSBLOCKED |
|
2059 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2060 |
END_INTERRUPTSBLOCKED |
|
2061 |
||
2062 |
/* |
|
2063 |
* have to compensate for an error in X ?, which does not scale |
|
2064 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2065 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2066 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2067 |
*/ |
|
2068 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2069 |
scale = (1<<bits) - 1; |
|
2070 |
shift = 16 - bits; |
|
2071 |
||
2072 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2073 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2074 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2075 |
r = __MKSMALLINT(sr); |
|
2076 |
g = __MKSMALLINT(sg); |
|
2077 |
b = __MKSMALLINT(sb); |
|
295 | 2078 |
} |
2079 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2080 |
^ aBlock value:r value:g value:b |
295 | 2081 |
! |
2082 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2083 |
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
|
2084 |
"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
|
2085 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2086 |
|
2087 |
|r g b| |
|
2088 |
||
2089 |
displayId isNil ifTrue:[ |
|
1430 | 2090 |
self pimitiveFailed. |
2091 |
^ nil |
|
295 | 2092 |
]. |
2093 |
%{ |
|
555 | 2094 |
int screen = __intVal(__INST(screen)); |
295 | 2095 |
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
|
2096 |
int sr, sg, sb; |
295 | 2097 |
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
|
2098 |
int bits, scale, shift; |
295 | 2099 |
|
1209 | 2100 |
if (ISCONNECTED |
2101 |
&& __isString(colorName) || __isSymbol(colorName)) { |
|
1430 | 2102 |
Display *dpy = myDpy; |
1209 | 2103 |
|
1430 | 2104 |
BEGIN_INTERRUPTSBLOCKED |
2105 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2106 |
(char *)_stringVal(colorName), &color)) { |
|
2107 |
/* |
|
2108 |
* have to compensate for an error in X ?, which does not scale |
|
2109 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2110 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2111 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2112 |
*/ |
|
2113 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2114 |
scale = (1<<bits) - 1; |
|
2115 |
shift = 16 - bits; |
|
2116 |
||
2117 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2118 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2119 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2120 |
r = __MKSMALLINT(sr); |
|
2121 |
g = __MKSMALLINT(sg); |
|
2122 |
b = __MKSMALLINT(sb); |
|
2123 |
} |
|
2124 |
END_INTERRUPTSBLOCKED |
|
295 | 2125 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2126 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2127 |
^ aBlock value:r value:g value:b |
295 | 2128 |
! |
2129 |
||
2130 |
listOfAvailableColors |
|
2131 |
"return a list of all available colornames. |
|
2132 |
This should not be used, since colornames are very |
|
2133 |
display-specific (here X-specific)." |
|
2134 |
||
2135 |
|aStream list line index colorName| |
|
2136 |
||
2137 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2138 |
aStream isNil ifTrue:[^ nil]. |
|
2139 |
list := OrderedCollection new. |
|
2140 |
[aStream atEnd] whileFalse:[ |
|
1344 | 2141 |
line := aStream nextLine. |
2142 |
line notNil ifTrue:[ |
|
2143 |
"skip the r/g/b numbers" |
|
2144 |
index := 1. |
|
2145 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2146 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2147 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2148 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2149 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2150 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2151 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2152 |
colorName := line copyFrom:index. |
|
2153 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2154 |
list add:colorName |
|
2155 |
] |
|
2156 |
] |
|
295 | 2157 |
]. |
2158 |
aStream close. |
|
2159 |
^ list sort |
|
1047 | 2160 |
|
2161 |
" |
|
2162 |
Screen current listOfAvailableColors |
|
2163 |
" |
|
2164 |
||
2165 |
"Modified: 11.9.1996 / 15:26:28 / stefan" |
|
295 | 2166 |
! |
2167 |
||
2168 |
percentToXColorValue:aPercentage |
|
2169 |
"given a color-component value in percent (0..100), return the corresponding |
|
2170 |
x-component value (0..65k) as an integer" |
|
2171 |
||
2172 |
%{ /* NOCONTEXT */ |
|
2173 |
||
2174 |
if (__isSmallInteger(aPercentage)) { |
|
1344 | 2175 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2176 |
} |
2177 |
if (__isFloat(aPercentage)) { |
|
1344 | 2178 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2179 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2180 |
%}. |
295 | 2181 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2182 |
! |
2183 |
||
892 | 2184 |
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
|
2185 |
"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
|
2186 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2187 |
|
2188 |
%{ /* NOCONTEXT */ |
|
2189 |
||
2190 |
char *colorname; |
|
2191 |
XColor color; |
|
555 | 2192 |
int screen = __intVal(__INST(screen)); |
0 | 2193 |
int r, g, b; |
2194 |
int ok = 1; |
|
2195 |
||
892 | 2196 |
if (__isSmallInteger(sred)) |
1344 | 2197 |
r = __intVal(sred); |
0 | 2198 |
else ok = 0; |
2199 |
||
892 | 2200 |
if (__isSmallInteger(sgreen)) |
1344 | 2201 |
g = __intVal(sgreen); |
0 | 2202 |
else ok = 0; |
2203 |
||
892 | 2204 |
if (__isSmallInteger(sblue)) |
1344 | 2205 |
b = __intVal(sblue); |
0 | 2206 |
else ok = 0; |
2207 |
||
1209 | 2208 |
if (ISCONNECTED |
2209 |
&& __isSmallInteger(index) && ok) { |
|
1344 | 2210 |
Display *dpy = myDpy; |
2211 |
||
2212 |
color.pixel = __intVal(index); |
|
2213 |
color.red = r; |
|
2214 |
color.green = g; |
|
2215 |
color.blue = b; |
|
2216 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2217 |
||
2218 |
BEGIN_INTERRUPTSBLOCKED |
|
2219 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2220 |
END_INTERRUPTSBLOCKED |
|
2221 |
RETURN ( self ); |
|
0 | 2222 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2223 |
%}. |
0 | 2224 |
self primitiveFailed |
295 | 2225 |
! ! |
2226 |
||
2227 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2228 |
||
2229 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2230 |
"change a cursors colors" |
|
2231 |
||
2232 |
|fgR fgG fgB bgR bgG bgB| |
|
2233 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2234 |
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
|
2235 |
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
|
2236 |
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
|
2237 |
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
|
2238 |
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
|
2239 |
bgB := bgColor scaledBlue. |
0 | 2240 |
%{ |
295 | 2241 |
XColor fgcolor, bgcolor; |
2242 |
||
1209 | 2243 |
if (ISCONNECTED |
2244 |
&& __isExternalAddress(aCursorId) |
|
295 | 2245 |
&& __bothSmallInteger(fgG, fgB) |
2246 |
&& __bothSmallInteger(bgR, bgG) |
|
2247 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2248 |
||
1344 | 2249 |
fgcolor.red = __intVal(fgR); |
2250 |
fgcolor.green= __intVal(fgG); |
|
2251 |
fgcolor.blue = __intVal(fgB); |
|
2252 |
bgcolor.red = __intVal(bgR); |
|
2253 |
bgcolor.green= __intVal(bgG); |
|
2254 |
bgcolor.blue = __intVal(bgB); |
|
2255 |
BEGIN_INTERRUPTSBLOCKED |
|
2256 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
2257 |
END_INTERRUPTSBLOCKED |
|
2258 |
RETURN ( self ); |
|
72 | 2259 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2260 |
%}. |
0 | 2261 |
self primitiveFailed |
70 | 2262 |
! |
2263 |
||
295 | 2264 |
createCursorShape:aShape |
974 | 2265 |
"create a cursor given a shape-symbol. This only works |
2266 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2267 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2268 |
|
2269 |
|number id| |
|
2270 |
||
2271 |
displayId isNil ifTrue:[ |
|
1344 | 2272 |
self primitiveFailed. |
2273 |
^ nil |
|
295 | 2274 |
]. |
2275 |
number := self shapeNumberFromSymbol:aShape. |
|
2276 |
%{ |
|
2277 |
Cursor newCursor; |
|
2278 |
||
1209 | 2279 |
if (ISCONNECTED |
2280 |
&& __isSmallInteger(number)) { |
|
1344 | 2281 |
BEGIN_INTERRUPTSBLOCKED |
2282 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2283 |
#ifdef COUNT_RESOURCES |
1344 | 2284 |
if (newCursor) |
2285 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2286 |
#endif |
1344 | 2287 |
END_INTERRUPTSBLOCKED |
2288 |
if (newCursor != (Cursor)0) { |
|
2289 |
id = __MKOBJ(newCursor); |
|
2290 |
} |
|
0 | 2291 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2292 |
%}. |
295 | 2293 |
^ id |
2294 |
! |
|
2295 |
||
974 | 2296 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2297 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2298 |
||
2299 |
|id sourceId maskId| |
|
2300 |
||
2301 |
displayId isNil ifTrue:[ |
|
1344 | 2302 |
self primitiveFailed. |
2303 |
^ nil |
|
295 | 2304 |
]. |
2305 |
sourceId := sourceForm id. |
|
2306 |
maskId := maskForm id. |
|
2307 |
%{ |
|
2308 |
Cursor newCursor; |
|
2309 |
XColor fgColor, bgColor; |
|
2310 |
||
1209 | 2311 |
if (ISCONNECTED |
2312 |
&& __isExternalAddress(sourceId) |
|
295 | 2313 |
&& __isExternalAddress(maskId) |
2314 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2315 |
fgColor.red = 0; /* fg is black */ |
2316 |
fgColor.green = 0; |
|
2317 |
fgColor.blue = 0; |
|
2318 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2319 |
bgColor.green = 0xFFFF; |
|
2320 |
bgColor.blue = 0xFFFF; |
|
2321 |
||
2322 |
BEGIN_INTERRUPTSBLOCKED |
|
2323 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2324 |
_PixmapVal(sourceId), |
|
2325 |
_PixmapVal(maskId), |
|
2326 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2327 |
#ifdef COUNT_RESOURCES |
1344 | 2328 |
if (newCursor) |
2329 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2330 |
#endif |
1344 | 2331 |
END_INTERRUPTSBLOCKED |
2332 |
if (newCursor != (Cursor)0) { |
|
2333 |
id = __MKOBJ(newCursor); |
|
2334 |
} |
|
0 | 2335 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2336 |
%}. |
295 | 2337 |
^ id |
2338 |
! |
|
2339 |
||
2340 |
destroyCursor:aCursorId |
|
974 | 2341 |
"release a cursor - frees any device resources" |
0 | 2342 |
|
2343 |
%{ /* NOCONTEXT */ |
|
2344 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2345 |
if (! ISCONNECTED) { |
1344 | 2346 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2347 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2348 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2349 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2350 |
Cursor curs = _CursorVal(aCursorId); |
2351 |
||
2352 |
if (curs) { |
|
2353 |
BEGIN_INTERRUPTSBLOCKED |
|
2354 |
XFreeCursor(myDpy, curs); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2355 |
#ifdef COUNT_RESOURCES |
1344 | 2356 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2357 |
#endif |
1344 | 2358 |
END_INTERRUPTSBLOCKED |
2359 |
} |
|
2360 |
RETURN ( self ); |
|
0 | 2361 |
} |
974 | 2362 |
%}. |
0 | 2363 |
self primitiveFailed |
295 | 2364 |
! |
2365 |
||
974 | 2366 |
needDeviceFormsForCursor |
2367 |
^ true |
|
2368 |
! |
|
2369 |
||
295 | 2370 |
shapeNumberFromSymbol:shape |
974 | 2371 |
"given a shape-symbol, return the corresponding cursor-number, |
2372 |
or nil if no such standard cursor exists." |
|
295 | 2373 |
|
2374 |
"this is pure X-knowlegde - but you may easily add more" |
|
2375 |
||
2376 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2377 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2378 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2379 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2380 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2381 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2382 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2383 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2384 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2385 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2386 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2387 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2388 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2389 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2390 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2391 |
((shape == #origin) |
|
2392 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2393 |
((shape == #corner) |
|
2394 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2395 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2396 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2397 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2398 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2399 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2400 |
|
2401 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2402 |
^ nil |
0 | 2403 |
! ! |
2404 |
||
2405 |
!XWorkstation methodsFor:'drawing'! |
|
2406 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2407 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2408 |
"do a bit-blt; copy bits from the rectangle defined by |
2409 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2410 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2411 |
argument is not integer." |
|
0 | 2412 |
|
2413 |
%{ /* NOCONTEXT */ |
|
2414 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2415 |
GC gc; |
0 | 2416 |
Drawable source, dest; |
2417 |
||
1209 | 2418 |
if (ISCONNECTED |
2419 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2420 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2421 |
&& __isExternalAddress(destId) |
97 | 2422 |
&& __bothSmallInteger(w, h) |
2423 |
&& __bothSmallInteger(srcX, srcY) |
|
2424 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2425 |
gc = _GCVal(dstGCId); |
2426 |
source = (Drawable) _WindowVal(sourceId); |
|
2427 |
dest = (Drawable) _WindowVal(destId); |
|
2428 |
XCopyArea(myDpy, source, dest, gc, |
|
2429 |
__intVal(srcX), __intVal(srcY), |
|
2430 |
__intVal(w), __intVal(h), |
|
2431 |
__intVal(dstX), __intVal(dstY)); |
|
2432 |
RETURN ( self ); |
|
0 | 2433 |
} |
118 | 2434 |
%}. |
2435 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2436 |
or any non integer coordinate" |
|
2437 |
||
0 | 2438 |
self primitiveFailed |
2439 |
! |
|
2440 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2441 |
copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2442 |
"do a bit-blt from a pix- or bitmap; copy bits from the rectangle defined by |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2443 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2444 |
below dstX/dstY in the destId drawable. Trigger an error if any |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2445 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2446 |
This is basically the same as copyFromId:..., but does not generate expose events." |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2447 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2448 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2449 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2450 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2451 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2452 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2453 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2454 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2455 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2456 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2457 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2458 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2459 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2460 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2461 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2462 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2463 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2464 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2465 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2466 |
XCopyArea(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2467 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2468 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2469 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2470 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2471 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2472 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2473 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2474 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2475 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2476 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2477 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2478 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2479 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2480 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2481 |
"do a bit-blt, but only copy the low-bit plane; |
2482 |
copy bits from the rectangle defined by |
|
2483 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2484 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2485 |
argument is not integer." |
|
0 | 2486 |
|
2487 |
%{ /* NOCONTEXT */ |
|
2488 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2489 |
GC gc; |
0 | 2490 |
Drawable source, dest; |
2491 |
||
1209 | 2492 |
if (ISCONNECTED |
2493 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2494 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2495 |
&& __isExternalAddress(destId) |
97 | 2496 |
&& __bothSmallInteger(w, h) |
2497 |
&& __bothSmallInteger(srcX, srcY) |
|
2498 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2499 |
gc = _GCVal(dstGCId); |
2500 |
source = (Drawable) _WindowVal(sourceId); |
|
2501 |
dest = (Drawable) _WindowVal(destId); |
|
2502 |
XCopyPlane(myDpy, source, dest, gc, |
|
2503 |
__intVal(srcX), __intVal(srcY), |
|
2504 |
__intVal(w), __intVal(h), |
|
2505 |
__intVal(dstX), __intVal(dstY), 1); |
|
2506 |
RETURN ( self ); |
|
0 | 2507 |
} |
118 | 2508 |
%}. |
2509 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2510 |
or any non integer coordinate" |
|
2511 |
||
0 | 2512 |
self primitiveFailed |
2513 |
! |
|
2514 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2515 |
copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2516 |
"do a bit-blt from a pix- or bitmap, but only copy the low-bit plane; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2517 |
copy bits from the rectangle defined by |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2518 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2519 |
below dstX/dstY in the destId drawable. Trigger an error if any |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2520 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2521 |
This is the same as copyPlaneFromId:..., but does not generate graphics exposes" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2522 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2523 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2524 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2525 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2526 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2527 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2528 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2529 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2530 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2531 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2532 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2533 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2534 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2535 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2536 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2537 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2538 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2539 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2540 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2541 |
XCopyPlane(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2542 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2543 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2544 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2545 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2546 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2547 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2548 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2549 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2550 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2551 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2552 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2553 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2554 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2555 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2556 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2557 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2558 |
|
2559 |
%{ /* NOCONTEXT */ |
|
2560 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2561 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2562 |
Window win; |
0 | 2563 |
int w, h, angle1, angle2; |
2564 |
double f; |
|
2565 |
||
97 | 2566 |
if (__isSmallInteger(startAngle)) |
1344 | 2567 |
angle1 = __intVal(startAngle) * 64; |
36 | 2568 |
else if (__isFloat(startAngle)) { |
1344 | 2569 |
f = __floatVal(startAngle); |
2570 |
angle1 = f * 64; |
|
0 | 2571 |
} |
97 | 2572 |
if (__isSmallInteger(angle)) |
1344 | 2573 |
angle2 = __intVal(angle) * 64; |
36 | 2574 |
else if (__isFloat(angle)) { |
1344 | 2575 |
f = __floatVal(angle); |
2576 |
angle2 = f * 64; |
|
0 | 2577 |
} |
1209 | 2578 |
if (ISCONNECTED |
2579 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2580 |
&& __isExternalAddress(aDrawableId) |
97 | 2581 |
&& __bothSmallInteger(x, y) |
2582 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2583 |
win = _WindowVal(aDrawableId); |
2584 |
gc = _GCVal(aGCId); |
|
2585 |
w = __intVal(width); |
|
2586 |
h = __intVal(height); |
|
2587 |
/* |
|
2588 |
* need this check here: some servers simply dump core with bad args |
|
2589 |
*/ |
|
2590 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2591 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2592 |
w, h, angle1, angle2); |
|
2593 |
} |
|
2594 |
RETURN ( self ); |
|
0 | 2595 |
} |
73 | 2596 |
%}. |
2597 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2598 |
self primitiveFailed |
2599 |
! |
|
2600 |
||
295 | 2601 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2602 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2603 |
||
2604 |
%{ /* NOCONTEXT */ |
|
2605 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2606 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2607 |
Window win; |
295 | 2608 |
|
1209 | 2609 |
if (ISCONNECTED |
2610 |
&& __isExternalAddress(aGCId) |
|
295 | 2611 |
&& __isExternalAddress(aDrawableId) |
2612 |
&& __bothSmallInteger(x0, y0) |
|
2613 |
&& __bothSmallInteger(x1, y1)) { |
|
1511
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2614 |
gc = _GCVal(aGCId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2615 |
win = _WindowVal(aDrawableId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2616 |
|
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2617 |
if ((x0 == x1) && (y0 == y1)) { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2618 |
XDrawPoint(myDpy, win, gc, __intVal(x0), __intVal(y0)); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2619 |
} else { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2620 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2621 |
__intVal(x1), __intVal(y1)); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2622 |
} |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2623 |
RETURN ( self ); |
295 | 2624 |
} |
2625 |
%}. |
|
2626 |
"badGC, badDrawable or coordinates not integer" |
|
2627 |
self primitiveFailed |
|
2628 |
! |
|
2629 |
||
2630 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2631 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2632 |
||
2633 |
%{ /* NOCONTEXT */ |
|
2634 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2635 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2636 |
Window win; |
295 | 2637 |
|
1209 | 2638 |
if (ISCONNECTED |
2639 |
&& __isExternalAddress(aGCId) |
|
295 | 2640 |
&& __isExternalAddress(aDrawableId) |
2641 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2642 |
gc = _GCVal(aGCId); |
2643 |
win = _WindowVal(aDrawableId); |
|
2644 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
|
2645 |
RETURN ( self ); |
|
295 | 2646 |
} |
2647 |
%}. |
|
2648 |
"badGC, badDrawable or x/y not integer" |
|
2649 |
self primitiveFailed |
|
2650 |
! |
|
2651 |
||
2652 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2653 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2654 |
define the polygon. |
|
2655 |
If any coordinate is not integer, an error is triggered." |
|
2656 |
||
2657 |
|numberOfPoints newPoints| |
|
2658 |
||
2659 |
numberOfPoints := aPolygon size. |
|
2660 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2661 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2662 |
Window win; |
295 | 2663 |
OBJ point, x, y; |
2664 |
int i, num; |
|
2665 |
XPoint *points; |
|
2666 |
XPoint qPoints[100]; |
|
377 | 2667 |
int mustFree = 0; |
295 | 2668 |
|
1209 | 2669 |
if (ISCONNECTED |
2670 |
&& __isExternalAddress(aGCId) |
|
295 | 2671 |
&& __isExternalAddress(aDrawableId) |
2672 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 2673 |
gc = _GCVal(aGCId); |
2674 |
win = _WindowVal(aDrawableId); |
|
2675 |
num = __intVal(numberOfPoints); |
|
2676 |
/* |
|
2677 |
* avoid a (slow) malloc, if the number of points is small |
|
2678 |
*/ |
|
2679 |
if (num > 100) { |
|
2680 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2681 |
if (! points) goto fail; |
|
2682 |
mustFree = 1; |
|
2683 |
} else |
|
2684 |
points = qPoints; |
|
2685 |
||
2686 |
for (i=0; i<num; i++) { |
|
2687 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2688 |
if (! __isPoint(point)) goto fail; |
|
2689 |
x = _point_X(point); |
|
2690 |
y = _point_Y(point); |
|
2691 |
if (! __bothSmallInteger(x, y)) |
|
2692 |
goto fail; |
|
2693 |
points[i].x = __intVal(x); |
|
2694 |
points[i].y = __intVal(y); |
|
2695 |
} |
|
2696 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
2697 |
if (mustFree) |
|
2698 |
free(points); |
|
2699 |
RETURN ( self ); |
|
295 | 2700 |
} |
2701 |
fail: ; |
|
377 | 2702 |
if (mustFree) |
1344 | 2703 |
free(points); |
295 | 2704 |
%}. |
2705 |
"badGC, badDrawable or coordinates not integer" |
|
2706 |
self primitiveFailed |
|
2707 |
! |
|
2708 |
||
2709 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2710 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2711 |
||
2712 |
%{ /* NOCONTEXT */ |
|
2713 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2714 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2715 |
Window win; |
295 | 2716 |
int w, h; |
2717 |
||
1209 | 2718 |
if (ISCONNECTED |
2719 |
&& __isExternalAddress(aGCId) |
|
295 | 2720 |
&& __isExternalAddress(aDrawableId) |
2721 |
&& __bothSmallInteger(x, y) |
|
2722 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2723 |
gc = _GCVal(aGCId); |
2724 |
win = _WindowVal(aDrawableId); |
|
2725 |
w = __intVal(width); |
|
2726 |
h = __intVal(height); |
|
2727 |
/* |
|
2728 |
* need this check here: some servers simply dump core with bad args |
|
2729 |
*/ |
|
2730 |
if ((w >= 0) && (h >= 0)) { |
|
2731 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
|
2732 |
} |
|
2733 |
RETURN ( self ); |
|
295 | 2734 |
} |
2735 |
%}. |
|
2736 |
"badGC, badDrawable or coordinates not integer" |
|
2737 |
self primitiveFailed |
|
2738 |
! |
|
2739 |
||
2740 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2741 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2742 |
foreground and background characters. |
|
2743 |
If the coordinates are not integers, an error is triggered." |
|
2744 |
||
2745 |
%{ /* NOCONTEXT */ |
|
2746 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2747 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2748 |
Window win; |
295 | 2749 |
unsigned char *cp; |
2750 |
OBJ cls; |
|
2751 |
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
|
2752 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2753 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2754 |
int nInstBytes; |
295 | 2755 |
|
1209 | 2756 |
if (ISCONNECTED |
2757 |
&& __isExternalAddress(aGCId) |
|
295 | 2758 |
&& __isExternalAddress(aDrawableId) |
2759 |
&& __isNonNilObject(aString) |
|
2760 |
&& __bothSmallInteger(index1, index2) |
|
2761 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2762 |
gc = _GCVal(aGCId); |
2763 |
win = _WindowVal(aDrawableId); |
|
2764 |
cls = __qClass(aString); |
|
2765 |
||
2766 |
i1 = __intVal(index1) - 1; |
|
2767 |
if (i1 >= 0) { |
|
2768 |
i2 = __intVal(index2) - 1; |
|
2769 |
if (i2 < i1) { |
|
2770 |
RETURN (self); |
|
2771 |
} |
|
2772 |
||
2773 |
cp = _stringVal(aString); |
|
2774 |
l = i2 - i1 + 1; |
|
2775 |
||
2776 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2777 |
n = _stringSize(aString); |
|
2778 |
if (i2 < n) { |
|
2779 |
cp += i1; |
|
2780 |
if (l > 1000) l = 1000; |
|
2781 |
if (opaque == true) |
|
2782 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2783 |
else |
|
2784 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2785 |
RETURN ( self ); |
|
2786 |
} |
|
2787 |
} |
|
2788 |
||
2789 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2790 |
cp += nInstBytes; |
|
2791 |
||
2792 |
if (__isBytes(aString)) { |
|
2793 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2794 |
||
2795 |
if (i2 < n) { |
|
2796 |
cp += i1; |
|
2797 |
if (l > 1000) l = 1000; |
|
2798 |
if (opaque == true) |
|
2799 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2800 |
else |
|
2801 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2802 |
RETURN ( self ); |
|
2803 |
} |
|
2804 |
} |
|
2805 |
||
2806 |
/* TWOBYTESTRINGS */ |
|
2807 |
if (__isWords(aString)) { |
|
2808 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2809 |
||
2810 |
if (i2 < n) { |
|
2811 |
union { |
|
2812 |
char b[2]; |
|
2813 |
unsigned short s; |
|
2814 |
} u; |
|
2815 |
int i; |
|
2816 |
XChar2b *cp2 = (XChar2b *)0; |
|
2817 |
int mustFree = 0; |
|
2818 |
||
2819 |
cp += (i1 * 2); |
|
2820 |
if (l > 1000) l = 1000; |
|
2821 |
||
2822 |
/* |
|
2823 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2824 |
* X expects them MSB first |
|
2825 |
* convert as required |
|
2826 |
*/ |
|
2827 |
||
2828 |
u.s = 0x1234; |
|
2829 |
if (u.b[0] != 0x12) { |
|
2830 |
if (l <= NLOCALBUFFER) { |
|
2831 |
cp2 = xlatebuffer; |
|
2832 |
} else { |
|
2833 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2834 |
mustFree = 1; |
|
2835 |
} |
|
2836 |
for (i=0; i<l; i++) { |
|
2837 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2838 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2839 |
} |
|
2840 |
cp = (char *) cp2; |
|
2841 |
} |
|
2842 |
||
2843 |
if (opaque == true) |
|
2844 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2845 |
else |
|
2846 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2847 |
||
2848 |
if (mustFree) { |
|
2849 |
free(cp2); |
|
2850 |
} |
|
2851 |
||
2852 |
RETURN ( self ); |
|
2853 |
} |
|
2854 |
} |
|
2855 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2856 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2857 |
#undef NLOCALBUFFER |
295 | 2858 |
%}. |
2859 |
"x/y not integer, badGC or drawable, or not a string" |
|
2860 |
self primitiveFailed |
|
2861 |
! |
|
2862 |
||
2863 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2864 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2865 |
foreground and background characters. |
|
2866 |
If the coordinates are not integers, an error is triggered." |
|
2867 |
||
2868 |
%{ /* NOCONTEXT */ |
|
2869 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2870 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2871 |
Window win; |
295 | 2872 |
unsigned char *cp; |
2873 |
int n; |
|
2874 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2875 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2876 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2877 |
int nInstBytes; |
295 | 2878 |
|
1209 | 2879 |
if (ISCONNECTED |
2880 |
&& __isExternalAddress(aGCId) |
|
295 | 2881 |
&& __isExternalAddress(aDrawableId) |
2882 |
&& __isNonNilObject(aString) |
|
2883 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2884 |
gc = _GCVal(aGCId); |
2885 |
win = _WindowVal(aDrawableId); |
|
2886 |
cls = __qClass(aString); |
|
2887 |
||
2888 |
cp = _stringVal(aString); |
|
2889 |
||
2890 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2891 |
n = _stringSize(aString); |
|
2892 |
if (n > 1000) n = 1000; |
|
2893 |
if (opaque == true) |
|
2894 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2895 |
else |
|
2896 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2897 |
RETURN ( self ); |
|
2898 |
} |
|
2899 |
||
2900 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2901 |
cp += nInstBytes; |
|
2902 |
||
2903 |
if (__isBytes(aString)) { |
|
2904 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2905 |
||
2906 |
if (n > 1000) n = 1000; |
|
2907 |
if (opaque == true) |
|
2908 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2909 |
else |
|
2910 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2911 |
RETURN ( self ); |
|
2912 |
} |
|
2913 |
||
2914 |
/* TWOBYTESTRINGS */ |
|
2915 |
if (__isWords(aString)) { |
|
2916 |
union { |
|
2917 |
char b[2]; |
|
2918 |
unsigned short s; |
|
2919 |
} u; |
|
2920 |
int i; |
|
2921 |
XChar2b *cp2; |
|
2922 |
int mustFree = 0; |
|
2923 |
||
2924 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2925 |
if (n > 1000) n = 1000; |
|
2926 |
||
2927 |
/* |
|
2928 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2929 |
* X expects them MSB first |
|
2930 |
* convert as required |
|
2931 |
*/ |
|
2932 |
||
2933 |
u.s = 0x1234; |
|
2934 |
if (u.b[0] != 0x12) { |
|
2935 |
if (n <= NLOCALBUFFER) { |
|
2936 |
cp2 = xlatebuffer; |
|
2937 |
} else { |
|
2938 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2939 |
mustFree = 1; |
|
2940 |
} |
|
2941 |
||
2942 |
for (i=0; i<n; i++) { |
|
2943 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2944 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2945 |
} |
|
2946 |
cp = (char *) cp2; |
|
2947 |
} |
|
2948 |
||
2949 |
if (opaque == true) |
|
2950 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2951 |
else |
|
2952 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2953 |
||
2954 |
||
2955 |
if (mustFree) { |
|
2956 |
free(cp2); |
|
2957 |
} |
|
2958 |
||
2959 |
RETURN ( self ); |
|
2960 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2961 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2962 |
#undef NLOCALBUFFER |
295 | 2963 |
%}. |
2964 |
"x/y not integer, badGC or drawable, or not a string" |
|
2965 |
self primitiveFailed |
|
2966 |
! |
|
2967 |
||
2968 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 2969 |
width:imageWidth height:imageHeight |
2970 |
x:srcx y:srcy |
|
2971 |
into:aDrawableId |
|
2972 |
x:dstx y:dsty |
|
2973 |
width:w height:h |
|
2974 |
with:aGCId |
|
295 | 2975 |
|
2976 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2977 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2978 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2979 |
depth and pixel-units to be different. |
|
2980 |
It has to be checked elsewhere, that the server can do it with the given |
|
2981 |
depth - otherwise, primitive failure will be signalled. |
|
2982 |
Also it is assumed, that the colormap is setup correctly and the |
|
2983 |
colors are allocated - otherwise the colors may be wrong." |
|
2984 |
||
2985 |
" |
|
2986 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2987 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2988 |
" |
|
2989 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 2990 |
width:imageWidth height:imageHeight |
2991 |
x:srcx y:srcy |
|
2992 |
into:aDrawableId |
|
2993 |
x:dstx y:dsty |
|
2994 |
width:w height:h |
|
2995 |
with:aGCId) |
|
295 | 2996 |
ifFalse:[ |
1344 | 2997 |
" |
2998 |
also happens, if a segmentation violation occurs in the |
|
2999 |
XPutImage ... |
|
3000 |
" |
|
3001 |
self primitiveFailed |
|
295 | 3002 |
]. |
3003 |
! |
|
3004 |
||
3005 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3006 |
width:imageWidth height:imageHeight |
3007 |
x:srcx y:srcy |
|
3008 |
into:aDrawableId |
|
3009 |
x:dstx y:dsty |
|
3010 |
width:w height:h |
|
3011 |
with:aGCId |
|
295 | 3012 |
|
3013 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3014 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3015 |
Individual source pixels must have imageDepth bits. |
|
3016 |
It has to be checked elsewhere, that the server can do it with the given |
|
3017 |
depth - otherwise, primitive failure will be signalled. |
|
3018 |
Also it is assumed, that the colormap is setup correctly and the |
|
3019 |
colors are allocated - otherwise the colors may be wrong." |
|
3020 |
||
3021 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3022 |
width:imageWidth height:imageHeight |
3023 |
x:srcx y:srcy |
|
3024 |
into:aDrawableId |
|
3025 |
x:dstx y:dsty |
|
3026 |
width:w height:h |
|
3027 |
with:aGCId |
|
295 | 3028 |
|
3029 |
! |
|
3030 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3031 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3032 |
in:aDrawableId with:aGCId |
90 | 3033 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3034 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3035 |
|
3036 |
%{ /* NOCONTEXT */ |
|
3037 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3038 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3039 |
Window win; |
0 | 3040 |
int w, h, angle1, angle2; |
3041 |
double f; |
|
3042 |
||
97 | 3043 |
if (__isSmallInteger(startAngle)) |
1344 | 3044 |
angle1 = __intVal(startAngle) * 64; |
36 | 3045 |
else if (__isFloat(startAngle)) { |
1344 | 3046 |
f = __floatVal(startAngle); |
3047 |
angle1 = f * 64; |
|
0 | 3048 |
} |
97 | 3049 |
if (__isSmallInteger(angle)) |
1344 | 3050 |
angle2 = __intVal(angle) * 64; |
36 | 3051 |
else if (__isFloat(angle)) { |
1344 | 3052 |
f = __floatVal(angle); |
3053 |
angle2 = f * 64; |
|
0 | 3054 |
} |
1209 | 3055 |
if (ISCONNECTED |
3056 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3057 |
&& __isExternalAddress(aDrawableId) |
97 | 3058 |
&& __bothSmallInteger(x, y) |
3059 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3060 |
gc = _GCVal(aGCId); |
3061 |
win = _WindowVal(aDrawableId); |
|
3062 |
w = __intVal(width); |
|
3063 |
h = __intVal(height); |
|
3064 |
/* |
|
3065 |
* need this check here: some servers simply dump core with bad args |
|
3066 |
*/ |
|
3067 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
3068 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
3069 |
w, h, angle1, angle2); |
|
3070 |
} |
|
3071 |
RETURN ( self ); |
|
0 | 3072 |
} |
73 | 3073 |
%}. |
3074 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3075 |
self primitiveFailed |
3076 |
! |
|
3077 |
||
3078 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3079 |
"fill a polygon given by its points. |
3080 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3081 |
|
3082 |
|numberOfPoints| |
|
0 | 3083 |
|
3084 |
numberOfPoints := aPolygon size. |
|
3085 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3086 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3087 |
Window win; |
73 | 3088 |
OBJ point, x, y; |
3089 |
int i, num; |
|
3090 |
XPoint *points; |
|
3091 |
XPoint qPoints[100]; |
|
377 | 3092 |
int mustFree = 0; |
73 | 3093 |
|
1209 | 3094 |
if (ISCONNECTED |
3095 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3096 |
&& __isExternalAddress(aDrawableId) |
97 | 3097 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3098 |
gc = _GCVal(aGCId); |
3099 |
win = _WindowVal(aDrawableId); |
|
3100 |
num = __intVal(numberOfPoints); |
|
3101 |
if (num < 3) { |
|
3102 |
RETURN ( self ); |
|
3103 |
} |
|
3104 |
/* |
|
3105 |
* avoid (slow) malloc, if not many points |
|
3106 |
*/ |
|
3107 |
if (num > 100) { |
|
3108 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3109 |
if (! points) goto fail; |
|
3110 |
mustFree = 1; |
|
3111 |
} else |
|
3112 |
points = qPoints; |
|
3113 |
for (i=0; i<num; i++) { |
|
3114 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3115 |
if (! __isPoint(point)) goto fail; |
|
3116 |
x = _point_X(point); |
|
3117 |
y = _point_Y(point); |
|
3118 |
if (! __bothSmallInteger(x, y)) |
|
3119 |
goto fail; |
|
3120 |
points[i].x = __intVal(x); |
|
3121 |
points[i].y = __intVal(y); |
|
3122 |
} |
|
3123 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
3124 |
if (mustFree) |
|
3125 |
free(points); |
|
3126 |
RETURN ( self ); |
|
377 | 3127 |
|
0 | 3128 |
fail: ; |
1344 | 3129 |
if (mustFree) |
3130 |
free(points); |
|
0 | 3131 |
} |
73 | 3132 |
%}. |
3133 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3134 |
self primitiveFailed |
3135 |
! |
|
3136 |
||
295 | 3137 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3138 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3139 |
||
3140 |
%{ /* NOCONTEXT */ |
|
3141 |
||
3142 |
int w, h; |
|
3143 |
||
1209 | 3144 |
if (ISCONNECTED |
3145 |
&& __isExternalAddress(aGCId) |
|
295 | 3146 |
&& __isExternalAddress(aDrawableId) |
3147 |
&& __bothSmallInteger(x, y) |
|
3148 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3149 |
w = __intVal(width); |
3150 |
h = __intVal(height); |
|
3151 |
/* |
|
3152 |
* need this check here: some servers simply dump core with bad args |
|
3153 |
*/ |
|
3154 |
if ((w >= 0) && (h >= 0)) { |
|
3155 |
XFillRectangle(myDpy, |
|
3156 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3157 |
__intVal(x), __intVal(y), w, h); |
|
3158 |
} |
|
3159 |
RETURN ( self ); |
|
295 | 3160 |
} |
3161 |
%}. |
|
3162 |
"badGC, badDrawable or coordinates not integer" |
|
3163 |
self primitiveFailed |
|
43 | 3164 |
! |
3165 |
||
3166 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3167 |
width:imageWidth height:imageHeight |
3168 |
x:srcx y:srcy |
|
3169 |
into:aDrawableId |
|
3170 |
x:dstx y:dsty |
|
3171 |
width:w height:h |
|
3172 |
with:aGCId |
|
0 | 3173 |
|
132 | 3174 |
"since XPutImage may allocate huge amount of stack space |
3175 |
(some implementations use alloca), this must run with unlimited stack." |
|
3176 |
||
12 | 3177 |
%{ /* UNLIMITEDSTACK */ |
0 | 3178 |
|
43 | 3179 |
/* |
3180 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3181 |
* XPutImage |
|
3182 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3183 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3184 |
Window win; |
43 | 3185 |
XImage image; |
377 | 3186 |
int imgWdth; |
43 | 3187 |
|
1209 | 3188 |
if (ISCONNECTED |
3189 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3190 |
&& __isExternalAddress(aDrawableId) |
97 | 3191 |
&& __bothSmallInteger(srcx, srcy) |
3192 |
&& __bothSmallInteger(dstx, dsty) |
|
3193 |
&& __bothSmallInteger(w, h) |
|
3194 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3195 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3196 |
&& __isByteArray(imageBits)) { |
1344 | 3197 |
Display *dpy = myDpy; |
3198 |
||
3199 |
gc = _GCVal(aGCId); |
|
3200 |
win = _WindowVal(aDrawableId); |
|
3201 |
if (! gc || !win) |
|
3202 |
goto fail; |
|
46 | 3203 |
#ifdef ARGDEBUG |
1344 | 3204 |
printf("args ok\n"); |
46 | 3205 |
#endif |
1344 | 3206 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3207 |
image.width = imgWdth = __intVal(imageWidth); |
|
3208 |
image.height = __intVal(imageHeight); |
|
3209 |
image.xoffset = 0; |
|
3210 |
image.format = ZPixmap; |
|
3211 |
image.byte_order = MSBFirst; |
|
3212 |
image.bitmap_unit = 8; |
|
3213 |
image.bitmap_bit_order = MSBFirst; |
|
3214 |
image.bitmap_pad = 8; |
|
3215 |
image.depth = __intVal(imageDepth); |
|
3216 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3217 |
switch (image.bits_per_pixel) { |
|
3218 |
case 1: |
|
3219 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3220 |
break; |
|
3221 |
case 2: |
|
3222 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3223 |
break; |
|
3224 |
case 4: |
|
3225 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3226 |
break; |
|
3227 |
case 8: |
|
3228 |
image.bytes_per_line = imgWdth; |
|
3229 |
break; |
|
3230 |
case 16: |
|
3231 |
image.bytes_per_line = imgWdth*2; |
|
3232 |
break; |
|
3233 |
case 24: |
|
3234 |
image.bytes_per_line = imgWdth*3; |
|
3235 |
break; |
|
3236 |
case 32: |
|
3237 |
image.bytes_per_line = imgWdth*4; |
|
3238 |
break; |
|
3239 |
default: |
|
46 | 3240 |
#ifdef ARGDEBUG |
1344 | 3241 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3242 |
#endif |
1344 | 3243 |
goto fail; |
3244 |
} |
|
3245 |
image.red_mask = 0xFFFF; |
|
3246 |
image.green_mask = 0xFFFF; |
|
3247 |
image.blue_mask = 0xFFFF; |
|
3248 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
|
3249 |
__intVal(dstx), __intVal(dsty), |
|
3250 |
__intVal(w), __intVal(h)); |
|
3251 |
RETURN ( true ); |
|
43 | 3252 |
} |
46 | 3253 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3254 |
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
|
3255 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3256 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3257 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3258 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3259 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3260 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3261 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3262 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3263 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3264 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3265 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3266 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3267 |
#endif |
3268 |
||
0 | 3269 |
fail: ; |
3270 |
%} |
|
3271 |
. |
|
12 | 3272 |
^ false |
0 | 3273 |
! ! |
3274 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3275 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3276 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3277 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3278 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3279 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3280 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3281 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3282 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3283 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3284 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3285 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3286 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3287 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3288 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3289 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3290 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3291 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3292 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3293 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3294 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3295 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3296 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3297 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3298 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3299 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3300 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3301 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3302 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3303 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3304 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3305 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3306 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3307 |
gravityNotifyView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3308 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3309 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3310 |
"/ aView gravityNotify |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3311 |
! |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3312 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3313 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3314 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3315 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3316 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3317 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3318 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3319 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3320 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3321 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3322 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3323 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3324 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3325 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3326 |
reparentedView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3327 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3328 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3329 |
"/ aView reparented |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3330 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3331 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3332 |
resizeRequestView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3333 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3334 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3335 |
"/ aView resizeRequest |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3336 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3337 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3338 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3339 |
"sent when another X-client has created a selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3340 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3341 |
|
1344 | 3342 |
"/ |
3343 |
"/ workaround a bug in olvwm: it clears selections |
|
3344 |
"/ on window raise. |
|
3345 |
"/ In this case, keep my last own selection. |
|
3346 |
"/ |
|
3347 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3348 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3349 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3350 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3351 |
"/ noone is interrested in that ... |
1344 | 3352 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3353 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3354 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3355 |
selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3356 |
"sent when the server returns an answer from a request for a selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3357 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3358 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3359 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3360 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3361 |
propertyID == 0 ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3362 |
"invalid olvwm behavior" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3363 |
s := self getLastCopyBuffer |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3364 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3365 |
targetID == self atomIDOfSTRING ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3366 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3367 |
a returned string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3368 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3369 |
s := self getTextProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3370 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3371 |
(s endsWith:Character cr) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3372 |
s := s asStringCollection copyWith:'' |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3373 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3374 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3375 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3376 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3377 |
a returned object |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3378 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3379 |
s := self getObjectProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3380 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3381 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3382 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3383 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3384 |
(sensor := aView sensor) notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3385 |
sensor pasteFromClipBoard:s view:aView |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3386 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3387 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3388 |
if there is no sensor ... |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3389 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3390 |
aView pasteFromClipBoard:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3391 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3392 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3393 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3394 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3395 |
selectionRequest:propertyID target:targetID selection:selectionID from:windowID view:aView |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3396 |
"sent by some other X-client to ask for the selection. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3397 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3398 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3399 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3400 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3401 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3402 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3403 |
"/ the other one wants to know the size of our selection ... |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3404 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3405 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3406 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3407 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3408 |
setLengthProperty:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3409 |
value:s size |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3410 |
for:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3411 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3412 |
sendSelectionNotifySelection:selectionID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3413 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3414 |
target:targetID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3415 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3416 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3417 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3418 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3419 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3420 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3421 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3422 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3423 |
"/ the other view wants the selection as string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3424 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3425 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3426 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3427 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3428 |
sendSelection:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3429 |
property:propertyID |
1345 | 3430 |
target:targetID |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3431 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3432 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3433 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3434 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3435 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3436 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3437 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3438 |
"/ (assuming, that the other view knows how to handle it) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3439 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3440 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3441 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3442 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3443 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3444 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3445 |
sendSelection:(stream contents) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3446 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3447 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3448 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3449 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3450 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3451 |
|
86 | 3452 |
!XWorkstation methodsFor:'event handling'! |
0 | 3453 |
|
3454 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3455 |
"central event handling method: |
|
54 | 3456 |
get next event and send appropriate message to the sensor or view. |
0 | 3457 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3458 |
otherwise only events for the view with given id are processed. |
3459 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3460 |
handled." |
|
3461 |
||
54 | 3462 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3463 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3464 |
ex return |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3465 |
] do:[ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3466 |
self dispatchLastEvent. |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3467 |
] |
54 | 3468 |
]. |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3469 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3470 |
"Modified: 26.3.1997 / 19:00:41 / cg" |
12 | 3471 |
! |
3472 |
||
295 | 3473 |
dispatchExposeEventFor:aViewIdOrNil |
3474 |
"get next expose event and send appropriate message to the sensor or view. |
|
3475 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3476 |
otherwise only events for the view with given id are processed." |
|
3477 |
||
3478 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3479 |
! |
3480 |
||
3481 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3482 |
|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
|
3483 |
eventType| |
12 | 3484 |
|
3485 |
%{ /* STACK: 8000 */ |
|
3486 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3487 |
|
1209 | 3488 |
Display *dpy; |
135 | 3489 |
OBJ eB; |
3490 |
XEvent *ev; |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3491 |
int ev_x, ev_y; |
135 | 3492 |
|
3493 |
# define ae ((XAnyEvent *)ev) |
|
3494 |
# define ee ((XExposeEvent *)ev) |
|
3495 |
# define ke ((XKeyPressedEvent *)ev) |
|
3496 |
# define be ((XButtonPressedEvent *)ev) |
|
3497 |
# define ce ((XConfigureEvent *)ev) |
|
3498 |
# define me ((XMotionEvent *)ev) |
|
3499 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3500 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3501 |
# define de ((XDestroyWindowEvent *)ev) |
|
3502 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3503 |
# define mape ((XMappingEvent *)ev) |
135 | 3504 |
|
0 | 3505 |
KeySym keySym; |
3506 |
unsigned char buffer[10]; |
|
3507 |
int i, nchars; |
|
3508 |
char *keySymString; |
|
3509 |
char keySymStringBuffer[32]; |
|
3510 |
unsigned nextMultiClickTime; |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3511 |
OBJ upDown, t; |
115 | 3512 |
|
3513 |
struct inlineCache *ipS; |
|
0 | 3514 |
static struct inlineCache vid = _ILC1; |
12 | 3515 |
|
3516 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
3517 |
static struct inlineCache gexpS = _ILC6; |
12 | 3518 |
static struct inlineCache nexpS = _ILC1; |
3519 |
static struct inlineCache motS = _ILC4; |
|
3520 |
static struct inlineCache bpS = _ILC4; |
|
3521 |
static struct inlineCache bmpS = _ILC4; |
|
3522 |
static struct inlineCache bspS = _ILC4; |
|
3523 |
static struct inlineCache brS = _ILC4; |
|
3524 |
static struct inlineCache focInS = _ILC1; |
|
3525 |
static struct inlineCache focOutS = _ILC1; |
|
3526 |
static struct inlineCache peS = _ILC4; |
|
3527 |
static struct inlineCache plS = _ILC2; |
|
54 | 3528 |
static struct inlineCache termS = _ILC1; |
3529 |
static struct inlineCache savtermS = _ILC1; |
|
3530 |
static struct inlineCache destrS = _ILC1; |
|
3531 |
static struct inlineCache unmapS = _ILC1; |
|
3532 |
static struct inlineCache mapS = _ILC1; |
|
3533 |
static struct inlineCache confS = _ILC5; |
|
70 | 3534 |
static struct inlineCache coveredS = _ILC2; |
12 | 3535 |
|
3536 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3537 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3538 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3539 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3540 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3541 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3542 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3543 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3544 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3545 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3546 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3547 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3548 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3549 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3550 |
static struct inlineCache mapping = _ILC2; |
70 | 3551 |
static struct inlineCache vis = _ILC1; |
12 | 3552 |
|
3553 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3554 |
static struct inlineCache skrS = _ILC4; |
12 | 3555 |
|
1209 | 3556 |
if (! ISCONNECTED) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3557 |
RETURN (false); |
1209 | 3558 |
} |
3559 |
||
3560 |
dpy = myDpy; |
|
3561 |
||
1210 | 3562 |
eB = __INST(eventBuffer); |
3563 |
||
135 | 3564 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3565 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3566 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3567 |
printf("DISPLAY: no eventBuffer\n"); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3568 |
RETURN (false); |
135 | 3569 |
} |
3570 |
||
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3571 |
/* |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3572 |
* very often, its another event for the same view ... |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3573 |
* avoid creation & lookup then. |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3574 |
*/ |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3575 |
if ((t = __INST(lastId)) != nil) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3576 |
if (__isExternalAddress(t)) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3577 |
if (_WindowVal(t) == ae->window) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3578 |
theView = __INST(lastView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3579 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3580 |
} |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3581 |
} |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3582 |
|
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3583 |
if (theView == nil) { |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3584 |
windowID = __MKOBJ(ae->window); |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3585 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3586 |
/* |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3587 |
* #viewFromId: could lead to a GC - refetch event ptr |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3588 |
*/ |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3589 |
eB = __INST(eventBuffer); |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3590 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3591 |
} |
12 | 3592 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3593 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3594 |
RETURN (nil); |
12 | 3595 |
} |
3596 |
||
3597 |
/* |
|
3598 |
* key, button and pointer events are sent to the sensor, |
|
3599 |
* or (if there is none) to the delegate. |
|
3600 |
* or (if there is none) to the view. |
|
26 | 3601 |
* |
3602 |
* expose events are sent to the sensor, |
|
3603 |
* or (if there is none) to the view |
|
3604 |
* |
|
12 | 3605 |
* sensor and delegate get view as additional argument |
115 | 3606 |
* all of this has been taken out of here to corresponding methods |
3607 |
* in DeviceWorkstation. |
|
12 | 3608 |
*/ |
90 | 3609 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3610 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3611 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3612 |
#endif |
135 | 3613 |
switch (ev->type) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3614 |
case KeyRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3615 |
symS = @symbol(keyRelease:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3616 |
ipS = &skrS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3617 |
upDown = false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3618 |
goto keyPressAndRelease; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3619 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3620 |
case KeyPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3621 |
symS = @symbol(keyPress:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3622 |
ipS = &skpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3623 |
upDown = true; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3624 |
/* FALL INTO */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3625 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3626 |
keyPressAndRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3627 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3628 |
__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
|
3629 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3630 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3631 |
__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
|
3632 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3633 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3634 |
__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
|
3635 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3636 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3637 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3638 |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3639 |
ev_x = ke->x; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3640 |
ev_y = ke->y; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3641 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3642 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3643 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3644 |
if (nchars |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3645 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3646 |
|| (buffer[0] >= 0x80))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3647 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3648 |
keySymString = NULL; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3649 |
} else { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3650 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3651 |
switch (keySym) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3652 |
case XK_Control_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3653 |
case XK_Control_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3654 |
__INST(ctrlDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3655 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3656 |
case XK_Shift_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3657 |
case XK_Shift_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3658 |
__INST(shiftDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3659 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3660 |
case XK_Meta_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3661 |
case XK_Meta_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3662 |
__INST(metaDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3663 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3664 |
case XK_Alt_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3665 |
case XK_Alt_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3666 |
__INST(altDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3667 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3668 |
} |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3669 |
#endif |
150 | 3670 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3671 |
keySymString = XKeysymToString(keySym); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3672 |
if (keySymString) { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3673 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3674 |
if (keySymString[0] == 'D') { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3675 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3676 |
* remove underscore, dont want it in symbols |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3677 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3678 |
if (strcmp(keySymString, "Delete_line") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3679 |
keySymString = "DeleteLine"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3680 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3681 |
keySymString = "DeleteWord"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3682 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3683 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3684 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3685 |
* make names compatible |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3686 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3687 |
if (strcmp(keySymString, "Down") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3688 |
keySymString = "CursorDown"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3689 |
} else if (strcmp(keySymString, "Up") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3690 |
keySymString = "CursorUp"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3691 |
} else if (strcmp(keySymString, "Left") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3692 |
keySymString = "CursorLeft"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3693 |
} else if (strcmp(keySymString, "Right") == 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3694 |
keySymString = "CursorRight"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3695 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3696 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3697 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3698 |
arg = __MKSTRING(keySymString); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3699 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3700 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3701 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3702 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3703 |
if (arg == nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3704 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3705 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3706 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3707 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3708 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3709 |
arg, |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3710 |
__MKSMALLINT(ev_x), |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3711 |
__MKSMALLINT(ev_y), |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3712 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3713 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3714 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3715 |
case ButtonPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3716 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3717 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3718 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3719 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3720 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3721 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3722 |
else |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3723 |
nextMultiClickTime = 0; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3724 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3725 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3726 |
if ((t = __INST(multiClickTime)) != nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3727 |
int _multiClickTime; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3728 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3729 |
_multiClickTime = __longIntVal(t); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3730 |
if (be->time < _multiClickTime) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3731 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3732 |
/* |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3733 |
* MKUINT could lead to a GC - refetch event ptr |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3734 |
*/ |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3735 |
eB = __INST(eventBuffer); |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3736 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3737 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3738 |
ipS = &bmpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3739 |
symS = @symbol(buttonMultiPress:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3740 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3741 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3742 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3743 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3744 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3745 |
/* |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3746 |
* MKUINT could lead to a GC - refetch event ptr |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3747 |
*/ |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3748 |
eB = __INST(eventBuffer); |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3749 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3750 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
3751 |
#ifdef NO_LONGER |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3752 |
if (be->state & ShiftMask) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3753 |
ipS = &bspS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3754 |
symS = @symbol(buttonShiftPress:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3755 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3756 |
} |
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
3757 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3758 |
ipS = &bpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3759 |
symS = @symbol(buttonPress:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3760 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3761 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3762 |
/* NOT REACHED */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3763 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3764 |
case ButtonRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3765 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3766 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3767 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3768 |
ipS = &brS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3769 |
symS = @symbol(buttonRelease:x:y:view:); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3770 |
/* fall into */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3771 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3772 |
sendButtonEvent: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3773 |
butt = __MKSMALLINT(be->button); |
12 | 3774 |
#ifdef NOTDEF |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3775 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3776 |
* this allows operation with single button mouses: meta-click is always Button 2 |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3777 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3778 |
if (__INST(metaDown) == true) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3779 |
butt = __MKSMALLINT(2); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3780 |
else |
0 | 3781 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3782 |
butt = __AT_(__INST(buttonTranslation), butt); |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3783 |
/* |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3784 |
* #at: could lead to a GC - refetch event ptr |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3785 |
*/ |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3786 |
eB = __INST(eventBuffer); |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3787 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3788 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3789 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3790 |
(*(*ipS).ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3791 |
symS, nil, ipS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3792 |
butt, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3793 |
__MKSMALLINT(ke->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3794 |
__MKSMALLINT(ke->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3795 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3796 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3797 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3798 |
case MotionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3799 |
if (__INST(motionEventCompression) != false) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3800 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3801 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3802 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3803 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3804 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 3805 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3806 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3807 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3808 |
__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
|
3809 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3810 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3811 |
__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
|
3812 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3813 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3814 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3815 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3816 |
(*motS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3817 |
@symbol(buttonMotion:x:y:view:), nil, &motS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3818 |
__MKSMALLINT(me->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3819 |
__MKSMALLINT(me->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3820 |
__MKSMALLINT(me->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3821 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3822 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3823 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3824 |
case FocusIn: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3825 |
(*focInS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3826 |
@symbol(focusInView:), nil, &focInS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3827 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3828 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3829 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3830 |
case FocusOut: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3831 |
(*focOutS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3832 |
@symbol(focusOutView:), nil, &focOutS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3833 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3834 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3835 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3836 |
case EnterNotify: |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3837 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3838 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3839 |
__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
|
3840 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3841 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3842 |
__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
|
3843 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3844 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3845 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3846 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3847 |
(*peS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3848 |
@symbol(pointerEnter:x:y:view:), nil, &peS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3849 |
__MKSMALLINT(ewe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3850 |
__MKSMALLINT(ewe->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3851 |
__MKSMALLINT(ewe->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3852 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3853 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3854 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3855 |
case LeaveNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3856 |
(*plS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3857 |
@symbol(pointerLeave:view:), nil, &plS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3858 |
__MKSMALLINT(lwe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3859 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3860 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3861 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3862 |
case GraphicsExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3863 |
(*gexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3864 |
@symbol(graphicsExposeX:y:width:height:final:view:), nil, &gexpS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3865 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3866 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3867 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3868 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3869 |
ee->count == 0 ? true : false, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3870 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3871 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3872 |
if (ee->count != 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3873 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3874 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3875 |
/* fall into */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3876 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3877 |
case NoExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3878 |
(*nexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3879 |
@symbol(noExposeView:), nil, &nexpS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3880 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3881 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3882 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3883 |
case Expose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3884 |
(*expS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3885 |
@symbol(exposeX:y:width:height:view:), nil, &expS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3886 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3887 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3888 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3889 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3890 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3891 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3892 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3893 |
case ConfigureNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3894 |
if (ce->above != None) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3895 |
siblingID = __MKOBJ(ce->above); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3896 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, siblingID); |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3897 |
/* |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3898 |
* MKOBJ or #viewFromId: could lead to a GC - refetch event ptr |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3899 |
*/ |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3900 |
eB = __INST(eventBuffer); |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3901 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3902 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3903 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3904 |
(*confS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3905 |
@symbol(configureX:y:width:height:view:), nil, &confS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3906 |
__MKSMALLINT(ce->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3907 |
__MKSMALLINT(ce->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3908 |
__MKSMALLINT(ce->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3909 |
__MKSMALLINT(ce->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3910 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3911 |
if (sibling != nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3912 |
(*coveredS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3913 |
@symbol(coveredBy:view:), nil, &coveredS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3914 |
theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3915 |
sibling); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3916 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3917 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3918 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3919 |
case ClientMessage: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3920 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3921 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3922 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3923 |
(*termS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3924 |
@symbol(terminateView:), nil, &termS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3925 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3926 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3927 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3928 |
(*savtermS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3929 |
@symbol(saveAndTerminateView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3930 |
, nil, &savtermS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3931 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3932 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3933 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3934 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3935 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3936 |
case DestroyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3937 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3938 |
, nil, &destrS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3939 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3940 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3941 |
case UnmapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3942 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3943 |
, nil, &unmapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3944 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3945 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3946 |
case MapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3947 |
(*mapS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3948 |
@symbol(mappedView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3949 |
, nil, &mapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3950 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3951 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3952 |
case KeymapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3953 |
(*keymap.ilc_func)(theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3954 |
@symbol(keyMapChange) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3955 |
, nil, &keymap); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3956 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3957 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3958 |
case VisibilityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3959 |
switch (ve->state) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3960 |
case VisibilityUnobscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3961 |
arg = @symbol(unobscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3962 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3963 |
case VisibilityPartiallyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3964 |
arg = @symbol(partiallyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3965 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3966 |
case VisibilityFullyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3967 |
arg = @symbol(fullyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3968 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3969 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3970 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:), nil, &vis, arg); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3971 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3972 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3973 |
case CreateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3974 |
(*created.ilc_func)(self, @symbol(createdView:), nil, &created, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3975 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3976 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3977 |
case MapRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3978 |
(*mapReq.ilc_func)(self, @symbol(mapRequestView:), nil, &mapReq, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3979 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3980 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3981 |
case ReparentNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3982 |
(*repar.ilc_func)(self, @symbol(reparentedView:), nil, &repar, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3983 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3984 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3985 |
case ConfigureRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3986 |
(*confReq.ilc_func)(self, @symbol(configureRequestView:), nil, &confReq, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3987 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3988 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3989 |
case GravityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3990 |
(*gravNotify.ilc_func)(self, @symbol(gravityNotifyView:), nil, &resReq, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3991 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3992 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3993 |
case ResizeRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3994 |
(*resReq.ilc_func)(self, @symbol(resizeRequestView:), nil, &resReq, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3995 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3996 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3997 |
case CirculateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3998 |
(*circNotify.ilc_func)(self, @symbol(circulateNotifyView:), nil, &circNotify, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3999 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4000 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4001 |
case CirculateRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4002 |
(*circReq.ilc_func)(self, @symbol(circulateRequestView:), nil, &circReq, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4003 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4004 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4005 |
case PropertyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4006 |
(*prop.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4007 |
@symbol(propertyChangeView) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4008 |
, nil, &prop, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4009 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4010 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4011 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4012 |
case SelectionClear: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4013 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4014 |
(*selClear.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4015 |
@symbol(selectionClear:view:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4016 |
, nil, &selClear, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4017 |
selectionID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4018 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4019 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4020 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4021 |
case SelectionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4022 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4023 |
* returned selection value (answer from SelectionRequest) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4024 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4025 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4026 |
ev->xselection.property, ev->xselection.target, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4027 |
ev->xselection.selection, ev->xselection.requestor)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4028 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4029 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4030 |
targetID = __MKATOMOBJ(ev->xselection.target); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4031 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4032 |
requestorID = __MKOBJ(ev->xselection.requestor); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4033 |
(*selNotify.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4034 |
@symbol(selectionNotify:target:selection:from:view:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4035 |
, nil, &selNotify, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4036 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4037 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4038 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4039 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4040 |
case SelectionRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4041 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4042 |
* someone wants the selection |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4043 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4044 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4045 |
ev->xselectionrequest.property, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4046 |
ev->xselectionrequest.target, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4047 |
ev->xselectionrequest.selection, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4048 |
ev->xselectionrequest.requestor)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4049 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4050 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4051 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4052 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4053 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4054 |
(*selReq.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4055 |
@symbol(selectionRequest:target:selection:from:view:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4056 |
, nil, &selReq, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4057 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4058 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4059 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4060 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4061 |
case ColormapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4062 |
(*colormap.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4063 |
@symbol(colorMapChangeView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4064 |
, nil, &colormap, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4065 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4066 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4067 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4068 |
case MappingNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4069 |
switch(mape->request) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4070 |
case MappingModifier: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4071 |
arg = @symbol(mappingModifier); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4072 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4073 |
case MappingKeyboard: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4074 |
arg = @symbol(mappingKeyboard); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4075 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4076 |
case MappingPointer: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4077 |
arg = @symbol(mappingPointer); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4078 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4079 |
default: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4080 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4081 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4082 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4083 |
(*mapping.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4084 |
@symbol(mappingChanged:event:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4085 |
, nil, &mapping, arg, eB); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4086 |
break; |
0 | 4087 |
} |
135 | 4088 |
#undef ae |
0 | 4089 |
#undef ee |
4090 |
#undef ke |
|
4091 |
#undef be |
|
4092 |
#undef ce |
|
4093 |
#undef me |
|
4094 |
#undef ewe |
|
4095 |
#undef lwe |
|
4096 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4097 |
#undef mape |
0 | 4098 |
%} |
4099 |
. |
|
4100 |
^ true |
|
4101 |
! |
|
4102 |
||
1344 | 4103 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4104 |
"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
|
4105 |
(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
|
4106 |
This code is somewhat special, since X has a concept of graphic |
295 | 4107 |
expose events (which are sent after a bitblt). After such a bitblt, |
4108 |
we only handle exposes until the graphicsExpose arrives. |
|
4109 |
Other systems may not need such a kludge" |
|
4110 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4111 |
"interested in exposes only ?" |
295 | 4112 |
dispatchingExpose notNil ifTrue:[ |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4113 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4114 |
self dispatchExposeEventFor:dispatchingExpose |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4115 |
]. |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4116 |
^ self |
295 | 4117 |
]. |
4118 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4119 |
[self eventPendingWithSync:false] whileTrue:[ |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4120 |
(self getEventFor:nil withMask:nil) ifTrue:[ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4121 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4122 |
ex return |
1491 | 4123 |
] do:[ |
4124 |
self dispatchLastEvent |
|
4125 |
] |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4126 |
]. |
295 | 4127 |
] |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4128 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4129 |
"Modified: 26.3.1997 / 19:04:17 / cg" |
295 | 4130 |
! |
4131 |
||
1344 | 4132 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4133 |
"dispose (throw away) specific events. If aWindowId is nil, |
4134 |
events matching the mask are thrown away regardless of which |
|
4135 |
view they are for. Otherwise, only matching events for that |
|
4136 |
view are flushed." |
|
0 | 4137 |
|
4138 |
%{ /* NOCONTEXT */ |
|
4139 |
||
4140 |
XEvent ev; |
|
4141 |
Window win; |
|
4142 |
||
1209 | 4143 |
if (ISCONNECTED |
4144 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4145 |
Display *dpy = myDpy; |
4146 |
||
4147 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4148 |
win = _WindowVal(aWindowIdOrNil); |
|
4149 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4150 |
} else { |
|
4151 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4152 |
} |
|
4153 |
RETURN ( self ); |
|
0 | 4154 |
} |
4155 |
%} |
|
4156 |
. |
|
4157 |
self primitiveFailed |
|
4158 |
! |
|
4159 |
||
1344 | 4160 |
eventMaskFor:anEventSymbol |
295 | 4161 |
"return the eventMask bit-constant corresponding to an event symbol" |
4162 |
||
4163 |
%{ /* NOCONTEXT */ |
|
4164 |
||
4165 |
int m = 0; |
|
4166 |
||
4167 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4168 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4169 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4170 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4171 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4172 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4173 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4174 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4175 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4176 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4177 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4178 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4179 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4180 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4181 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4182 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4183 |
RETURN (__MKSMALLINT(m)); |
295 | 4184 |
%} |
4185 |
! |
|
4186 |
||
1344 | 4187 |
eventPending |
310 | 4188 |
"return true, if any event is pending. |
4189 |
This looks for both the internal queue and the display connection." |
|
12 | 4190 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4191 |
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
|
4192 |
|
12 | 4193 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4194 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4195 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4196 |
^ self eventPendingWithSync:false |
0 | 4197 |
! |
4198 |
||
1344 | 4199 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4200 |
"return true, if a specific event is pending" |
4201 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4202 |
^ 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
|
4203 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4204 |
|
1344 | 4205 |
eventPendingWithSync:doSync |
7 | 4206 |
"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
|
4207 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4208 |
before checking." |
0 | 4209 |
|
12 | 4210 |
%{ /* UNLIMITEDSTACK */ |
0 | 4211 |
|
150 | 4212 |
if (ISCONNECTED) { |
1344 | 4213 |
Display *dpy = myDpy; |
4214 |
||
4215 |
if (doSync == true) { |
|
4216 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4217 |
} |
|
4218 |
if (XPending(dpy)) { |
|
4219 |
RETURN (true); |
|
4220 |
} |
|
150 | 4221 |
} |
4222 |
RETURN ( false ); |
|
0 | 4223 |
%} |
4224 |
! |
|
4225 |
||
1344 | 4226 |
eventQueued |
341 | 4227 |
"return true, if any event is queued" |
4228 |
||
4229 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 4230 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 4231 |
]. |
4232 |
^ self eventQueuedAlready |
|
4233 |
||
4234 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
4235 |
! |
|
4236 |
||
1344 | 4237 |
eventQueuedAlready |
341 | 4238 |
"return true, if any event is queued internally. |
4239 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
4240 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
4241 |
the display connection)." |
|
4242 |
||
4243 |
%{ /* UNLIMITEDSTACK */ |
|
4244 |
||
4245 |
if (ISCONNECTED) { |
|
1344 | 4246 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
4247 |
RETURN (true); |
|
4248 |
} |
|
341 | 4249 |
} |
4250 |
RETURN ( false ); |
|
4251 |
%} |
|
4252 |
! |
|
4253 |
||
1344 | 4254 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 4255 |
"return true, if any of the masked events is pending" |
4256 |
||
4257 |
%{ /* UNLIMITEDSTACK */ |
|
4258 |
||
4259 |
XEvent ev; |
|
4260 |
Window win; |
|
4261 |
int thereIsOne; |
|
4262 |
||
4263 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 4264 |
Display *dpy = myDpy; |
4265 |
||
4266 |
if (doSync == true) { |
|
4267 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4268 |
} |
|
4269 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4270 |
win = _WindowVal(aWindowIdOrNil); |
|
4271 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
4272 |
} else { |
|
4273 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
4274 |
} |
|
4275 |
if (thereIsOne) { |
|
4276 |
XPutBackEvent(dpy, &ev); |
|
4277 |
RETURN ( true ); |
|
4278 |
} |
|
295 | 4279 |
} |
4280 |
RETURN ( false ); |
|
4281 |
%} |
|
4282 |
! |
|
4283 |
||
1344 | 4284 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 4285 |
"return true, if any expose event is pending for a specific view, |
4286 |
or any view (if the arg is nil). |
|
4287 |
This is an X specific, only required after a scroll operation." |
|
7 | 4288 |
|
12 | 4289 |
%{ /* UNLIMITEDSTACK */ |
7 | 4290 |
|
4291 |
XEvent ev; |
|
4292 |
Window win; |
|
81 | 4293 |
int thereIsOne; |
4294 |
||
150 | 4295 |
if (ISCONNECTED) { |
1344 | 4296 |
Display *dpy = myDpy; |
4297 |
||
4298 |
if (doSync == true) { |
|
4299 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4300 |
} |
|
4301 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4302 |
win = _WindowVal(aWindowIdOrNil); |
|
4303 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
4304 |
} else { |
|
4305 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
4306 |
} |
|
4307 |
if (thereIsOne) { |
|
4308 |
XPutBackEvent(dpy, &ev); |
|
4309 |
RETURN ( true ); |
|
4310 |
} |
|
81 | 4311 |
} |
4312 |
RETURN ( false ); |
|
4313 |
%} |
|
4314 |
! |
|
4315 |
||
1344 | 4316 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 4317 |
"read next event - put into local eventBuffer. |
4318 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
4319 |
otherwise only events for that specific view will be fetched. |
|
4320 |
Returns true, if there was an event, false otherwise. |
|
4321 |
This method may block - so you better check for pending events |
|
4322 |
before calling for it. |
|
4323 |
||
4324 |
Sorry I had to split dispatch into this fetch method and an extra |
|
4325 |
handle method to allow unlimitedstack here. |
|
4326 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
4327 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
4328 |
" |
|
81 | 4329 |
|
4330 |
%{ /* UNLIMITEDSTACK */ |
|
4331 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4332 |
Display *dpy; |
295 | 4333 |
Window win, wWanted; |
4334 |
int evMask; |
|
4335 |
OBJ eB; |
|
4336 |
XEvent *ev; |
|
4337 |
||
4338 |
if (! ISCONNECTED) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4339 |
RETURN (false); |
295 | 4340 |
} |
4341 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4342 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4343 |
|
555 | 4344 |
eB = __INST(eventBuffer); |
295 | 4345 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4346 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4347 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4348 |
printf("DISPLAY: no eventBuffer\n"); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4349 |
RETURN (false); |
295 | 4350 |
} |
4351 |
ev->type = 0; |
|
4352 |
||
4353 |
if (__isSmallInteger(eventMask)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4354 |
evMask = __intVal(eventMask); |
295 | 4355 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4356 |
evMask = ~0; |
295 | 4357 |
} |
4358 |
||
4359 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4360 |
wWanted = _WindowVal(aViewIdOrNil); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4361 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4362 |
RETURN ( true ); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4363 |
} |
295 | 4364 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4365 |
if (evMask == ~0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4366 |
XNextEvent(dpy, ev); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4367 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4368 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4369 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4370 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4371 |
} |
295 | 4372 |
} |
4373 |
%}. |
|
4374 |
^ false |
|
4375 |
! |
|
4376 |
||
1344 | 4377 |
handleAllEvents |
295 | 4378 |
"from now on, handle any kind of event" |
4379 |
||
4380 |
dispatchingExpose := nil |
|
4381 |
! |
|
4382 |
||
1344 | 4383 |
handleExposeOnlyFor:aView |
295 | 4384 |
"from now on, handle expose events only" |
4385 |
||
4386 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4387 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4388 |
|
1344 | 4389 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4390 |
"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
|
4391 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4392 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4393 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 4394 |
self refreshKeyboardMapping:eB. |
4395 |
"Maybe some of our modifiers have been changed" |
|
4396 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4397 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4398 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4399 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4400 |
! |
4401 |
||
1344 | 4402 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4403 |
"tell X that we are only interested in events from aMask, which |
295 | 4404 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4405 |
||
4406 |
%{ /* NOCONTEXT */ |
|
4407 |
||
4408 |
int mask; |
|
4409 |
||
1209 | 4410 |
if (ISCONNECTED |
4411 |
&& __isExternalAddress(aWindowId) |
|
295 | 4412 |
&& __isSmallInteger(aMask)) { |
1344 | 4413 |
mask = __intVal(aMask); |
295 | 4414 |
|
4415 |
#ifdef OLD |
|
1344 | 4416 |
/* these may not be disabled */ |
4417 |
mask |= ExposureMask | StructureNotifyMask | |
|
4418 |
KeyPressMask | KeyReleaseMask | |
|
4419 |
EnterWindowMask | LeaveWindowMask | |
|
4420 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 4421 |
#endif |
4422 |
||
1344 | 4423 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
4424 |
RETURN ( self ); |
|
295 | 4425 |
} |
4426 |
%} |
|
4427 |
. |
|
4428 |
self primitiveFailed |
|
4429 |
! |
|
4430 |
||
1344 | 4431 |
startDispatch |
295 | 4432 |
"redefined to clear dispatchingExpose, which is a special X feature" |
4433 |
||
4434 |
dispatching ifTrue:[^ self]. |
|
4435 |
dispatchingExpose := nil. |
|
4436 |
super startDispatch |
|
0 | 4437 |
! ! |
295 | 4438 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4439 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4440 |
|
1344 | 4441 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4442 |
"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
|
4443 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4444 |
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
|
4445 |
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
|
4446 |
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
|
4447 |
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
|
4448 |
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
|
4449 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4450 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4451 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4452 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4453 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4454 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4455 |
if (__isSmallInteger(stateMask)) { |
1344 | 4456 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4457 |
} else { |
1344 | 4458 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4459 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4460 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4461 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4462 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4463 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4464 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 4465 |
Display *dpy = myDpy; |
4466 |
||
4467 |
XEvent ev; |
|
4468 |
Window target; |
|
4469 |
Status result; |
|
4470 |
KeySym keySym, *syms; |
|
4471 |
int screen = __intVal(__INST(screen)); |
|
4472 |
char s[2]; |
|
4473 |
int nSyms; |
|
4474 |
||
4475 |
if ((typeSymbol == @symbol(keyPress)) |
|
4476 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
4477 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
4478 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
4479 |
} else { |
|
4480 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
4481 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
4482 |
s[1] = '\0'; |
|
4483 |
keySym = XStringToKeysym(s); |
|
4484 |
} else { |
|
4485 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
4486 |
} |
|
4487 |
} |
|
4488 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
4489 |
||
4490 |
if (stateMask == nil) { |
|
4491 |
/* |
|
4492 |
* get the modifier from the keySym |
|
4493 |
*/ |
|
4494 |
nSyms = 0; |
|
4495 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
4496 |
if (syms) { |
|
4497 |
int i; |
|
4498 |
||
4499 |
for (i=0; i<nSyms; i++) { |
|
4500 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4501 |
#ifdef MODIFIERDEBUG |
1344 | 4502 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4503 |
#endif |
1344 | 4504 |
if (i) state = (1 << (i-1)); |
4505 |
break; |
|
4506 |
} |
|
4507 |
} |
|
4508 |
XFree(syms); |
|
4509 |
} |
|
4510 |
} |
|
4511 |
} else { |
|
4512 |
if ((typeSymbol == @symbol(buttonPress)) |
|
4513 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
4514 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
4515 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
4516 |
} else { |
|
4517 |
ev.xbutton.button = 1; |
|
4518 |
} |
|
4519 |
} else { |
|
4520 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
4521 |
RETURN (false); |
|
4522 |
} |
|
4523 |
} |
|
4524 |
||
4525 |
if (typeSymbol == @symbol(keyPress)) |
|
4526 |
ev.xany.type = KeyPress; |
|
4527 |
else if (typeSymbol == @symbol(keyRelease)) |
|
4528 |
ev.xany.type = KeyRelease; |
|
4529 |
else if (typeSymbol == @symbol(buttonPress)) |
|
4530 |
ev.xany.type = ButtonPress; |
|
4531 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
4532 |
ev.xany.type = ButtonRelease; |
|
4533 |
||
4534 |
if (__isExternalAddress(targetId)) { |
|
4535 |
target = _WindowVal(targetId); |
|
4536 |
} else { |
|
4537 |
target = (Window) __longIntVal(targetId); |
|
4538 |
} |
|
4539 |
ev.xkey.window = target; |
|
4540 |
ev.xkey.same_screen = 1; |
|
4541 |
ev.xkey.subwindow = 0; |
|
4542 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
4543 |
ev.xkey.x = __intVal(xPos); |
|
4544 |
ev.xkey.y = __intVal(yPos); |
|
4545 |
ev.xkey.state = state; |
|
4546 |
ev.xkey.time = CurrentTime; |
|
4547 |
||
4548 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
|
4549 |
if ((result == BadValue) || (result == BadWindow)) { |
|
4550 |
DPRINTF(("bad status\n")); |
|
4551 |
RETURN ( false ) |
|
4552 |
} |
|
4553 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4554 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4555 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4556 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4557 |
^ false |
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 |
|
1344 | 4560 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4561 |
"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
|
4562 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4563 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4564 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 4565 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4566 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4567 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4568 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4569 |
aCharacterOrString isString ifTrue:[ |
1344 | 4570 |
aCharacterOrString do:[:char | |
4571 |
self simulateKeyboardInput:char inViewId:viewId |
|
4572 |
]. |
|
4573 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4574 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4575 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4576 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4577 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4578 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4579 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 4580 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4581 |
] ifFalse:[ |
1344 | 4582 |
(aCharacterOrString == Character tab) ifTrue:[ |
4583 |
code := #Tab |
|
4584 |
] ifFalse:[ |
|
4585 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4586 |
code := #Escape |
|
4587 |
] |
|
4588 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4589 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4590 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4591 |
control ifTrue:[ |
1344 | 4592 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4593 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4594 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4595 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4596 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4597 |
"/ (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
|
4598 |
"/ 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
|
4599 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4600 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4601 |
code isNumber ifTrue:[ |
1344 | 4602 |
code >= $A asciiValue ifTrue:[ |
4603 |
code <= $Z asciiValue ifTrue:[ |
|
4604 |
state := self shiftMask |
|
4605 |
] |
|
4606 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4607 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4608 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4609 |
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
|
4610 |
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
|
4611 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4612 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4613 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4614 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4615 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4616 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4617 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4618 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4619 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4620 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4621 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4622 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4623 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4624 |
|
295 | 4625 |
!XWorkstation methodsFor:'font stuff'! |
4626 |
||
1344 | 4627 |
createFontFor:aFontName |
295 | 4628 |
"a basic method for X-font allocation; this method allows |
4629 |
any font to be aquired (even those not conforming to |
|
4630 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4631 |
||
4632 |
%{ /* UNLIMITEDSTACK */ |
|
4633 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4634 |
||
4635 |
XFontStruct *newFont; |
|
4636 |
||
4637 |
if (ISCONNECTED) { |
|
1344 | 4638 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
4639 |
BEGIN_INTERRUPTSBLOCKED |
|
4640 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4641 |
#ifdef COUNT_RESOURCES |
1344 | 4642 |
if (newFont) |
4643 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4644 |
#endif |
1344 | 4645 |
END_INTERRUPTSBLOCKED |
4646 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4647 |
} |
|
295 | 4648 |
} |
4649 |
%}. |
|
4650 |
^ nil |
|
4651 |
! |
|
4652 |
||
1344 | 4653 |
decomposeXFontName:aString into:aBlock |
295 | 4654 |
"extract family, face, style and size from an |
4655 |
X-font name |
|
4656 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4657 |
evaluate aBlock with these" |
|
4658 |
||
4659 |
|origin family face style moreStyle skip fheight size |
|
4660 |
resX resY x1 x2 coding start end | |
|
4661 |
||
4662 |
aString isNil ifTrue:[^ false]. |
|
4663 |
(aString startsWith:'-') ifFalse:[ |
|
1344 | 4664 |
" |
4665 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
4666 |
" |
|
4667 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
4668 |
end := aString indexOf:$- startingAt:1. |
|
4669 |
family := aString copyFrom:1 to:(end - 1). |
|
4670 |
start := end + 1. |
|
4671 |
end := aString indexOf:$- startingAt:start. |
|
4672 |
style := aString copyFrom:start to:(end - 1). |
|
4673 |
start := end + 1. |
|
4674 |
size := aString copyFrom:start. |
|
4675 |
size := (Number readFromString:size onError:[^false]). |
|
4676 |
aBlock value:family value:nil value:style value:size value:nil. |
|
4677 |
^ true. |
|
4678 |
]. |
|
4679 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
4680 |
" |
|
4681 |
something like lucidasans-24 |
|
4682 |
" |
|
4683 |
end := aString indexOf:$- startingAt:1. |
|
4684 |
||
4685 |
family := aString copyFrom:1 to:(end - 1). |
|
4686 |
start := end + 1. |
|
4687 |
size := aString copyFrom:start. |
|
4688 |
size := (Number readFromString:size onError:[^false]). |
|
4689 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
4690 |
^ true. |
|
4691 |
]. |
|
4692 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
4693 |
^ true. |
|
295 | 4694 |
]. |
4695 |
||
4696 |
end := aString indexOf:$- startingAt:2. |
|
4697 |
(end == 0) ifTrue:[^ false]. |
|
4698 |
origin := aString copyFrom:2 to:(end - 1). |
|
4699 |
||
4700 |
start := end + 1. |
|
4701 |
end := aString indexOf:$- startingAt:start. |
|
4702 |
(end == 0) ifTrue:[^ false]. |
|
4703 |
family := aString copyFrom:start to:(end - 1). |
|
4704 |
||
4705 |
start := end + 1. |
|
4706 |
end := aString indexOf:$- startingAt:start. |
|
4707 |
(end == 0) ifTrue:[^ false]. |
|
4708 |
face := aString copyFrom:start to:(end - 1). |
|
4709 |
||
4710 |
start := end + 1. |
|
4711 |
end := aString indexOf:$- startingAt:start. |
|
4712 |
(end == 0) ifTrue:[^ false]. |
|
4713 |
style := aString copyFrom:start to:(end - 1). |
|
4714 |
(style = 'o') ifTrue:[ |
|
1344 | 4715 |
style := 'oblique' |
295 | 4716 |
] ifFalse:[ |
1344 | 4717 |
(style = 'i') ifTrue:[ |
4718 |
style := 'italic' |
|
4719 |
] ifFalse:[ |
|
4720 |
(style = 'r') ifTrue:[ |
|
4721 |
style := 'roman' |
|
4722 |
] |
|
4723 |
] |
|
295 | 4724 |
]. |
4725 |
||
4726 |
start := end + 1. |
|
4727 |
end := aString indexOf:$- startingAt:start. |
|
4728 |
(end == 0) ifTrue:[^ false]. |
|
4729 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4730 |
||
4731 |
start := end + 1. |
|
4732 |
end := aString indexOf:$- startingAt:start. |
|
4733 |
(end == 0) ifTrue:[^ false]. |
|
4734 |
skip := aString copyFrom:start to:(end - 1). |
|
4735 |
||
4736 |
start := end + 1. |
|
4737 |
end := aString indexOf:$- startingAt:start. |
|
4738 |
(end == 0) ifTrue:[^ false]. |
|
4739 |
fheight := aString copyFrom:start to:(end - 1). |
|
4740 |
||
4741 |
start := end + 1. |
|
4742 |
end := aString indexOf:$- startingAt:start. |
|
4743 |
(end == 0) ifTrue:[^ false]. |
|
4744 |
size := aString copyFrom:start to:(end - 1). |
|
4745 |
size := (Number readFromString:size) / 10. |
|
4746 |
||
4747 |
start := end + 1. |
|
4748 |
end := aString indexOf:$- startingAt:start. |
|
4749 |
(end == 0) ifTrue:[^ false]. |
|
4750 |
resX := aString copyFrom:start to:(end - 1). |
|
4751 |
||
4752 |
start := end + 1. |
|
4753 |
end := aString indexOf:$- startingAt:start. |
|
4754 |
(end == 0) ifTrue:[^ false]. |
|
4755 |
resY := aString copyFrom:start to:(end - 1). |
|
4756 |
||
4757 |
start := end + 1. |
|
4758 |
end := aString indexOf:$- startingAt:start. |
|
4759 |
(end == 0) ifTrue:[^ false]. |
|
4760 |
x1 := aString copyFrom:start to:(end - 1). |
|
4761 |
||
4762 |
start := end + 1. |
|
4763 |
end := aString indexOf:$- startingAt:start. |
|
4764 |
(end == 0) ifTrue:[^ false]. |
|
4765 |
x2 := aString copyFrom:start to:(end - 1). |
|
4766 |
||
4767 |
start := end + 1. |
|
4768 |
end := aString indexOf:$- startingAt:start. |
|
4769 |
(end == 0) ifTrue:[^ false]. |
|
4770 |
coding := aString copyFrom:start to:(end - 1). |
|
4771 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4772 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1344 | 4773 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4774 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4775 |
|
295 | 4776 |
aBlock value:family value:face value:style value:size value:coding. |
4777 |
^ true |
|
4778 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4779 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 4780 |
! |
4781 |
||
1344 | 4782 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4783 |
"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
|
4784 |
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
|
4785 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4786 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4787 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4788 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4789 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4790 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4791 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4792 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4793 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4794 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4795 |
if (ISCONNECTED) { |
1344 | 4796 |
Display *dpy = myDpy; |
4797 |
||
4798 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
4799 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
4800 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
4801 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
4802 |
||
4803 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4804 |
|
1344 | 4805 |
f = _FontVal(aFontId); |
4806 |
if (f) { |
|
4807 |
n = f->n_properties; |
|
4808 |
prop = f->properties; |
|
4809 |
if (prop) { |
|
4810 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4811 |
#ifdef SUPERDEBUG |
1344 | 4812 |
cp = XGetAtomName(dpy, prop->name); |
4813 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
4814 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4815 |
#endif |
1344 | 4816 |
if (prop->name == XA_FULL_NAME) { |
4817 |
cp = XGetAtomName(dpy, prop->card32); |
|
4818 |
if (cp) { |
|
4819 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4820 |
#ifdef SUPERDEBUG |
1344 | 4821 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4822 |
#endif |
1344 | 4823 |
XFree(cp); |
4824 |
} |
|
4825 |
} else if (prop->name == fontAtom) { |
|
4826 |
cp = XGetAtomName(dpy, prop->card32); |
|
4827 |
if (cp) { |
|
4828 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4829 |
#ifdef SUPERDEBUG |
1344 | 4830 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4831 |
#endif |
1344 | 4832 |
XFree(cp); |
4833 |
} |
|
4834 |
} else if (prop->name == encodingAtom) { |
|
4835 |
cp = XGetAtomName(dpy, prop->card32); |
|
4836 |
if (cp) { |
|
4837 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4838 |
#ifdef SUPERDEBUG |
1344 | 4839 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4840 |
#endif |
1344 | 4841 |
XFree(cp); |
4842 |
} |
|
4843 |
} else if (prop->name == registryAtom) { |
|
4844 |
cp = XGetAtomName(dpy, prop->card32); |
|
4845 |
if (cp) { |
|
4846 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4847 |
#ifdef SUPERDEBUG |
1344 | 4848 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4849 |
#endif |
1344 | 4850 |
XFree(cp); |
4851 |
} |
|
4852 |
} else if (prop->name == charSetCollAtom) { |
|
4853 |
cp = XGetAtomName(dpy, prop->card32); |
|
4854 |
if (cp) { |
|
4855 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4856 |
#ifdef SUPERDEBUG |
1344 | 4857 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4858 |
#endif |
1344 | 4859 |
XFree(cp); |
4860 |
} |
|
4861 |
} |
|
4862 |
prop++; |
|
4863 |
} |
|
4864 |
} |
|
4865 |
} |
|
4866 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4867 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4868 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4869 |
^ self |
1344 | 4870 |
extractEncodingFromRegistry:registry |
4871 |
encoding:encoding |
|
4872 |
charSetCollections:charSetCollections |
|
4873 |
! |
|
4874 |
||
4875 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4876 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4877 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4878 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4879 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4880 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 4881 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4882 |
] ifFalse:[ |
1344 | 4883 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4884 |
enc := encoding asLowercase asSymbol |
|
4885 |
] ifFalse:[ |
|
4886 |
charSets := charSetCollections. |
|
4887 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
4888 |
charSets := charSets asUppercase asCollectionOfWords. |
|
4889 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
4890 |
enc := #iso8859 |
|
4891 |
] ifFalse:[ |
|
4892 |
(charSets includes:'ISO8859') ifTrue:[ |
|
4893 |
enc := #iso8859 |
|
4894 |
] ifFalse:[ |
|
4895 |
(charSets includes:'ASCII') ifTrue:[ |
|
4896 |
enc := #ascii |
|
4897 |
] ifFalse:[ |
|
4898 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
4899 |
enc := #iso8859 |
|
4900 |
] |
|
4901 |
] |
|
4902 |
] |
|
4903 |
] |
|
4904 |
] |
|
4905 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4906 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4907 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4908 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4909 |
"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
|
4910 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4911 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4912 |
|
1344 | 4913 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4914 |
"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
|
4915 |
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
|
4916 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4917 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4918 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4919 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4920 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4921 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4922 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4923 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4924 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4925 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4926 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4927 |
|
1344 | 4928 |
fontMetricsOf:fontId into:aBlock |
991 | 4929 |
"evaluate aBlock, passing a fonts metrics as arguments" |
4930 |
||
4931 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4932 |
maxAscent maxDescent minWidth maxWidth avgWidth |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4933 |
res resX resY| |
991 | 4934 |
|
994 | 4935 |
%{ |
991 | 4936 |
XFontStruct *f; |
4937 |
int len; |
|
4938 |
||
4939 |
if (ISCONNECTED) { |
|
1344 | 4940 |
if (__isExternalAddress(fontId)) { |
4941 |
f = _FontVal(fontId); |
|
4942 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4943 |
#ifdef NOTDEF |
1344 | 4944 |
char *cp; |
4945 |
XFontProp *prop; |
|
4946 |
||
4947 |
n = f->n_properties; |
|
4948 |
prop = f->properties; |
|
4949 |
||
4950 |
if (prop) { |
|
4951 |
while (n--) { |
|
4952 |
if (prop->name == RESOLUTION_X) { |
|
4953 |
resX = __MKSMALLINT(prop->card32); |
|
4954 |
} else if (prop->name == RESOLUTION_Y) { |
|
4955 |
resY = __MKSMALLINT(prop->card32); |
|
4956 |
} else if (prop->name == RESOLUTION) { |
|
4957 |
res = __MKSMALLINT(prop->card32); |
|
4958 |
} |
|
4959 |
prop++; |
|
4960 |
} |
|
4961 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4962 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4963 |
|
1344 | 4964 |
avgAscent = __MKSMALLINT(f->ascent); |
4965 |
avgDescent = __MKSMALLINT(f->descent); |
|
4966 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
4967 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
4968 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
4969 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
4970 |
BEGIN_INTERRUPTSBLOCKED |
|
4971 |
len = XTextWidth(f, " ", 1); |
|
4972 |
END_INTERRUPTSBLOCKED |
|
4973 |
avgWidth = __MKSMALLINT( len ); |
|
4974 |
} |
|
4975 |
} |
|
991 | 4976 |
} |
4977 |
%}. |
|
4978 |
encoding := self encodingOf:fontId. |
|
4979 |
aBlock value:encoding |
|
1344 | 4980 |
value:avgAscent |
4981 |
value:avgDescent |
|
4982 |
value:maxAscent |
|
4983 |
value:maxDescent |
|
4984 |
value:minWidth |
|
4985 |
value:maxWidth |
|
4986 |
value:avgWidth |
|
4987 |
! |
|
4988 |
||
4989 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4990 |
"return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution, |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4991 |
but due to errors in some XServer installations, some use 75dpi fonts on higher |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4992 |
resolution displays and vice/versa." |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4993 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4994 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4995 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4996 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4997 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4998 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4999 |
if (ISCONNECTED) { |
1344 | 5000 |
Display *dpy = myDpy; |
5001 |
||
5002 |
if (__isExternalAddress(fontId)) { |
|
5003 |
f = _FontVal(fontId); |
|
5004 |
if (f) { |
|
5005 |
char *cp; |
|
5006 |
XFontProp *prop; |
|
5007 |
Atom resolutionXAtom, resolutionYAtom; |
|
5008 |
int n; |
|
5009 |
||
5010 |
n = f->n_properties; |
|
5011 |
prop = f->properties; |
|
5012 |
||
5013 |
if (prop) { |
|
5014 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
5015 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
5016 |
||
5017 |
while (n--) { |
|
5018 |
if (prop->name == resolutionXAtom) { |
|
5019 |
resX = __MKSMALLINT(prop->card32); |
|
5020 |
} else if (prop->name == resolutionYAtom) { |
|
5021 |
resY = __MKSMALLINT(prop->card32); |
|
5022 |
} else if (prop->name == XA_RESOLUTION) { |
|
5023 |
res = __MKSMALLINT(prop->card32); |
|
5024 |
} |
|
5025 |
prop++; |
|
5026 |
} |
|
5027 |
} |
|
5028 |
} |
|
5029 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5030 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5031 |
%}. |
1046 | 5032 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 5033 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5034 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5035 |
res notNil ifTrue:[ |
1344 | 5036 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5037 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5038 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5039 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5040 |
|
1344 | 5041 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5042 |
"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
|
5043 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5044 |
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
|
5045 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5046 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5047 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5048 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5049 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5050 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5051 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5052 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5053 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5054 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5055 |
if (ISCONNECTED) { |
1344 | 5056 |
Display *dpy = myDpy; |
5057 |
||
5058 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5059 |
||
5060 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5061 |
|
1344 | 5062 |
f = _FontVal(aFontId); |
5063 |
if (f) { |
|
5064 |
n = f->n_properties; |
|
5065 |
prop = f->properties; |
|
5066 |
if (prop) { |
|
5067 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5068 |
#ifdef SUPERDEBUG |
1344 | 5069 |
cp = XGetAtomName(dpy, prop->name); |
5070 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5071 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5072 |
#endif |
1344 | 5073 |
if (prop->name == XA_FULL_NAME) { |
5074 |
cp = XGetAtomName(dpy, prop->card32); |
|
5075 |
if (cp) { |
|
5076 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5077 |
#ifdef SUPERDEBUG |
1344 | 5078 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5079 |
#endif |
1344 | 5080 |
XFree(cp); |
5081 |
} |
|
5082 |
} |
|
5083 |
if (prop->name == fontAtom) { |
|
5084 |
cp = XGetAtomName(dpy, prop->card32); |
|
5085 |
if (cp) { |
|
5086 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5087 |
#ifdef SUPERDEBUG |
1344 | 5088 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5089 |
#endif |
1344 | 5090 |
XFree(cp); |
5091 |
} |
|
5092 |
} |
|
5093 |
prop++; |
|
5094 |
} |
|
5095 |
} |
|
5096 |
} |
|
5097 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5098 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5099 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5100 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 5101 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5102 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5103 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5104 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5105 |
|
1344 | 5106 |
getAvailableFontsMatching:pattern |
295 | 5107 |
"return an Array filled with font names matching aPattern" |
5108 |
||
5109 |
%{ /* UNLIMITEDSTACK */ |
|
5110 |
||
5111 |
int nnames = 1500; |
|
5112 |
int available = nnames + 1; |
|
5113 |
char **fonts; |
|
5114 |
OBJ arr, str; |
|
5115 |
int i; |
|
5116 |
||
5117 |
if (ISCONNECTED) { |
|
1344 | 5118 |
if (__isString(pattern)) { |
5119 |
for (;;) { |
|
5120 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
5121 |
if ((fonts == NULL) || (available < nnames)) break; |
|
5122 |
XFreeFontNames(fonts); |
|
5123 |
nnames = available * 2; |
|
5124 |
} |
|
5125 |
if (fonts == NULL) { |
|
5126 |
RETURN ( nil ); |
|
5127 |
} |
|
5128 |
/* |
|
5129 |
* now, that we know the number of font names, |
|
5130 |
* create the array ... |
|
5131 |
*/ |
|
5132 |
arr = __ARRAY_NEW_INT(available); |
|
5133 |
if (! arr) { |
|
5134 |
RETURN (nil); |
|
5135 |
} |
|
5136 |
/* |
|
5137 |
* ... and fill it |
|
5138 |
*/ |
|
5139 |
for (i=0; i<available; i++) { |
|
5140 |
__PROTECT__(arr); |
|
5141 |
str = __MKSTRING(fonts[i]); |
|
5142 |
__UNPROTECT__(arr); |
|
5143 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
5144 |
} |
|
5145 |
RETURN (arr); |
|
5146 |
} |
|
295 | 5147 |
} |
5148 |
%}. |
|
5149 |
^ nil |
|
5150 |
! |
|
5151 |
||
1344 | 5152 |
getDefaultFont |
295 | 5153 |
"return a default font id - used when class Font cannot |
5154 |
find anything usable" |
|
5155 |
||
5156 |
^ self createFontFor:'fixed' |
|
5157 |
! |
|
5158 |
||
1344 | 5159 |
getFontWithFamily:familyString face:faceString |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5160 |
style:styleArgString size:sizeArg encoding:encodingSym |
295 | 5161 |
|
5162 |
"try to get the specified font, if not available, try next smaller |
|
5163 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
5164 |
as family and the other parameters as nil. For example, the cursor font |
|
5165 |
can be aquired that way." |
|
5166 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5167 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5168 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5169 |
styleString := styleArgString. |
295 | 5170 |
|
5171 |
"special: if face is nil, allow access to X-fonts" |
|
5172 |
faceString isNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5173 |
sizeArg notNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5174 |
theName := familyString , '-' , sizeArg printString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5175 |
] ifFalse:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5176 |
theName := familyString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5177 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5178 |
theName isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5179 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5180 |
mhmh - fall back to the default font |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5181 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5182 |
theName := 'fixed' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5183 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5184 |
theId := self createFontFor:theName. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5185 |
theId isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5186 |
theId := self getDefaultFont |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5187 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5188 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5189 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5190 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5191 |
"/ 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
|
5192 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5193 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5194 |
(styleString notNil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5195 |
and:[(styleString endsWith:'-narrow') |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5196 |
or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5197 |
|i| |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5198 |
i := styleString lastIndexOf:$-. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5199 |
spacing := styleString copyFrom:(i+1). |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5200 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5201 |
] ifFalse:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5202 |
spacing := 'normal'. |
295 | 5203 |
]. |
5204 |
||
5205 |
xlatedStyle := styleString. |
|
5206 |
xlatedStyle notNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5207 |
xlatedStyle := xlatedStyle first asString |
295 | 5208 |
]. |
5209 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5210 |
id := self |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5211 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5212 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5213 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5214 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5215 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5216 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5217 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5218 |
registry:encodingSym |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5219 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5220 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5221 |
id isNil ifTrue:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5222 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5223 |
"/ too stupid: encodings come in both cases |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5224 |
"/ and X does not ignore case |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5225 |
"/ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5226 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5227 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5228 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5229 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5230 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5231 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5232 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5233 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5234 |
registry:encodingSym asUppercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5235 |
encoding:'*'. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5236 |
id isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5237 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5238 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5239 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5240 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5241 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5242 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5243 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5244 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5245 |
registry:encodingSym asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5246 |
encoding:'*'. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5247 |
] |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5248 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5249 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5250 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5251 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5252 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5253 |
"Modified: 28.2.1997 / 18:26:12 / cg" |
295 | 5254 |
! |
5255 |
||
1344 | 5256 |
getFontWithFoundry:foundry family:family weight:weight |
5257 |
slant:slant spacing:spc pixelSize:pSize size:size |
|
5258 |
registry:registry encoding:encoding |
|
295 | 5259 |
|
5260 |
"get the specified font, if not available, return nil. |
|
5261 |
This is the new font creation method - all others will be changed to |
|
5262 |
use this entry. |
|
5263 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
5264 |
||
5265 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
5266 |
family: 'helvetica' 'courier' 'times' ... |
|
5267 |
weight: 'bold' 'medium' 'demi' ... |
|
5268 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
5269 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
5270 |
pixelSize: 16,18 ... usually left empty |
|
5271 |
size: size in point (1/72th of an inch) |
|
5272 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5273 |
encoding: vendor specific encoding (usually '*') |
295 | 5274 |
" |
5275 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5276 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5277 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 5278 |
pSizeMatch registryMatch encodingMatch| |
295 | 5279 |
|
5280 |
"this works only on 'Release >= 3' - X-servers" |
|
5281 |
"name is: |
|
1344 | 5282 |
-foundry-family -weight -slant- |
5283 |
sony helvetica bold r |
|
5284 |
adobe courier medium i |
|
5285 |
msic fixed o |
|
5286 |
... ... |
|
295 | 5287 |
" |
5288 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5289 |
size isNil ifTrue:[ |
1344 | 5290 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5291 |
] ifFalse:[ |
1344 | 5292 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5293 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5294 |
foundry isNil ifTrue:[ |
1344 | 5295 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5296 |
] ifFalse:[ |
1344 | 5297 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5298 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5299 |
family isNil ifTrue:[ |
1344 | 5300 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5301 |
] ifFalse:[ |
1344 | 5302 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5303 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5304 |
weight isNil ifTrue:[ |
1344 | 5305 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5306 |
] ifFalse:[ |
1344 | 5307 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5308 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5309 |
slant isNil ifTrue:[ |
1344 | 5310 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5311 |
] ifFalse:[ |
1344 | 5312 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5313 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5314 |
spc isNil ifTrue:[ |
1344 | 5315 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5316 |
] ifFalse:[ |
1344 | 5317 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5318 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5319 |
pSize isNil ifTrue:[ |
1344 | 5320 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5321 |
] ifFalse:[ |
1344 | 5322 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5323 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5324 |
registry isNil ifTrue:[ |
1344 | 5325 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5326 |
] ifFalse:[ |
1344 | 5327 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5328 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5329 |
encoding isNil ifTrue:[ |
1344 | 5330 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5331 |
] ifFalse:[ |
1344 | 5332 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5333 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5334 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5335 |
theName := ('-' , foundryMatch, |
1344 | 5336 |
'-' , familyMatch, |
5337 |
'-' , weightMatch , |
|
5338 |
'-' , slantMatch , |
|
5339 |
'-' , spcMatch , |
|
5340 |
'-*' , |
|
5341 |
'-' , pSizeMatch , |
|
5342 |
'-' , sizeMatch , |
|
5343 |
'-*-*-*-*' , |
|
5344 |
'-' , registryMatch , |
|
5345 |
'-' , encodingMatch). |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5346 |
|
697 | 5347 |
"/ Transcript showCR:theName; endEntry. |
295 | 5348 |
|
5349 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5350 |
|
295 | 5351 |
|
5352 |
" |
|
5353 |
Display getFontWithFoundry:'*' |
|
1344 | 5354 |
family:'courier' |
5355 |
weight:'medium' |
|
5356 |
slant:'r' |
|
5357 |
spacing:nil |
|
5358 |
pixelSize:nil |
|
5359 |
size:13 |
|
5360 |
registry:'iso8859' |
|
5361 |
encoding:'*' |
|
295 | 5362 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5363 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5364 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 5365 |
! |
5366 |
||
1344 | 5367 |
listOfAvailableFonts |
295 | 5368 |
"return a list with all available fonts on this display. |
5369 |
Since this takes a long time, keep the result of the query for the |
|
5370 |
next time. The elements of the returned collection are instances of |
|
5371 |
FontDescription." |
|
5372 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
5373 |
|"stream aName fntDescr" names| |
295 | 5374 |
|
5375 |
listOfXFonts isNil ifTrue:[ |
|
5376 |
"/ |
|
5377 |
"/ old code; using a pipe to xlsfonts |
|
5378 |
"/ |
|
5379 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
5380 |
"/ stream isNil ifTrue:[^ nil]. |
|
5381 |
"/ listOfXFonts := OrderedCollection new. |
|
5382 |
"/ [stream atEnd] whileFalse:[ |
|
5383 |
"/ aName := stream nextLine. |
|
5384 |
"/ aName notNil ifTrue:[ |
|
5385 |
"/ self decomposeXFontName:aName into: |
|
5386 |
"/ [:family :face :style :size :coding | |
|
5387 |
"/ family notNil ifTrue:[ |
|
5388 |
"/ fntDescr := FontDescription |
|
5389 |
"/ family:family |
|
5390 |
"/ face:face |
|
5391 |
"/ style:style |
|
5392 |
"/ size:size |
|
5393 |
"/ encoding:coding. |
|
5394 |
"/ listOfXFonts add:fntDescr |
|
5395 |
"/ ] |
|
5396 |
"/ ] |
|
5397 |
"/ ] |
|
5398 |
"/ ]. |
|
5399 |
"/ stream close. |
|
5400 |
"/ "if xlsfont is broken ... (hey sco)" |
|
5401 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
5402 |
"/ listOfXFonts := nil |
|
5403 |
"/ ] ifFalse:[ |
|
5404 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
5405 |
"/ ]. |
|
5406 |
||
1344 | 5407 |
"/ |
5408 |
"/ new code: |
|
5409 |
"/ use new primitive to get font names; |
|
5410 |
"/ this is much faster, and also works on systems where |
|
5411 |
"/ a) xlsfonts is broken (sco) |
|
5412 |
"/ b) xlsfonts is not available (aix) |
|
5413 |
"/ |
|
5414 |
names := self getAvailableFontsMatching:'*'. |
|
5415 |
names isNil ifTrue:[ |
|
5416 |
"no names returned ..." |
|
5417 |
^ nil |
|
5418 |
]. |
|
5419 |
listOfXFonts := names collect:[:aName | |
|
5420 |
|fntDescr| |
|
5421 |
||
5422 |
(self decomposeXFontName:aName into: |
|
5423 |
[:family :face :style :size :coding | |
|
5424 |
family notNil ifTrue:[ |
|
5425 |
fntDescr := FontDescription |
|
5426 |
family:family |
|
5427 |
face:face |
|
5428 |
style:style |
|
5429 |
size:size |
|
5430 |
encoding:coding. |
|
5431 |
] ifFalse:[ |
|
5432 |
fntDescr := FontDescription |
|
5433 |
name:aName |
|
5434 |
] |
|
5435 |
] |
|
5436 |
) ifFalse:[ |
|
5437 |
fntDescr := FontDescription name:aName. |
|
5438 |
]. |
|
5439 |
fntDescr |
|
5440 |
]. |
|
295 | 5441 |
|
5442 |
]. |
|
5443 |
^ listOfXFonts |
|
5444 |
||
5445 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5446 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5447 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5448 |
Display getAvailableFontsMatching:'*'. |
295 | 5449 |
" |
5450 |
||
5451 |
"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
|
5452 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5453 |
! |
5454 |
||
1344 | 5455 |
releaseFont:aFontId |
295 | 5456 |
|
5457 |
%{ /* NOCONTEXT */ |
|
5458 |
||
5459 |
XFontStruct *f; |
|
5460 |
||
1212 | 5461 |
if (! ISCONNECTED) { |
1344 | 5462 |
RETURN ( self ); |
1212 | 5463 |
} |
5464 |
||
5465 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 5466 |
f = _FontVal(aFontId); |
5467 |
if (f) { |
|
5468 |
BEGIN_INTERRUPTSBLOCKED |
|
5469 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5470 |
#ifdef COUNT_RESOURCES |
1344 | 5471 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5472 |
#endif |
1344 | 5473 |
END_INTERRUPTSBLOCKED |
5474 |
RETURN ( self ); |
|
5475 |
} |
|
295 | 5476 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5477 |
%}. |
295 | 5478 |
self primitiveFailed |
5479 |
! |
|
5480 |
||
1344 | 5481 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5482 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5483 |
on this display. |
|
5484 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5485 |
||
5486 |
|sizes| |
|
5487 |
||
466 | 5488 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5489 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 5490 |
"special: in X11R5 and above, size 0 means: |
5491 |
there are scaled versions in all sizes available" |
|
5492 |
||
5493 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 5494 |
]. |
5495 |
^ sizes |
|
5496 |
||
5497 |
" |
|
5498 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5499 |
" |
|
466 | 5500 |
|
5501 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5502 |
! |
5503 |
||
1344 | 5504 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 5505 |
|
5506 |
%{ /* NOCONTEXT */ |
|
5507 |
||
5508 |
XFontStruct *f; |
|
5509 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5510 |
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
|
5511 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5512 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5513 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5514 |
int nInstBytes; |
295 | 5515 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5516 |
if (ISCONNECTED) { |
1344 | 5517 |
if (__bothSmallInteger(index1, index2) |
5518 |
&& __isExternalAddress(aFontId) |
|
5519 |
&& __isNonNilObject(aString)) { |
|
5520 |
f = _FontVal(aFontId); |
|
5521 |
if (! f) goto fail; |
|
5522 |
||
5523 |
i1 = __intVal(index1) - 1; |
|
5524 |
cls = __qClass(aString); |
|
5525 |
||
5526 |
if (i1 >= 0) { |
|
5527 |
i2 = __intVal(index2) - 1; |
|
5528 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5529 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 5530 |
} |
5531 |
||
5532 |
cp = (char *) _stringVal(aString); |
|
5533 |
l = i2 - i1 + 1; |
|
5534 |
||
5535 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5536 |
n = _stringSize(aString); |
|
5537 |
if (i2 < n) { |
|
5538 |
cp += i1; |
|
5539 |
BEGIN_INTERRUPTSBLOCKED |
|
5540 |
len = XTextWidth(f, cp, l); |
|
5541 |
END_INTERRUPTSBLOCKED |
|
5542 |
RETURN ( __MKSMALLINT(len) ); |
|
5543 |
} |
|
5544 |
} |
|
5545 |
||
5546 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5547 |
cp += nInstBytes; |
|
5548 |
||
5549 |
if (__isBytes(aString)) { |
|
5550 |
n = __byteArraySize(aString) - nInstBytes; |
|
5551 |
if (i2 < n) { |
|
5552 |
cp += i1; |
|
5553 |
BEGIN_INTERRUPTSBLOCKED |
|
5554 |
len = XTextWidth(f, cp, l); |
|
5555 |
END_INTERRUPTSBLOCKED |
|
5556 |
RETURN ( __MKSMALLINT(len) ); |
|
5557 |
} |
|
5558 |
} |
|
5559 |
||
5560 |
/* TWOBYTESTRINGS */ |
|
5561 |
if (__isWords(aString)) { |
|
5562 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5563 |
||
5564 |
if (i2 < n) { |
|
5565 |
union { |
|
5566 |
char b[2]; |
|
5567 |
unsigned short s; |
|
5568 |
} u; |
|
5569 |
int i; |
|
5570 |
XChar2b *cp2 = (XChar2b *)0; |
|
5571 |
int mustFree = 0; |
|
5572 |
||
5573 |
cp += (i1 * 2); |
|
5574 |
if (l > 1000) l = 1000; |
|
5575 |
||
5576 |
/* |
|
5577 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5578 |
* X expects them MSB first |
|
5579 |
* convert as required |
|
5580 |
*/ |
|
5581 |
||
5582 |
u.s = 0x1234; |
|
5583 |
if (u.b[0] != 0x12) { |
|
5584 |
if (l <= NLOCALBUFFER) { |
|
5585 |
cp2 = xlatebuffer; |
|
5586 |
} else { |
|
5587 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5588 |
mustFree = 1; |
|
5589 |
} |
|
5590 |
for (i=0; i<l; i++) { |
|
5591 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5592 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5593 |
} |
|
5594 |
cp = (char *) cp2; |
|
5595 |
} |
|
5596 |
BEGIN_INTERRUPTSBLOCKED |
|
5597 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
5598 |
END_INTERRUPTSBLOCKED |
|
5599 |
||
5600 |
if (mustFree) { |
|
5601 |
free(cp2); |
|
5602 |
} |
|
5603 |
||
5604 |
RETURN ( __MKSMALLINT(len) ); |
|
5605 |
} |
|
5606 |
} |
|
5607 |
} |
|
5608 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5609 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5610 |
#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
|
5611 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5612 |
%}. |
295 | 5613 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5614 |
^ 0 |
295 | 5615 |
! |
5616 |
||
1344 | 5617 |
widthOf:aString inFont:aFontId |
295 | 5618 |
|
5619 |
%{ /* NOCONTEXT */ |
|
5620 |
||
5621 |
XFontStruct *f; |
|
5622 |
char *cp; |
|
5623 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5624 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5625 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5626 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5627 |
int nInstBytes; |
295 | 5628 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5629 |
if (ISCONNECTED) { |
1344 | 5630 |
if (__isExternalAddress(aFontId) |
5631 |
&& __isNonNilObject(aString)) { |
|
5632 |
f = _FontVal(aFontId); |
|
5633 |
if (! f) goto fail; |
|
5634 |
||
5635 |
cls = __qClass(aString); |
|
5636 |
||
5637 |
cp = (char *)_stringVal(aString); |
|
5638 |
||
5639 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5640 |
n = _stringSize(aString); |
|
5641 |
BEGIN_INTERRUPTSBLOCKED |
|
5642 |
len = XTextWidth(f, cp, n); |
|
5643 |
END_INTERRUPTSBLOCKED |
|
5644 |
RETURN ( __MKSMALLINT(len) ); |
|
5645 |
} |
|
5646 |
||
5647 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5648 |
cp += nInstBytes; |
|
5649 |
||
5650 |
if (__isBytes(aString)) { |
|
5651 |
n = __byteArraySize(aString) - nInstBytes; |
|
5652 |
||
5653 |
BEGIN_INTERRUPTSBLOCKED |
|
5654 |
len = XTextWidth(f, cp, n); |
|
5655 |
END_INTERRUPTSBLOCKED |
|
5656 |
RETURN ( __MKSMALLINT(len) ); |
|
5657 |
} |
|
5658 |
||
5659 |
/* TWOBYTESTRINGS */ |
|
5660 |
if (__isWords(aString)) { |
|
5661 |
union { |
|
5662 |
char b[2]; |
|
5663 |
unsigned short s; |
|
5664 |
} u; |
|
5665 |
int i; |
|
5666 |
XChar2b *cp2; |
|
5667 |
int mustFree = 0; |
|
5668 |
||
5669 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5670 |
if (n > 1000) n = 1000; |
|
5671 |
||
5672 |
/* |
|
5673 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5674 |
* X expects them MSB first |
|
5675 |
* convert as required |
|
5676 |
*/ |
|
5677 |
||
5678 |
u.s = 0x1234; |
|
5679 |
if (u.b[0] != 0x12) { |
|
5680 |
if (n <= NLOCALBUFFER) { |
|
5681 |
cp2 = xlatebuffer; |
|
5682 |
} else { |
|
5683 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
5684 |
mustFree = 1; |
|
5685 |
} |
|
5686 |
||
5687 |
for (i=0; i<n; i++) { |
|
5688 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5689 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5690 |
} |
|
5691 |
cp = (char *) cp2; |
|
5692 |
} |
|
5693 |
||
5694 |
BEGIN_INTERRUPTSBLOCKED |
|
5695 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
5696 |
END_INTERRUPTSBLOCKED |
|
5697 |
||
5698 |
if (mustFree) { |
|
5699 |
free(cp2); |
|
5700 |
} |
|
5701 |
||
5702 |
RETURN ( __MKSMALLINT(len) ); |
|
5703 |
} |
|
5704 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5705 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5706 |
#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
|
5707 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5708 |
%}. |
295 | 5709 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5710 |
^ 0 |
295 | 5711 |
! ! |
5712 |
||
5713 |
!XWorkstation methodsFor:'grabbing '! |
|
5714 |
||
1344 | 5715 |
allowEvents:mode |
295 | 5716 |
%{ /* NOCONTEXT */ |
5717 |
||
5718 |
int _mode, ok = 1; |
|
5719 |
||
5720 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 5721 |
_mode = AsyncPointer; |
295 | 5722 |
else if (mode == @symbol(syncPointer)) |
1344 | 5723 |
_mode = SyncPointer; |
295 | 5724 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 5725 |
_mode = AsyncKeyboard; |
295 | 5726 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 5727 |
_mode = SyncKeyboard; |
295 | 5728 |
else if (mode == @symbol(syncBoth)) |
1344 | 5729 |
_mode = SyncBoth; |
295 | 5730 |
else if (mode == @symbol(asyncBoth)) |
1344 | 5731 |
_mode = AsyncBoth; |
295 | 5732 |
else if (mode == @symbol(replayPointer)) |
1344 | 5733 |
_mode = ReplayPointer; |
295 | 5734 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 5735 |
_mode = ReplayKeyboard; |
295 | 5736 |
else |
1344 | 5737 |
ok = 0; |
295 | 5738 |
|
5739 |
if (ok) { |
|
1344 | 5740 |
if (ISCONNECTED) { |
5741 |
BEGIN_INTERRUPTSBLOCKED |
|
5742 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5743 |
END_INTERRUPTSBLOCKED |
|
5744 |
RETURN (self); |
|
5745 |
} |
|
295 | 5746 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5747 |
%}. |
295 | 5748 |
self primitiveFailed |
5749 |
! |
|
5750 |
||
1344 | 5751 |
grabKeyboardIn:aWindowId |
295 | 5752 |
"grab the keyboard" |
5753 |
||
5754 |
%{ /* NOCONTEXT */ |
|
5755 |
int result, ok; |
|
5756 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5757 |
if (ISCONNECTED) { |
1344 | 5758 |
if (__isExternalAddress(aWindowId)) { |
5759 |
BEGIN_INTERRUPTSBLOCKED |
|
5760 |
result = XGrabKeyboard(myDpy, |
|
5761 |
_WindowVal(aWindowId), |
|
5762 |
True /* False */, |
|
5763 |
GrabModeAsync, |
|
5764 |
GrabModeAsync, |
|
5765 |
CurrentTime); |
|
5766 |
END_INTERRUPTSBLOCKED |
|
5767 |
ok = 0; |
|
5768 |
switch(result) { |
|
5769 |
case AlreadyGrabbed: |
|
5770 |
if (@global(ErrorPrinting) == true) { |
|
5771 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
5772 |
} |
|
5773 |
break; |
|
5774 |
case GrabNotViewable: |
|
5775 |
if (@global(ErrorPrinting) == true) { |
|
5776 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
5777 |
} |
|
5778 |
break; |
|
5779 |
case GrabInvalidTime: |
|
5780 |
if (@global(ErrorPrinting) == true) { |
|
5781 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
5782 |
} |
|
5783 |
break; |
|
5784 |
case GrabFrozen: |
|
5785 |
if (@global(ErrorPrinting) == true) { |
|
5786 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
5787 |
} |
|
5788 |
break; |
|
5789 |
default: |
|
5790 |
ok = 1; |
|
5791 |
break; |
|
5792 |
} |
|
5793 |
if (! ok) { |
|
5794 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5795 |
RETURN (false); |
|
5796 |
} |
|
5797 |
||
5798 |
RETURN ( true ); |
|
5799 |
} |
|
295 | 5800 |
} |
1183 | 5801 |
%}. |
295 | 5802 |
self primitiveFailed |
5803 |
! |
|
5804 |
||
1344 | 5805 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 5806 |
"grap the pointer - return true if ok" |
5807 |
||
5808 |
%{ /* NOCONTEXT */ |
|
5809 |
||
5810 |
int result, ok; |
|
5811 |
Window confineWin; |
|
5812 |
Cursor curs; |
|
5813 |
int pointer_mode, keyboard_mode; |
|
5814 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5815 |
if (ISCONNECTED) { |
1344 | 5816 |
if (__isExternalAddress(aWindowId)) { |
5817 |
if (__isExternalAddress(confineId)) |
|
5818 |
confineWin = _WindowVal(confineId); |
|
5819 |
else |
|
5820 |
confineWin = (Window) None; |
|
5821 |
||
5822 |
if (__isExternalAddress(aCursorId)) |
|
5823 |
curs = _CursorVal(aCursorId); |
|
5824 |
else |
|
5825 |
curs = (Cursor) None; |
|
5826 |
||
5827 |
if (pMode == @symbol(sync)) |
|
5828 |
pointer_mode = GrabModeSync; |
|
5829 |
else |
|
5830 |
pointer_mode = GrabModeAsync; |
|
5831 |
||
5832 |
if (kMode == @symbol(sync)) |
|
5833 |
keyboard_mode = GrabModeSync; |
|
5834 |
else |
|
5835 |
keyboard_mode = GrabModeAsync; |
|
5836 |
||
5837 |
BEGIN_INTERRUPTSBLOCKED |
|
5838 |
result = XGrabPointer(myDpy, |
|
5839 |
_WindowVal(aWindowId), |
|
5840 |
False, |
|
5841 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5842 |
pointer_mode, keyboard_mode, |
|
5843 |
confineWin, |
|
5844 |
curs, |
|
5845 |
CurrentTime); |
|
5846 |
END_INTERRUPTSBLOCKED |
|
5847 |
||
5848 |
ok = 0; |
|
5849 |
switch (result) { |
|
5850 |
case AlreadyGrabbed: |
|
5851 |
if (@global(ErrorPrinting) == true) { |
|
5852 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
5853 |
} |
|
5854 |
break; |
|
5855 |
case GrabNotViewable: |
|
5856 |
if (@global(ErrorPrinting) == true) { |
|
5857 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
5858 |
} |
|
5859 |
break; |
|
5860 |
case GrabInvalidTime: |
|
5861 |
if (@global(ErrorPrinting) == true) { |
|
5862 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
5863 |
} |
|
5864 |
break; |
|
5865 |
case GrabFrozen: |
|
5866 |
if (@global(ErrorPrinting) == true) { |
|
5867 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
5868 |
} |
|
5869 |
break; |
|
5870 |
default: |
|
5871 |
ok = 1; |
|
5872 |
break; |
|
5873 |
} |
|
5874 |
||
5875 |
if (! ok) { |
|
5876 |
XUngrabPointer(myDpy, CurrentTime); |
|
5877 |
RETURN (false); |
|
5878 |
} |
|
5879 |
RETURN ( true ); |
|
5880 |
} |
|
295 | 5881 |
} |
1183 | 5882 |
%}. |
295 | 5883 |
self primitiveFailed |
5884 |
! |
|
5885 |
||
1344 | 5886 |
ungrabKeyboard |
295 | 5887 |
"release the keyboard" |
5888 |
||
5889 |
%{ /* NOCONTEXT */ |
|
5890 |
||
5891 |
if (ISCONNECTED) { |
|
1344 | 5892 |
BEGIN_INTERRUPTSBLOCKED |
5893 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5894 |
XSync(myDpy, 0); |
|
5895 |
END_INTERRUPTSBLOCKED |
|
295 | 5896 |
} |
5897 |
%}. |
|
5898 |
activeKeyboardGrab := nil |
|
5899 |
! |
|
5900 |
||
1344 | 5901 |
ungrabPointer |
295 | 5902 |
"release the pointer" |
5903 |
||
5904 |
%{ /* NOCONTEXT */ |
|
5905 |
||
5906 |
if (ISCONNECTED) { |
|
1344 | 5907 |
BEGIN_INTERRUPTSBLOCKED |
5908 |
XUngrabPointer(myDpy, CurrentTime); |
|
5909 |
XSync(myDpy, 0); |
|
5910 |
END_INTERRUPTSBLOCKED |
|
295 | 5911 |
} |
5912 |
%}. |
|
5913 |
activePointerGrab := nil |
|
5914 |
! ! |
|
5915 |
||
5916 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5917 |
||
1344 | 5918 |
noClipIn:aGCId |
295 | 5919 |
"disable clipping rectangle" |
5920 |
||
5921 |
%{ /* NOCONTEXT */ |
|
5922 |
||
5923 |
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
|
5924 |
GC gc; |
295 | 5925 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5926 |
if (ISCONNECTED) { |
1344 | 5927 |
if (__isExternalAddress(aGCId)) { |
5928 |
gc = _GCVal(aGCId); |
|
5929 |
gcv.clip_mask = None; |
|
5930 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5931 |
RETURN ( self ); |
|
5932 |
} |
|
295 | 5933 |
} |
5934 |
%}. |
|
5935 |
self primitiveFailed |
|
5936 |
! |
|
5937 |
||
1344 | 5938 |
setBackground:bgColorIndex in:aGCId |
295 | 5939 |
"set background color to be drawn with" |
5940 |
||
5941 |
%{ /* NOCONTEXT */ |
|
5942 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5943 |
if (ISCONNECTED) { |
1344 | 5944 |
if (__isExternalAddress(aGCId) |
5945 |
&& __isSmallInteger(bgColorIndex)) { |
|
5946 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
|
5947 |
RETURN ( self ); |
|
5948 |
} |
|
295 | 5949 |
} |
5950 |
%}. |
|
5951 |
self primitiveFailed |
|
5952 |
! |
|
5953 |
||
1344 | 5954 |
setBitmapMask:aBitmapId in:aGCId |
295 | 5955 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
5956 |
||
5957 |
%{ /* NOCONTEXT */ |
|
5958 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5959 |
GC gc; |
295 | 5960 |
Pixmap bitmap; |
5961 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5962 |
if (ISCONNECTED) { |
1344 | 5963 |
Display *dpy = myDpy; |
5964 |
||
5965 |
if (__isExternalAddress(aGCId)) { |
|
5966 |
gc = _GCVal(aGCId); |
|
5967 |
if (__isExternalAddress(aBitmapId)) { |
|
5968 |
bitmap = _PixmapVal(aBitmapId); |
|
5969 |
XSetStipple(dpy, gc, bitmap); |
|
5970 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5971 |
RETURN ( self ); |
|
5972 |
} |
|
5973 |
if (aBitmapId == nil) { |
|
5974 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5975 |
RETURN ( self ); |
|
5976 |
} |
|
5977 |
} |
|
295 | 5978 |
} |
5979 |
%}. |
|
5980 |
self primitiveFailed |
|
5981 |
! |
|
5982 |
||
1344 | 5983 |
setClipByChildren:aBool in:aGCId |
295 | 5984 |
"enable/disable drawing into child views" |
5985 |
||
5986 |
%{ /* NOCONTEXT */ |
|
5987 |
||
5988 |
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
|
5989 |
GC gc; |
295 | 5990 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5991 |
if (ISCONNECTED) { |
1344 | 5992 |
if (__isExternalAddress(aGCId)) { |
5993 |
gc = _GCVal(aGCId); |
|
5994 |
if (aBool == true) |
|
5995 |
gcv.subwindow_mode = ClipByChildren; |
|
5996 |
else |
|
5997 |
gcv.subwindow_mode = IncludeInferiors; |
|
5998 |
||
5999 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
6000 |
RETURN ( self ); |
|
6001 |
} |
|
295 | 6002 |
} |
6003 |
%}. |
|
6004 |
self primitiveFailed |
|
6005 |
! |
|
6006 |
||
1344 | 6007 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
295 | 6008 |
"clip to a rectangle" |
6009 |
||
6010 |
%{ /* NOCONTEXT */ |
|
6011 |
||
6012 |
XRectangle r; |
|
6013 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6014 |
if (ISCONNECTED) { |
1344 | 6015 |
if (__isExternalAddress(aGCId) |
6016 |
&& __bothSmallInteger(clipX, clipY) |
|
6017 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
6018 |
r.x = __intVal(clipX); |
|
6019 |
r.y = __intVal(clipY); |
|
6020 |
r.width = __intVal(clipWidth); |
|
6021 |
r.height = __intVal(clipHeight); |
|
6022 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
6023 |
RETURN ( self ); |
|
6024 |
} |
|
295 | 6025 |
} |
6026 |
%}. |
|
6027 |
self primitiveFailed |
|
6028 |
! |
|
6029 |
||
1344 | 6030 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 6031 |
"set line attributes" |
6032 |
||
6033 |
%{ /* NOCONTEXT */ |
|
6034 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6035 |
if (ISCONNECTED) { |
1344 | 6036 |
if (__isExternalAddress(aGCId) |
6037 |
&& __isSmallInteger(offset) |
|
6038 |
&& __isByteArray(dashList)) { |
|
6039 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
6040 |
__intVal(offset), |
|
6041 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
6042 |
__byteArraySize(dashList)); |
|
6043 |
RETURN ( self ); |
|
6044 |
} |
|
788 | 6045 |
} |
6046 |
bad: ; |
|
6047 |
%}. |
|
6048 |
" |
|
6049 |
either aGCId is invalid, |
|
6050 |
and/or dashList is not a byteArray |
|
6051 |
and/or offset is not a smallInteger |
|
6052 |
" |
|
6053 |
self primitiveFailed |
|
6054 |
! |
|
6055 |
||
1344 | 6056 |
setFont:aFontId in:aGCId |
295 | 6057 |
"set font to be drawn in" |
6058 |
||
6059 |
%{ /* NOCONTEXT */ |
|
6060 |
||
6061 |
XFontStruct *f; |
|
6062 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6063 |
if (ISCONNECTED) { |
1344 | 6064 |
if (__isExternalAddress(aFontId) |
6065 |
&& __isExternalAddress(aGCId)) { |
|
6066 |
f = (XFontStruct *) _FontVal(aFontId); |
|
6067 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
6068 |
RETURN ( self ); |
|
6069 |
} |
|
295 | 6070 |
} |
6071 |
%}. |
|
6072 |
" |
|
6073 |
aGCId and/or aFontId are invalid |
|
6074 |
" |
|
6075 |
self primitiveFailed |
|
6076 |
! |
|
6077 |
||
1344 | 6078 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 6079 |
"set foreground and background colors to be drawn with" |
6080 |
||
6081 |
%{ /* NOCONTEXT */ |
|
6082 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6083 |
GC gc; |
295 | 6084 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6085 |
if (ISCONNECTED) { |
1344 | 6086 |
Display *dpy = myDpy; |
6087 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
6088 |
&& __isExternalAddress(aGCId)) { |
|
6089 |
gc = _GCVal(aGCId); |
|
6090 |
||
6091 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
|
6092 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
6093 |
RETURN ( self ); |
|
6094 |
} |
|
295 | 6095 |
} |
6096 |
%}. |
|
6097 |
self primitiveFailed |
|
6098 |
! |
|
6099 |
||
1344 | 6100 |
setForeground:fgColorIndex in:aGCId |
295 | 6101 |
"set foreground color to be drawn with" |
6102 |
||
6103 |
%{ /* NOCONTEXT */ |
|
6104 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6105 |
if (ISCONNECTED) { |
1344 | 6106 |
if (__isExternalAddress(aGCId) |
6107 |
&& __isSmallInteger(fgColorIndex)) { |
|
6108 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
|
6109 |
RETURN ( self ); |
|
6110 |
} |
|
295 | 6111 |
} |
6112 |
%}. |
|
6113 |
self primitiveFailed |
|
6114 |
! |
|
6115 |
||
1344 | 6116 |
setFunction:aFunctionSymbol in:aGCId |
295 | 6117 |
"set alu function to be drawn with" |
6118 |
||
6119 |
%{ /* NOCONTEXT */ |
|
6120 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6121 |
GC gc; |
295 | 6122 |
int fun = -1; |
6123 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6124 |
if (ISCONNECTED) { |
1344 | 6125 |
if (__isExternalAddress(aGCId)) { |
6126 |
gc = _GCVal(aGCId); |
|
6127 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
6128 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
6129 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
6130 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
6131 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
6132 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
6133 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
6134 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
6135 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
6136 |
if (fun != -1) { |
|
6137 |
XSetFunction(myDpy, gc, fun); |
|
6138 |
RETURN ( self ); |
|
6139 |
} |
|
6140 |
} |
|
295 | 6141 |
} |
6142 |
%}. |
|
6143 |
" |
|
6144 |
either aGCId is not an integer, or an invalid symbol |
|
6145 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
6146 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
6147 |
" |
|
6148 |
self primitiveFailed |
|
6149 |
! |
|
6150 |
||
1344 | 6151 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 6152 |
"set or clear the graphics exposures flag" |
6153 |
||
6154 |
%{ /* NOCONTEXT */ |
|
6155 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6156 |
if (ISCONNECTED) { |
1344 | 6157 |
if (__isExternalAddress(aGCId)) { |
6158 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
6159 |
RETURN ( self ); |
|
6160 |
} |
|
295 | 6161 |
} |
6162 |
%} |
|
6163 |
. |
|
6164 |
self primitiveFailed |
|
6165 |
! |
|
6166 |
||
1344 | 6167 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
1455 | 6168 |
"set line attributes; |
6169 |
lineStyle must be one of #solid, #dashed or #doubleDashed; |
|
6170 |
capStyle one of: #notLast, #butt, #round or #projecting; |
|
6171 |
joinStyle one of: #miter, #bevel or #round." |
|
295 | 6172 |
|
6173 |
%{ /* NOCONTEXT */ |
|
6174 |
||
6175 |
int x_style, x_cap, x_join; |
|
6176 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6177 |
if (ISCONNECTED) { |
1455 | 6178 |
if (__isExternalAddress(aGCId) |
6179 |
&& __isSmallInteger(aNumber)) { |
|
6180 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
6181 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
6182 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
6183 |
else goto bad; |
|
6184 |
||
6185 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
6186 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
6187 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
6188 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
6189 |
else goto bad; |
|
6190 |
||
6191 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
6192 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
6193 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
6194 |
else goto bad; |
|
6195 |
||
6196 |
XSetLineAttributes(myDpy, |
|
6197 |
_GCVal(aGCId), __intVal(aNumber), |
|
6198 |
x_style, x_cap, x_join); |
|
6199 |
RETURN ( self ); |
|
6200 |
} |
|
295 | 6201 |
} |
6202 |
bad: ; |
|
6203 |
%}. |
|
6204 |
" |
|
6205 |
either aGCId is invalid, |
|
1455 | 6206 |
and/or lineWidth is not a smallInteger, |
295 | 6207 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
6208 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
6209 |
and/or joinStyle is none of #miter, #bevel, #round |
|
6210 |
" |
|
6211 |
self primitiveFailed |
|
6212 |
! |
|
6213 |
||
1344 | 6214 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 6215 |
"set the mask origin" |
6216 |
||
6217 |
%{ /* NOCONTEXT */ |
|
6218 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6219 |
if (ISCONNECTED) { |
1344 | 6220 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
6221 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
|
6222 |
RETURN ( self ); |
|
6223 |
} |
|
295 | 6224 |
} |
6225 |
%}. |
|
6226 |
self primitiveFailed |
|
6227 |
! |
|
6228 |
||
1344 | 6229 |
setPixmapMask:aPixmapId in:aGCId |
295 | 6230 |
"set or clear the drawing mask - a pixmap mask providing full color" |
6231 |
||
6232 |
%{ /* NOCONTEXT */ |
|
6233 |
||
6234 |
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
|
6235 |
GC gc; |
295 | 6236 |
Pixmap pixmap; |
6237 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6238 |
if (ISCONNECTED) { |
1344 | 6239 |
if (__isExternalAddress(aGCId)) { |
6240 |
gc = _GCVal(aGCId); |
|
6241 |
if (__isExternalAddress(aPixmapId)) { |
|
6242 |
pixmap = _PixmapVal(aPixmapId); |
|
6243 |
XSetTile(dpy, gc, pixmap); |
|
6244 |
XSetFillStyle(dpy, gc, FillTiled); |
|
6245 |
RETURN ( self ); |
|
6246 |
} |
|
6247 |
if (aPixmapId == nil) { |
|
6248 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6249 |
RETURN ( self ); |
|
6250 |
} |
|
6251 |
} |
|
295 | 6252 |
} |
6253 |
%}. |
|
6254 |
self primitiveFailed |
|
6255 |
! ! |
|
6256 |
||
6257 |
!XWorkstation methodsFor:'initialize / release'! |
|
6258 |
||
1344 | 6259 |
closeConnection |
295 | 6260 |
"close down the connection to the X-server" |
6261 |
||
6262 |
%{ /* NOCONTEXT */ |
|
6263 |
||
6264 |
if (ISCONNECTED) { |
|
1344 | 6265 |
Display *dpy = myDpy; |
6266 |
||
6267 |
BEGIN_INTERRUPTSBLOCKED |
|
6268 |
__INST(displayId) = nil; |
|
6269 |
XCloseDisplay(dpy); |
|
6270 |
END_INTERRUPTSBLOCKED |
|
295 | 6271 |
} |
6272 |
%} |
|
6273 |
! |
|
6274 |
||
1344 | 6275 |
initializeDefaultValues |
295 | 6276 |
buttonTranslation := ButtonTranslation. |
6277 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
6278 |
||
6279 |
self initializeModifierMappings |
|
6280 |
! |
|
6281 |
||
1344 | 6282 |
initializeEventBuffer |
295 | 6283 |
|sz| |
6284 |
||
6285 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6286 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 6287 |
%}. |
6288 |
eventBuffer isNil ifTrue:[ |
|
1344 | 6289 |
eventBuffer := ByteArray new:sz. |
295 | 6290 |
]. |
6291 |
! |
|
6292 |
||
1344 | 6293 |
initializeFor:aDisplayName |
295 | 6294 |
"initialize the receiver for a connection to an X-Server; |
6295 |
the argument, aDisplayName may be nil (for the default server from |
|
6296 |
DISPLAY-variable or command line argument) or the name of the server |
|
6297 |
as hostname:number" |
|
6298 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
6299 |
|dpyName index arguments| |
295 | 6300 |
|
6301 |
dpyName := aDisplayName. |
|
6302 |
dpyName isNil ifTrue:[ |
|
1344 | 6303 |
"look for a '-display xxx' argument" |
6304 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
6305 |
index := arguments indexOf:'-display'. |
|
6306 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
6307 |
dpyName := arguments at:index+1 |
|
6308 |
] |
|
6309 |
] |
|
295 | 6310 |
]. |
6311 |
%{ |
|
6312 |
int scr; |
|
6313 |
Display *dpy; |
|
6314 |
Visual *visual; |
|
6315 |
XVisualInfo viproto; |
|
6316 |
XVisualInfo *vip; /* retured info */ |
|
6317 |
int maxRGBDepth; |
|
6318 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6319 |
int rgbVisualID; |
|
6320 |
int nvi, i; |
|
6321 |
char *type, *nm; |
|
6322 |
int dummy; |
|
6323 |
OBJ dpyID; |
|
6324 |
||
555 | 6325 |
if (__INST(displayId) != nil) { |
1344 | 6326 |
/* |
6327 |
* already connected - you bad guy try to |
|
6328 |
* trick me manually ? |
|
6329 |
*/ |
|
6330 |
RETURN ( self ); |
|
295 | 6331 |
} |
6332 |
||
6333 |
BEGIN_INTERRUPTSBLOCKED |
|
6334 |
||
6335 |
if (__isString(dpyName)) |
|
1344 | 6336 |
nm = (char *)_stringVal(dpyName); |
295 | 6337 |
else { |
1344 | 6338 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
6339 |
nm = NULL; |
|
295 | 6340 |
} |
6341 |
dpy = XOpenDisplay(nm); |
|
6342 |
||
6343 |
if (dpy) { |
|
1344 | 6344 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 6345 |
|
6346 |
#ifdef SUPERDEBUG |
|
1344 | 6347 |
XSynchronize(dpy, 1); |
295 | 6348 |
#endif |
6349 |
||
1344 | 6350 |
XSetErrorHandler(__XErrorHandler__); |
295 | 6351 |
} |
6352 |
||
6353 |
END_INTERRUPTSBLOCKED |
|
6354 |
%}. |
|
6355 |
displayId isNil ifTrue:[ |
|
1344 | 6356 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
6357 |
^ nil |
|
295 | 6358 |
]. |
6359 |
||
6360 |
dispatching := false. |
|
6361 |
dispatchingExpose := false. |
|
6362 |
isSlow := false. |
|
6363 |
shiftDown := false. |
|
6364 |
ctrlDown := false. |
|
6365 |
metaDown := false. |
|
6366 |
altDown := false. |
|
6367 |
motionEventCompression := true. |
|
6368 |
buttonsPressed := 0. |
|
6369 |
displayName := dpyName. |
|
6370 |
||
6371 |
protocolsAtom := nil. |
|
6372 |
deleteWindowAtom := nil. |
|
6373 |
saveYourselfAtom := nil. |
|
6374 |
quitAppAtom := nil. |
|
6375 |
||
6376 |
self initializeScreenProperties. |
|
1366 | 6377 |
self initializeDeviceResourceTables. |
295 | 6378 |
|
6379 |
self initializeDefaultValues. |
|
6380 |
self initializeEventBuffer. |
|
6381 |
self initializeSpecialFlags. |
|
6382 |
self initializeKeyboardMap. |
|
6383 |
||
6384 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
6385 |
! |
|
6386 |
||
1344 | 6387 |
initializeModifierMappings |
295 | 6388 |
|map mod| |
6389 |
||
6390 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6391 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6392 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6393 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6394 |
||
6395 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6396 |
altModifierMask := metaModifierMask := nil. |
|
6397 |
||
6398 |
map := self modifierMapping. |
|
342 | 6399 |
map isNil ifTrue:[ |
1344 | 6400 |
"/ |
6401 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6402 |
"/ setup some reasonable default. If that is not sufficient, |
|
6403 |
"/ you have to change things from your display.rc file. |
|
6404 |
"/ |
|
6405 |
altModifierMask := self modifier1Mask. |
|
6406 |
metaModifierMask := self modifier2Mask. |
|
6407 |
||
6408 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6409 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6410 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6411 |
altModifiers := #(Alt_R Alt). |
|
342 | 6412 |
] ifFalse:[ |
1344 | 6413 |
altModifierMask := 0. |
6414 |
metaModifierMask := 0. |
|
6415 |
||
6416 |
mod := map at:1. |
|
6417 |
mod notNil ifTrue:[ |
|
6418 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6419 |
]. |
|
6420 |
mod := map at:3. |
|
6421 |
mod notNil ifTrue:[ |
|
6422 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6423 |
]. |
|
6424 |
mod := map at:4. |
|
6425 |
mod notNil ifTrue:[ |
|
6426 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6427 |
metaModifierMask := 1 bitShift:(4-1). |
|
6428 |
]. |
|
6429 |
mod := map at:5. |
|
6430 |
mod notNil ifTrue:[ |
|
6431 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6432 |
altModifierMask := 1 bitShift:(5-1). |
|
6433 |
] |
|
295 | 6434 |
]. |
6435 |
||
6436 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6437 |
! |
|
6438 |
||
1344 | 6439 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6440 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6441 |
|
295 | 6442 |
%{ /* NOCONTEXT */ |
6443 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6444 |
Display *dpy; |
295 | 6445 |
int scr; |
6446 |
Visual *visual; |
|
6447 |
XVisualInfo viproto; |
|
6448 |
XVisualInfo *vip; /* retured info */ |
|
6449 |
int maxRGBDepth; |
|
6450 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6451 |
int rgbVisualID; |
|
6452 |
int nvi, i; |
|
6453 |
int shapeEventBase, shapeErrorBase; |
|
6454 |
int shmEventBase, shmErrorBase; |
|
6455 |
char *type, *nm; |
|
6456 |
int dummy; |
|
6457 |
int mask, shift, nBits; |
|
6458 |
||
6459 |
if (ISCONNECTED) { |
|
1344 | 6460 |
dpy = myDpy; |
6461 |
||
6462 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
6463 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6464 |
||
6465 |
BEGIN_INTERRUPTSBLOCKED |
|
6466 |
||
6467 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6468 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6469 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6470 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6471 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6472 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6473 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6474 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6475 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6476 |
|
6477 |
#ifdef SHAPE |
|
1344 | 6478 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
6479 |
__INST(hasShapeExtension) = true; |
|
6480 |
else |
|
295 | 6481 |
#endif |
1344 | 6482 |
__INST(hasShapeExtension) = false; |
295 | 6483 |
|
6484 |
#ifdef SHM |
|
1344 | 6485 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
6486 |
__INST(hasShmExtension) = true; |
|
6487 |
else |
|
295 | 6488 |
#endif |
1344 | 6489 |
__INST(hasShmExtension) = false; |
295 | 6490 |
|
6491 |
#ifdef DPS |
|
1344 | 6492 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6493 |
__INST(hasDPSExtension) = true; |
|
6494 |
else |
|
295 | 6495 |
#endif |
1344 | 6496 |
__INST(hasDPSExtension) = false; |
295 | 6497 |
|
6498 |
#ifdef XVIDEO |
|
1344 | 6499 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6500 |
__INST(hasXVideoExtension) = true; |
|
6501 |
else |
|
295 | 6502 |
#endif |
1344 | 6503 |
__INST(hasXVideoExtension) = false; |
295 | 6504 |
|
6505 |
#ifdef MBUF |
|
1344 | 6506 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6507 |
__INST(hasMbufExtension) = true; |
|
6508 |
else |
|
295 | 6509 |
#endif |
1344 | 6510 |
__INST(hasMbufExtension) = false; |
295 | 6511 |
|
6512 |
#ifdef PEX5 |
|
1344 | 6513 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6514 |
__INST(hasPEXExtension) = true; |
|
6515 |
else |
|
295 | 6516 |
#endif |
1344 | 6517 |
__INST(hasPEXExtension) = false; |
295 | 6518 |
|
6519 |
#ifdef XIE |
|
1344 | 6520 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6521 |
__INST(hasImageExtension) = true; |
|
6522 |
else |
|
295 | 6523 |
#endif |
1344 | 6524 |
__INST(hasImageExtension) = false; |
295 | 6525 |
|
6526 |
#ifdef XI |
|
1344 | 6527 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6528 |
__INST(hasInputExtension) = true; |
|
6529 |
else |
|
295 | 6530 |
#endif |
1344 | 6531 |
__INST(hasInputExtension) = false; |
6532 |
||
6533 |
/* |
|
6534 |
* look for RGB visual |
|
6535 |
*/ |
|
6536 |
nvi = 0; |
|
6537 |
viproto.screen = scr; |
|
6538 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6539 |
maxRGBDepth = 0; |
|
6540 |
for (i = 0; i < nvi; i++) { |
|
6541 |
switch (vip[i].class) { |
|
6542 |
case TrueColor: |
|
6543 |
if (vip[i].depth > maxRGBDepth) { |
|
6544 |
maxRGBDepth = vip[i].depth; |
|
6545 |
rgbRedMask = vip[i].red_mask; |
|
6546 |
rgbGreenMask = vip[i].green_mask; |
|
6547 |
rgbBlueMask = vip[i].blue_mask; |
|
6548 |
rgbVisualID = vip[i].visualid; |
|
6549 |
} |
|
6550 |
break; |
|
6551 |
} |
|
6552 |
} |
|
6553 |
if (vip) XFree ((char *) vip); |
|
6554 |
||
6555 |
if (maxRGBDepth) { |
|
6556 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6557 |
} |
|
6558 |
||
6559 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6560 |
__INST(monitorType) = @symbol(unknown); |
|
6561 |
__INST(hasColors) = true; |
|
6562 |
__INST(hasGreyscales) = true; |
|
6563 |
switch (visual->class) { |
|
6564 |
case StaticGray: |
|
6565 |
__INST(visualType) = @symbol(StaticGray); |
|
6566 |
__INST(hasColors) = false; |
|
6567 |
__INST(monitorType) = @symbol(monochrome); |
|
6568 |
break; |
|
6569 |
case GrayScale: |
|
6570 |
__INST(visualType) = @symbol(GrayScale); |
|
6571 |
__INST(hasColors) = false; |
|
6572 |
__INST(monitorType) = @symbol(monochrome); |
|
6573 |
break; |
|
6574 |
case StaticColor: |
|
6575 |
__INST(visualType) = @symbol(StaticColor); |
|
6576 |
break; |
|
6577 |
case PseudoColor: |
|
6578 |
__INST(visualType) = @symbol(PseudoColor); |
|
6579 |
break; |
|
6580 |
case TrueColor: |
|
6581 |
__INST(visualType) = @symbol(TrueColor); |
|
6582 |
break; |
|
6583 |
case DirectColor: |
|
6584 |
__INST(visualType) = @symbol(DirectColor); |
|
6585 |
break; |
|
6586 |
} |
|
6587 |
if (DisplayCells(dpy, scr) == 2) { |
|
6588 |
__INST(hasColors) = false; |
|
6589 |
__INST(hasGreyscales) = false; |
|
6590 |
__INST(monitorType) = @symbol(monochrome); |
|
6591 |
} |
|
6592 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
6593 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6594 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6595 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
6596 |
switch (visual->class) { |
|
6597 |
case TrueColor: |
|
6598 |
/* extract number of bits and shift counts */ |
|
6599 |
mask = visual->red_mask; |
|
6600 |
shift = 0; |
|
6601 |
while (mask && ((mask & 1) == 0)) { |
|
6602 |
mask >>= 1; |
|
6603 |
shift++; |
|
6604 |
} |
|
6605 |
__INST(redShift) = __MKSMALLINT(shift); |
|
6606 |
nBits = 0; |
|
6607 |
while (mask) { |
|
6608 |
mask >>= 1; |
|
6609 |
nBits++; |
|
6610 |
} |
|
6611 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
6612 |
||
6613 |
mask = visual->green_mask; |
|
6614 |
shift = 0; |
|
6615 |
while (mask && ((mask & 1) == 0)) { |
|
6616 |
mask >>= 1; |
|
6617 |
shift++; |
|
6618 |
} |
|
6619 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
6620 |
nBits = 0; |
|
6621 |
while (mask) { |
|
6622 |
mask >>= 1; |
|
6623 |
nBits++; |
|
6624 |
} |
|
6625 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
6626 |
||
6627 |
mask = visual->blue_mask; |
|
6628 |
shift = 0; |
|
6629 |
while (mask && ((mask & 1) == 0)) { |
|
6630 |
mask >>= 1; |
|
6631 |
shift++; |
|
6632 |
} |
|
6633 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
6634 |
nBits = 0; |
|
6635 |
while (mask) { |
|
6636 |
mask >>= 1; |
|
6637 |
nBits++; |
|
6638 |
} |
|
6639 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
6640 |
break; |
|
6641 |
} |
|
295 | 6642 |
|
6643 |
#ifndef XA_PRIMARY |
|
1344 | 6644 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6645 |
#else |
1344 | 6646 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6647 |
#endif |
6648 |
#ifndef XA_SECONDARY |
|
1344 | 6649 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6650 |
#else |
1344 | 6651 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6652 |
#endif |
6653 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 6654 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6655 |
#else |
1344 | 6656 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6657 |
#endif |
6658 |
#ifndef XA_STRING |
|
1344 | 6659 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6660 |
#else |
1344 | 6661 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6662 |
#endif |
6663 |
#ifndef XA_LENGTH |
|
1344 | 6664 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6665 |
#else |
1344 | 6666 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6667 |
#endif |
6668 |
||
1344 | 6669 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6670 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6671 |
%}. |
295 | 6672 |
! |
6673 |
||
1344 | 6674 |
initializeSpecialFlags |
295 | 6675 |
"perform additional special server implementation flags" |
6676 |
||
6677 |
"/ |
|
6678 |
"/ assume we have it ... (should check) |
|
6679 |
"/ |
|
6680 |
hasSaveUnder := true. |
|
6681 |
ignoreBackingStore := false. |
|
6682 |
||
6683 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 6684 |
"/ |
6685 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6686 |
"/ which does not correctly handle saveUnder |
|
6687 |
"/ |
|
6688 |
hasSaveUnder := false. |
|
295 | 6689 |
]. |
6690 |
! |
|
6691 |
||
1344 | 6692 |
reinitialize |
295 | 6693 |
virtualRootId := rootId := nil. |
6694 |
super reinitialize. |
|
6695 |
dispatchingExpose := nil |
|
6696 |
! ! |
|
6697 |
||
6698 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6699 |
||
1344 | 6700 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6701 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6702 |
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
|
6703 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6704 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6705 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6706 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6707 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6708 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6709 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6710 |
|
1344 | 6711 |
altModifierMask:aSmallInteger |
341 | 6712 |
"define which key takes the role of an alt-key. |
6713 |
By default, this is X's modifier1, which is the ALT key on |
|
6714 |
most keyboards. However, there may be exceptions to this, |
|
6715 |
and the setting can be changed with: |
|
1344 | 6716 |
Display altModifierMask:(Display modifier2Mask) |
341 | 6717 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
6718 |
" |
|
6719 |
||
6720 |
altModifierMask := aSmallInteger |
|
6721 |
! |
|
6722 |
||
1344 | 6723 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6724 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6725 |
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
|
6726 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6727 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6728 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6729 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6730 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6731 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6732 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6733 |
|
1344 | 6734 |
metaModifierMask:aSmallInteger |
341 | 6735 |
"define which key takes the role of a meta key. |
6736 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6737 |
most keyboards (if present at all). |
|
6738 |
However, there may be exceptions to this, and the setting can |
|
6739 |
be changed with: |
|
1344 | 6740 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 6741 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
6742 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6743 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6744 |
all the time. On those, you should disable the meta key by setting |
|
6745 |
the mask to 0. |
|
6746 |
" |
|
6747 |
||
6748 |
metaModifierMask := aSmallInteger |
|
6749 |
! |
|
6750 |
||
1344 | 6751 |
modifier1Mask |
341 | 6752 |
"return the Xlib mask bit for the 1st modifier key. |
6753 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6754 |
this could be used." |
|
6755 |
||
6756 |
%{ /* NOCONTEXT */ |
|
6757 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6758 |
%} |
|
6759 |
! |
|
6760 |
||
1344 | 6761 |
modifier2Mask |
341 | 6762 |
"return the Xlib mask bit for the 2nd modifier key. |
6763 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6764 |
this could be used." |
|
6765 |
||
6766 |
%{ /* NOCONTEXT */ |
|
6767 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6768 |
%} |
|
6769 |
! |
|
6770 |
||
1344 | 6771 |
modifierMapping |
341 | 6772 |
"Get the Modifier Mapping. |
6773 |
We return an array of arrays of keycodes" |
|
6774 |
||
6775 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6776 |
||
6777 |
%{ |
|
6778 |
XModifierKeymap *modmap; |
|
6779 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6780 |
||
6781 |
if (ISCONNECTED) { |
|
1344 | 6782 |
Display *dpy = myDpy; |
6783 |
||
6784 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6785 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6786 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6787 |
if (modifierKeyMap != nil) { |
|
6788 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6789 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6790 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6791 |
} |
|
6792 |
XFreeModifiermap(modmap); |
|
6793 |
} |
|
341 | 6794 |
} |
6795 |
%}. |
|
6796 |
||
6797 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6798 |
||
6799 |
ret := Array new:8. |
|
6800 |
nextKey := 1. |
|
6801 |
1 to:8 do:[ :i | |
|
1344 | 6802 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
6803 |
|mod| |
|
6804 |
||
6805 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6806 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6807 |
key ~= 0 ifTrue:[ |
|
6808 |
mod add:key |
|
6809 |
]. |
|
6810 |
]. |
|
6811 |
ret at:i put:mod. |
|
6812 |
]. |
|
6813 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 6814 |
]. |
6815 |
||
6816 |
^ ret |
|
6817 |
||
6818 |
" |
|
1344 | 6819 |
Display modifierMapping |
341 | 6820 |
" |
6821 |
! |
|
6822 |
||
1344 | 6823 |
stringFromKeycode:code |
341 | 6824 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
6825 |
||
6826 |
|str| |
|
6827 |
||
6828 |
%{ |
|
6829 |
KeySym keysym; |
|
6830 |
char *keystring; |
|
6831 |
||
6832 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 6833 |
Display *dpy = myDpy; |
6834 |
||
6835 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6836 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6837 |
str = __MKSTRING(keystring); |
|
341 | 6838 |
} |
6839 |
%}. |
|
6840 |
^ str |
|
6841 |
||
6842 |
" |
|
1344 | 6843 |
Display stringFromKeycode:28 |
341 | 6844 |
" |
6845 |
! |
|
6846 |
||
1344 | 6847 |
translateKey:untranslatedKey |
295 | 6848 |
"Return the key translated via the translation table. |
6849 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6850 |
which gets further processed in the superclasses translation method." |
|
6851 |
||
6852 |
|key| |
|
6853 |
||
6854 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 6855 |
key := RawKeysymTranslation at:key ifAbsent:key. |
6856 |
key := key asSymbol. |
|
295 | 6857 |
]. |
6858 |
^ super translateKey:key |
|
6859 |
! ! |
|
6860 |
||
6861 |
!XWorkstation methodsFor:'misc'! |
|
6862 |
||
1344 | 6863 |
beep |
295 | 6864 |
"output an audible beep or bell" |
6865 |
||
6866 |
self beep:50 |
|
6867 |
! |
|
6868 |
||
1344 | 6869 |
beep:volumeInPercent |
295 | 6870 |
"output an audible beep" |
6871 |
%{ |
|
6872 |
int volume; |
|
6873 |
||
6874 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 6875 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
6876 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
6877 |
if (volume < -100) volume = -100; |
|
6878 |
else if (volume > 100) volume = 100; |
|
6879 |
BEGIN_INTERRUPTSBLOCKED |
|
6880 |
XBell(myDpy, volume); |
|
6881 |
END_INTERRUPTSBLOCKED |
|
295 | 6882 |
} |
6883 |
%} |
|
6884 |
! |
|
6885 |
||
1344 | 6886 |
buffered |
295 | 6887 |
"buffer drawing - do not send it immediately to the display. |
374 | 6888 |
This is the default anyway. |
6889 |
See #unBuffered for additional info." |
|
295 | 6890 |
|
6891 |
%{ /* NOCONTEXT */ |
|
6892 |
||
6893 |
if (ISCONNECTED) { |
|
1344 | 6894 |
BEGIN_INTERRUPTSBLOCKED |
6895 |
XSynchronize(myDpy, 0); |
|
6896 |
END_INTERRUPTSBLOCKED |
|
295 | 6897 |
} |
6898 |
%} |
|
374 | 6899 |
" |
6900 |
Display buffered |
|
6901 |
" |
|
295 | 6902 |
! |
6903 |
||
1344 | 6904 |
flush |
295 | 6905 |
"send all buffered drawing to the display. |
6906 |
This may be required to make certain, that all previous operations |
|
6907 |
are really sent to the display before continuing. For example, |
|
6908 |
after a cursor-change with a followup long computation. |
|
374 | 6909 |
(otherwise, the cursor change request may still be in the output buffer) |
6910 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6911 |
|
6912 |
%{ /* NOCONTEXT */ |
|
6913 |
||
6914 |
if (ISCONNECTED) { |
|
1344 | 6915 |
BEGIN_INTERRUPTSBLOCKED |
6916 |
XFlush(myDpy); |
|
6917 |
END_INTERRUPTSBLOCKED |
|
310 | 6918 |
} |
6919 |
%} |
|
6920 |
! |
|
6921 |
||
1344 | 6922 |
flushDpsContext:aDPSContext |
295 | 6923 |
|
6924 |
%{ /* NOCONTEXT */ |
|
6925 |
#ifdef DPS |
|
6926 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 6927 |
BEGIN_INTERRUPTSBLOCKED |
6928 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6929 |
END_INTERRUPTSBLOCKED |
|
6930 |
RETURN ( self ); |
|
295 | 6931 |
} |
6932 |
#endif |
|
374 | 6933 |
%}. |
295 | 6934 |
self primitiveFailed |
6935 |
! |
|
6936 |
||
1344 | 6937 |
refreshKeyboardMapping:eB |
295 | 6938 |
%{ |
6939 |
XMappingEvent *ev; |
|
6940 |
||
6941 |
if (__isByteArray(eB)) { |
|
1344 | 6942 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
6943 |
XRefreshKeyboardMapping(ev); |
|
295 | 6944 |
} |
6945 |
%} |
|
6946 |
! |
|
6947 |
||
1344 | 6948 |
setInputFocusTo:aWindowId |
295 | 6949 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
6950 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6951 |
! |
|
6952 |
||
1344 | 6953 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 6954 |
"set the focus to the view as defined by aWindowId. |
6955 |
Passing nil set the focus to no window and lets the display discard all |
|
6956 |
input until a new focus is set. |
|
6957 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6958 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6959 |
given to the parent view, the root view or no view." |
|
6960 |
||
6961 |
%{ /* NOCONTEXT */ |
|
6962 |
int arg; |
|
6963 |
Window focusWindow; |
|
6964 |
||
6965 |
if (ISCONNECTED) { |
|
1344 | 6966 |
if (__isExternalAddress(aWindowId)) { |
6967 |
focusWindow = _WindowVal(aWindowId); |
|
6968 |
} else { |
|
6969 |
focusWindow = None; |
|
6970 |
} |
|
6971 |
if (revertSymbol == @symbol(parent)) |
|
6972 |
arg = RevertToParent; |
|
6973 |
else if (revertSymbol == @symbol(root)) |
|
6974 |
arg = RevertToPointerRoot; |
|
6975 |
else |
|
6976 |
arg = RevertToNone; |
|
6977 |
||
6978 |
BEGIN_INTERRUPTSBLOCKED |
|
6979 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6980 |
END_INTERRUPTSBLOCKED |
|
6981 |
RETURN ( self ); |
|
295 | 6982 |
} |
6983 |
%}. |
|
6984 |
self primitiveFailed |
|
6985 |
! |
|
6986 |
||
1344 | 6987 |
sync |
341 | 6988 |
"send all buffered drawing to the display AND wait until the display |
6989 |
has finished drawing it. |
|
6990 |
This is almost never needed, except if you are about to read previously |
|
374 | 6991 |
drawn pixels back from the display screen, or you want to wait for a beep |
6992 |
to be finished. See also #flush." |
|
341 | 6993 |
|
6994 |
%{ /* NOCONTEXT */ |
|
6995 |
||
6996 |
if (ISCONNECTED) { |
|
1344 | 6997 |
BEGIN_INTERRUPTSBLOCKED |
6998 |
XSync(myDpy, 0); |
|
6999 |
END_INTERRUPTSBLOCKED |
|
341 | 7000 |
} |
7001 |
%} |
|
7002 |
! |
|
7003 |
||
1344 | 7004 |
unBuffered |
374 | 7005 |
"make all drawing be sent immediately to the display. |
7006 |
This makes all graphics synchronous and turns off any buffering |
|
7007 |
(i.e. each individual draw-request is sent immediately without |
|
7008 |
packing multiple requests into a larger message buffer). |
|
7009 |
Be prepared, that this slows down graphics considerably. |
|
7010 |
However, it allows display errors to be handled immediately and |
|
7011 |
may be useful if you get Xdisplay errors and want to find the request |
|
7012 |
which was responsiblefor it. See also #buffered." |
|
295 | 7013 |
|
7014 |
%{ /* NOCONTEXT */ |
|
7015 |
||
7016 |
if (ISCONNECTED) { |
|
1344 | 7017 |
BEGIN_INTERRUPTSBLOCKED |
7018 |
XSynchronize(myDpy, 1); |
|
7019 |
END_INTERRUPTSBLOCKED |
|
295 | 7020 |
} |
7021 |
%} |
|
7022 |
"Display unbuffered" |
|
7023 |
! ! |
|
7024 |
||
7025 |
!XWorkstation methodsFor:'pointer queries '! |
|
7026 |
||
1344 | 7027 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7028 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7029 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7030 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7031 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7032 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7033 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7034 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7035 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7036 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7037 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7038 |
|
1344 | 7039 |
buttonStates |
295 | 7040 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7041 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7042 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7043 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 7044 |
|
7045 |
%{ /* NOCONTEXT*/ |
|
7046 |
Window w; |
|
555 | 7047 |
int screen = __intVal(__INST(screen)); |
295 | 7048 |
Window rootRet, childRet; |
7049 |
int rootX, rootY, winX, winY; |
|
7050 |
unsigned int mask; |
|
7051 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7052 |
if (ISCONNECTED) { |
1344 | 7053 |
Display *dpy = myDpy; |
7054 |
||
7055 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7056 |
#ifdef VIRTUAL_ROOT |
1344 | 7057 |
w = getRootWindow(myDpy, screen); |
295 | 7058 |
#else |
1344 | 7059 |
w = RootWindow(dpy, screen); |
295 | 7060 |
#endif |
1344 | 7061 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7062 |
&rootX, &rootY, |
|
7063 |
&winX, &winY, |
|
7064 |
&mask); |
|
7065 |
END_INTERRUPTSBLOCKED |
|
7066 |
RETURN (__MKSMALLINT(mask)); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7067 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7068 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7069 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7070 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7071 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7072 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7073 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7074 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7075 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7076 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7077 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7078 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7079 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7080 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7081 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7082 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7083 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7084 |
" |
295 | 7085 |
! |
7086 |
||
1344 | 7087 |
leftButtonStateMask |
295 | 7088 |
"return an integer for masking out the left button from a |
7089 |
buttonStates value" |
|
7090 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7091 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7092 |
|
295 | 7093 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7094 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7095 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 7096 |
! |
7097 |
||
1344 | 7098 |
middleButtonStateMask |
295 | 7099 |
"return an integer for masking out the middle button from a |
7100 |
buttonStates value" |
|
7101 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7102 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7103 |
|
295 | 7104 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7105 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7106 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 7107 |
! |
7108 |
||
1344 | 7109 |
pointerPosition |
295 | 7110 |
"return the current pointer position in root-window coordinates" |
7111 |
||
7112 |
|xpos ypos| |
|
7113 |
||
7114 |
%{ |
|
7115 |
Window w; |
|
555 | 7116 |
int screen = __intVal(__INST(screen)); |
295 | 7117 |
Window rootRet, childRet; |
7118 |
int rootX, rootY, winX, winY; |
|
7119 |
unsigned int mask; |
|
7120 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7121 |
if (ISCONNECTED) { |
1344 | 7122 |
Display *dpy = myDpy; |
7123 |
||
7124 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7125 |
#ifdef VIRTUAL_ROOT |
1344 | 7126 |
w = getRootWindow(myDpy, screen); |
295 | 7127 |
#else |
1344 | 7128 |
w = RootWindow(dpy, screen); |
295 | 7129 |
#endif |
1344 | 7130 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7131 |
&rootX, &rootY, |
|
7132 |
&winX, &winY, |
|
7133 |
&mask); |
|
7134 |
xpos = __MKSMALLINT(rootX); |
|
7135 |
ypos = __MKSMALLINT(rootY); |
|
7136 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7137 |
} |
295 | 7138 |
%} |
7139 |
. |
|
7140 |
^ xpos @ ypos |
|
7141 |
! |
|
7142 |
||
1344 | 7143 |
rightButtonStateMask |
295 | 7144 |
"return an integer for masking out the right button from a |
7145 |
buttonStates value" |
|
7146 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7147 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7148 |
|
295 | 7149 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7150 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7151 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 7152 |
! |
7153 |
||
1344 | 7154 |
rootPositionOfLastEvent |
295 | 7155 |
"return the position in root-window coordinates |
7156 |
of the last button, key or pointer event" |
|
7157 |
||
7158 |
^ eventRootX @ eventRootY |
|
7159 |
! ! |
|
7160 |
||
7161 |
!XWorkstation methodsFor:'resources'! |
|
7162 |
||
1344 | 7163 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7164 |
"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
|
7165 |
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
|
7166 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7167 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7168 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7169 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7170 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7171 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7172 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7173 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7174 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7175 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7176 |
|
1344 | 7177 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7178 |
"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
|
7179 |
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
|
7180 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7181 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7182 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7183 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7184 |
if (ISCONNECTED) { |
1344 | 7185 |
if (__isString(aStringOrSymbol) |
7186 |
|| __isSymbol(aStringOrSymbol)) { |
|
7187 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
7188 |
(create == true) ? False : True); |
|
7189 |
if (prop == None) { |
|
7190 |
RETURN (nil); |
|
7191 |
} |
|
7192 |
RETURN ( __MKATOMOBJ(prop) ); |
|
7193 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7194 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7195 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7196 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7197 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7198 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7199 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7200 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7201 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7202 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7203 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7204 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7205 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7206 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7207 |
|
1344 | 7208 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7209 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7210 |
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
|
7211 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7212 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7213 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7214 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7215 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7216 |
|
1344 | 7217 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7218 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7219 |
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
|
7220 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7221 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7222 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7223 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7224 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7225 |
|
1344 | 7226 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7227 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7228 |
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
|
7229 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7230 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7231 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7232 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7233 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7234 |
|
1344 | 7235 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7236 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7237 |
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
|
7238 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7239 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7240 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7241 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7242 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7243 |
|
1344 | 7244 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7245 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7246 |
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
|
7247 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7248 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7249 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7250 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7251 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7252 |
|
1344 | 7253 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7254 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7255 |
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
|
7256 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7257 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7258 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7259 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7260 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7261 |
if (ISCONNECTED) { |
1344 | 7262 |
if (__isAtomID(anAtomID)) { |
7263 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
7264 |
if (name == 0) { |
|
7265 |
RETURN (nil); |
|
7266 |
} |
|
7267 |
str = __MKSTRING(name); |
|
7268 |
XFree(name); |
|
7269 |
RETURN ( str ); |
|
7270 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7271 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7272 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7273 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7274 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7275 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7276 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7277 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7278 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7279 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7280 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7281 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7282 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7283 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7284 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7285 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7286 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7287 |
|
1344 | 7288 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7289 |
"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
|
7290 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7291 |
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
|
7292 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7293 |
Notice: |
1344 | 7294 |
we do not plan to use X's resources for ST/X's defaults, |
7295 |
styles or resources. This would make porting of applications |
|
7296 |
to different platforms much more difficult (Windows has no resource |
|
7297 |
database). If you stay within ST/X's resource files, these can be |
|
7298 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7299 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7300 |
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
|
7301 |
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
|
7302 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7303 |
|
295 | 7304 |
%{ |
7305 |
char *rslt; |
|
7306 |
||
7307 |
if ((__isString(name) || __isSymbol(name)) |
|
7308 |
&& (__isString(cls) || __isSymbol(cls)) |
|
7309 |
&& ISCONNECTED) { |
|
1344 | 7310 |
BEGIN_INTERRUPTSBLOCKED |
7311 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
7312 |
(char *)_stringVal(name)); |
|
7313 |
END_INTERRUPTSBLOCKED |
|
7314 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7315 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7316 |
%}. |
295 | 7317 |
self primitiveFailed. |
7318 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7319 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7320 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 7321 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7322 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7323 |
|
1344 | 7324 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7325 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7326 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 7327 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7328 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7329 |
|
1344 | 7330 |
Display getResource:'beNiceToColormap' class:'any' |
7331 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7332 |
" |
295 | 7333 |
! ! |
7334 |
||
7335 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
7336 |
||
1462
f8b2909deb3c
renamed getBitsFrom to getBitsFromId
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
7337 |
getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 7338 |
"get bits from a drawable into the imageBits. The storage for the bits |
7339 |
must be big enough for the data to fit. If ok, returns an array with some |
|
7340 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
7341 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
7342 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
7343 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7344 |
|rawInfo info| |
295 | 7345 |
|
7346 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 7347 |
self primitiveFailed. |
7348 |
^ nil |
|
295 | 7349 |
]. |
7350 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7351 |
rawInfo := Array new:8. |
1344 | 7352 |
"1 -> bit order" |
7353 |
"2 -> depth" |
|
7354 |
"3 -> bytes_per_line" |
|
7355 |
"4 -> byte_order" |
|
7356 |
"5 -> format" |
|
7357 |
"6 -> bitmap_unit" |
|
7358 |
"7 -> bitmap_pad" |
|
7359 |
"8 -> bits_per_pixel" |
|
295 | 7360 |
|
7361 |
"/ had to extract the getPixel call into a separate method, to specify |
|
7362 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
7363 |
"/ of temporary stack space |
|
7364 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7365 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 7366 |
info := IdentityDictionary new. |
7367 |
info at:#bitOrder put:(rawInfo at:1). |
|
7368 |
info at:#depth put:(rawInfo at:2). |
|
7369 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
7370 |
info at:#byteOrder put:(rawInfo at:4). |
|
7371 |
info at:#format put:(rawInfo at:5). |
|
7372 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
7373 |
info at:#bitmapPad put:(rawInfo at:7). |
|
7374 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
7375 |
^ info |
|
295 | 7376 |
]. |
7377 |
" |
|
7378 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
7379 |
or is too small to hold the bits |
|
7380 |
" |
|
7381 |
^ self primitiveFailed |
|
7382 |
! |
|
7383 |
||
1344 | 7384 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
7385 |
"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
|
7386 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 7387 |
|
7388 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
7389 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7390 |
Window win; |
295 | 7391 |
XImage *img; |
7392 |
int ret; |
|
7393 |
int xpos, ypos; |
|
7394 |
||
1209 | 7395 |
if (ISCONNECTED |
7396 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 7397 |
win = _WindowVal(aDrawableId); |
7398 |
xpos = __intVal(x); |
|
7399 |
ypos = __intVal(y); |
|
7400 |
if ((xpos < 0) || (ypos < 0)) { |
|
7401 |
RETURN ( __MKSMALLINT(0) ); |
|
7402 |
} |
|
7403 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
7404 |
if (img != 0) { |
|
7405 |
ret = XGetPixel(img, 0, 0); |
|
7406 |
XDestroyImage(img); |
|
7407 |
RETURN ( __MKSMALLINT(ret) ); |
|
7408 |
} |
|
295 | 7409 |
} |
7410 |
%}. |
|
7411 |
^ nil |
|
7412 |
! |
|
7413 |
||
1344 | 7414 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 7415 |
"since XGetImage may allocate huge amount of stack space |
7416 |
(some implementations use alloca), this must run with unlimited stack." |
|
7417 |
||
7418 |
%{ /* UNLIMITEDSTACK */ |
|
7419 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7420 |
Window win; |
295 | 7421 |
XImage *image = (XImage *)0; |
7422 |
int pad, bytes_per_line, numBytes; |
|
7423 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7424 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7425 |
&& __isExternalAddress(aDrawableId) |
295 | 7426 |
&& __bothSmallInteger(srcx, srcy) |
7427 |
&& __bothSmallInteger(w, h) |
|
7428 |
&& __isArray(info) |
|
7429 |
&& __isByteArray(imageBits)) { |
|
1344 | 7430 |
Display *dpy = myDpy; |
7431 |
||
7432 |
win = _WindowVal(aDrawableId); |
|
7433 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
|
7434 |
__intVal(w), __intVal(h), |
|
7435 |
(unsigned)AllPlanes, ZPixmap); |
|
7436 |
||
7437 |
if (! image) { |
|
7438 |
RETURN ( false ); |
|
7439 |
} |
|
7440 |
||
7441 |
pad = image->bitmap_pad; |
|
295 | 7442 |
#ifdef SUPERDEBUG |
1344 | 7443 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 7444 |
#endif |
1344 | 7445 |
switch (image->depth) { |
7446 |
case 1: |
|
7447 |
case 2: |
|
7448 |
case 4: |
|
7449 |
case 8: |
|
7450 |
case 16: |
|
7451 |
case 24: |
|
7452 |
case 32: |
|
7453 |
numBytes = image->bytes_per_line * image->height; |
|
7454 |
break; |
|
7455 |
default: |
|
7456 |
/* unsupported depth ? */ |
|
7457 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
7458 |
numBytes = image->bytes_per_line * image->height; |
|
7459 |
break; |
|
7460 |
} |
|
295 | 7461 |
|
7462 |
#ifdef SUPERDEBUG |
|
1344 | 7463 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 7464 |
#endif |
7465 |
||
1344 | 7466 |
if (numBytes > __byteArraySize(imageBits)) { |
7467 |
/* imageBits too small */ |
|
7468 |
printf("provided byteArray too small\n"); |
|
7469 |
goto fail; |
|
7470 |
} |
|
7471 |
if (image->bitmap_bit_order == MSBFirst) |
|
7472 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
7473 |
else |
|
7474 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
7475 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
7476 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
7477 |
if (image->byte_order == MSBFirst) |
|
7478 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
7479 |
else |
|
7480 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
7481 |
if (image->format == XYBitmap) |
|
7482 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
7483 |
else if (image->format == XYPixmap) |
|
7484 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
7485 |
else if (image->format == ZPixmap) |
|
7486 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7487 |
|
1344 | 7488 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
7489 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
7490 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
7491 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
7492 |
XDestroyImage(image); |
|
7493 |
RETURN ( true ); |
|
295 | 7494 |
} |
7495 |
fail: |
|
7496 |
if (image) { |
|
1344 | 7497 |
XDestroyImage(image); |
295 | 7498 |
} |
7499 |
%}. |
|
7500 |
^ false |
|
7501 |
! ! |
|
7502 |
||
7503 |
!XWorkstation methodsFor:'selections'! |
|
7504 |
||
1344 | 7505 |
getObjectProperty:propertyID from:aWindowID |
295 | 7506 |
"get an object property; return object or nil" |
7507 |
||
7508 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1344 | 7509 |
type == stringAtom ifTrue:[ |
7510 |
^ value |
|
7511 |
]. |
|
7512 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7513 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7514 |
] |
|
295 | 7515 |
]. |
7516 |
^ nil |
|
7517 |
! |
|
7518 |
||
1344 | 7519 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
295 | 7520 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
7521 |
||
7522 |
|val typeID cls| |
|
7523 |
||
7524 |
cls := ByteArray. |
|
7525 |
%{ |
|
7526 |
Window window; |
|
7527 |
Atom property; |
|
7528 |
char *cp, *cp2; |
|
7529 |
Atom actual_type; |
|
7530 |
int actual_format,i; |
|
7531 |
unsigned long nitems, bytes_after, nread; |
|
7532 |
unsigned char *data; |
|
7533 |
int ok = 1; |
|
7534 |
# define PROP_SIZE 2048 |
|
7535 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7536 |
if (ISCONNECTED) { |
1344 | 7537 |
Display *dpy = myDpy; |
7538 |
||
7539 |
if (__isAtomID(propertyID)) { |
|
7540 |
property = _AtomVal(propertyID); |
|
7541 |
if (__isExternalAddress(aWindowID)) { |
|
7542 |
window = _WindowVal(aWindowID); |
|
7543 |
} else { |
|
7544 |
window = DefaultRootWindow(dpy); |
|
7545 |
} |
|
7546 |
||
7547 |
nread = 0; |
|
7548 |
cp = 0; |
|
295 | 7549 |
/* |
1344 | 7550 |
fprintf(stderr, "getProperty: "); |
295 | 7551 |
*/ |
1344 | 7552 |
do { |
7553 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7554 |
AnyPropertyType,&actual_type,&actual_format, |
|
7555 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7556 |
!= Success) { |
|
7557 |
ok = 0; |
|
7558 |
break; |
|
7559 |
} |
|
7560 |
typeID = __MKATOMOBJ(actual_type); |
|
7561 |
if (! cp) { |
|
7562 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7563 |
} else { |
|
7564 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7565 |
cp2 = cp + nread; |
|
7566 |
} |
|
7567 |
if (! cp) { |
|
7568 |
XFree(data); |
|
7569 |
goto fail; |
|
7570 |
} |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7571 |
|
1344 | 7572 |
nread += nitems; |
7573 |
bcopy(data, cp2, nitems); |
|
7574 |
XFree(data); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7575 |
/* |
1344 | 7576 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7577 |
*/ |
1344 | 7578 |
} while (bytes_after > 0); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7579 |
/* |
1344 | 7580 |
fprintf(stderr, "\n"); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7581 |
*/ |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7582 |
|
1344 | 7583 |
if (ok) { |
7584 |
if (actual_type == XA_STRING) { |
|
7585 |
cp[nread] = '\0'; |
|
7586 |
val = __MKSTRING_L(cp, nread); |
|
7587 |
} else { |
|
7588 |
val = __new(nread + OHDR_SIZE); |
|
7589 |
val->o_class = cls; |
|
7590 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
7591 |
} |
|
7592 |
} |
|
7593 |
if (cp) |
|
7594 |
free(cp); |
|
7595 |
} |
|
295 | 7596 |
} |
7597 |
fail: ; |
|
7598 |
%}. |
|
7599 |
typeID isNil ifTrue:[ |
|
1344 | 7600 |
^ false |
295 | 7601 |
]. |
7602 |
aTwoArgBlock value:typeID value:val. |
|
7603 |
^ true |
|
7604 |
! |
|
7605 |
||
1344 | 7606 |
getSelectionFor:drawableId |
295 | 7607 |
"get the object selection - either immediate, or asynchronous. |
7608 |
Returns nil, if async request is on its way" |
|
7609 |
||
7610 |
|selProp sel| |
|
7611 |
||
7612 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 7613 |
"no primary selection - use cut buffer" |
7614 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7615 |
^ sel |
|
295 | 7616 |
]. |
7617 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7618 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7619 |
^ nil |
|
7620 |
! |
|
7621 |
||
1344 | 7622 |
getSelectionOwnerOf:selectionAtomID |
295 | 7623 |
"get the owner of a selection" |
7624 |
||
7625 |
%{ /* NOCONTEXT */ |
|
7626 |
Atom selection; |
|
7627 |
Window window; |
|
7628 |
||
7629 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 7630 |
Display *dpy = myDpy; |
7631 |
||
7632 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7633 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
295 | 7634 |
} |
7635 |
%}. |
|
7636 |
self primitiveFailed. |
|
7637 |
^ nil |
|
7638 |
! |
|
7639 |
||
1344 | 7640 |
getTextProperty:propertyID from:aWindowID |
295 | 7641 |
"get a text property; return string or nil" |
7642 |
||
7643 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1344 | 7644 |
type == stringAtom ifTrue:[ |
7645 |
^ value |
|
7646 |
] |
|
295 | 7647 |
]. |
7648 |
^ nil |
|
7649 |
! |
|
7650 |
||
1344 | 7651 |
getTextSelectionFor:drawableId |
295 | 7652 |
"get the text selection - either immediate, or asynchronous. |
7653 |
Returns nil, if async request is on its way" |
|
7654 |
||
7655 |
|selProp sel| |
|
7656 |
||
7657 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 7658 |
"no primary selection - use cut buffer" |
7659 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7660 |
^ sel |
|
295 | 7661 |
]. |
7662 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7663 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7664 |
^ nil |
|
7665 |
! |
|
7666 |
||
1344 | 7667 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 7668 |
"ask the server to send us the selection - the view with ID aWindowID |
7669 |
will later receive a SelectionNotify event for it." |
|
7670 |
||
7671 |
^ self requestSelection:selectionID |
|
1344 | 7672 |
property:propertyID |
7673 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7674 |
for:aWindowId |
|
7675 |
! |
|
7676 |
||
7677 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 7678 |
"ask the server to send us the selection - the view with id aWindowID |
7679 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7680 |
with the selections value)." |
|
7681 |
||
7682 |
%{ /* NOCONTEXT */ |
|
7683 |
Atom sel_prop; |
|
7684 |
char *cp; |
|
7685 |
||
7686 |
if (__isExternalAddress(aWindowId) |
|
7687 |
&& ISCONNECTED |
|
7688 |
&& __isSmallInteger(typeID) |
|
7689 |
&& __isAtomID(selectionID)) { |
|
1344 | 7690 |
Display *dpy = myDpy; |
7691 |
||
7692 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7693 |
/* |
|
7694 |
* no owner of primary selection |
|
7695 |
*/ |
|
7696 |
RETURN (false); |
|
7697 |
} |
|
7698 |
/* |
|
7699 |
* PRIMARY selection |
|
7700 |
*/ |
|
7701 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7702 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7703 |
RETURN (true); |
|
295 | 7704 |
} |
7705 |
%}. |
|
7706 |
self primitiveFailed. |
|
7707 |
^ false |
|
7708 |
||
7709 |
" |
|
7710 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 7711 |
property:(Display atomIDOf:'VT_SELECTION') |
7712 |
for:0 |
|
295 | 7713 |
" |
7714 |
! |
|
7715 |
||
1344 | 7716 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 7717 |
"ask the server to send us the selection - the view with ID aWindowID |
7718 |
will later receive a SelectionNotify event for it." |
|
7719 |
||
7720 |
^ self requestSelection:selectionID |
|
1344 | 7721 |
property:propertyID |
7722 |
type:stringAtom |
|
7723 |
for:aWindowId |
|
7724 |
! |
|
7725 |
||
7726 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7727 |
"send aString back from a SelectionRequest" |
7728 |
||
7729 |
self |
|
1344 | 7730 |
sendSelection:something |
7731 |
selection:primaryAtom |
|
7732 |
property:propertyID |
|
7733 |
target:targetID |
|
7734 |
from:windowID |
|
7735 |
to:requestorID |
|
7736 |
! |
|
7737 |
||
7738 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7739 |
"send aString back from a SelectionRequest" |
7740 |
||
7741 |
self |
|
1344 | 7742 |
setProperty:propertyID |
7743 |
type:targetID |
|
7744 |
value:something |
|
7745 |
for:requestorID. |
|
295 | 7746 |
self |
1344 | 7747 |
sendSelectionNotifySelection:selectionID |
7748 |
property:propertyID |
|
7749 |
target:targetID |
|
7750 |
from:requestorID |
|
7751 |
to:requestorID. |
|
7752 |
! |
|
7753 |
||
7754 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7755 |
"send a selectionNotify back from a SelectionRequest" |
7756 |
||
7757 |
%{ /* NOCONTEXT */ |
|
7758 |
||
7759 |
if (__isAtomID(propertyID) |
|
7760 |
&& __isExternalAddress(requestorID) |
|
7761 |
&& ISCONNECTED |
|
7762 |
&& __isAtomID(targetID) |
|
7763 |
&& __isAtomID(selectionID)) { |
|
1344 | 7764 |
Display *dpy = myDpy; |
7765 |
XEvent ev; |
|
7766 |
Window requestor = _WindowVal(requestorID); |
|
7767 |
Atom property = _AtomVal(propertyID); |
|
7768 |
Atom target = _AtomVal(targetID); |
|
7769 |
Atom selection = _AtomVal(selectionID); |
|
7770 |
Status result; |
|
7771 |
||
7772 |
ev.xselection.type = SelectionNotify; |
|
7773 |
ev.xselection.selection = selection; |
|
7774 |
ev.xselection.target = target; |
|
7775 |
if (__isExternalAddress(windowID)) |
|
7776 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7777 |
else |
|
7778 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7779 |
ev.xselection.time = CurrentTime; |
|
7780 |
if (property == None) |
|
7781 |
ev.xselection.property = target; |
|
7782 |
else |
|
7783 |
ev.xselection.property = property; |
|
7784 |
||
7785 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7786 |
ev.xselection.selection, |
|
7787 |
ev.xselection.property, |
|
7788 |
ev.xselection.target, |
|
7789 |
ev.xselection.requestor, |
|
7790 |
requestor)); |
|
7791 |
||
7792 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7793 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7794 |
DPRINTF(("bad status\n")); |
|
7795 |
RETURN (false); |
|
7796 |
} |
|
7797 |
RETURN (true) |
|
382 | 7798 |
} |
7799 |
%}. |
|
7800 |
self primitiveFailed. |
|
7801 |
^ false |
|
295 | 7802 |
! |
7803 |
||
1344 | 7804 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
295 | 7805 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
7806 |
! |
|
7807 |
||
1344 | 7808 |
setObjectProperty:propertyID value:anObject for:aWindowID |
295 | 7809 |
|s| |
7810 |
||
7811 |
(anObject isMemberOf:String) ifTrue:[ |
|
1344 | 7812 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
295 | 7813 |
]. |
7814 |
s := WriteStream on:(ByteArray new:200). |
|
7815 |
anObject storeBinaryOn:s. |
|
7816 |
^ self |
|
1344 | 7817 |
setProperty:propertyID |
7818 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7819 |
value:(s contents) |
|
7820 |
for:aWindowID |
|
7821 |
! |
|
7822 |
||
7823 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
295 | 7824 |
|
7825 |
%{ /* UNLIMITEDSTACK */ |
|
7826 |
||
7827 |
Atom prop, type; |
|
7828 |
Window window; |
|
7829 |
unsigned int value; |
|
7830 |
||
7831 |
if (__isAtomID(propertyID) |
|
7832 |
&& __isAtomID(typeID) |
|
7833 |
&& ISCONNECTED |
|
7834 |
&& (__isString(anObject) |
|
1344 | 7835 |
|| __isSmallInteger(anObject) |
7836 |
|| __isSymbol(anObject) |
|
7837 |
|| __isByteArray(anObject) |
|
7838 |
|| __isWords(anObject))) { |
|
7839 |
||
7840 |
Display *dpy = myDpy; |
|
7841 |
||
7842 |
prop = _AtomVal(propertyID); |
|
7843 |
type = _AtomVal(typeID); |
|
7844 |
if (__isExternalAddress(aWindowID)) { |
|
7845 |
window = _WindowVal(aWindowID); |
|
7846 |
} else { |
|
7847 |
window = DefaultRootWindow(dpy); |
|
7848 |
} |
|
7849 |
if (__isSmallInteger(anObject)) { |
|
7850 |
value = __intVal(anObject); |
|
7851 |
XChangeProperty(dpy, window, prop, type, 32, |
|
7852 |
PropModeReplace, |
|
7853 |
(unsigned char *)(&value), sizeof(unsigned int)); |
|
7854 |
} else { |
|
7855 |
if (__isByteArray(anObject)) { |
|
7856 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7857 |
PropModeReplace, |
|
7858 |
__ByteArrayInstPtr(anObject)->ba_element, |
|
7859 |
__byteArraySize(anObject)); |
|
7860 |
} else { |
|
7861 |
/* string or symbol or wordArray-like (16bit-string) object */ |
|
7862 |
if (__isWords(__qClass(anObject))) { |
|
7863 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
|
7864 |
PropModeReplace, |
|
7865 |
__stringVal(anObject), |
|
7866 |
__wordArraySize(anObject)); |
|
7867 |
} else { |
|
7868 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
|
7869 |
PropModeReplace, |
|
7870 |
__stringVal(anObject), |
|
7871 |
strlen(__stringVal(anObject))); |
|
7872 |
} |
|
7873 |
} |
|
7874 |
} |
|
7875 |
RETURN (true); |
|
295 | 7876 |
} |
7877 |
%}. |
|
7878 |
^ false |
|
7879 |
! |
|
7880 |
||
1344 | 7881 |
setSelection:anObject owner:aWindowId |
295 | 7882 |
"set the object selection, and make aWindowId be the owner. |
7883 |
This can be used by other Smalltalk(X) applications only." |
|
7884 |
||
7885 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 7886 |
^ false |
295 | 7887 |
]. |
7888 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7889 |
^ true |
|
7890 |
! |
|
7891 |
||
1344 | 7892 |
setSelectionOwner:aWindowId of:selectionID |
295 | 7893 |
"set the owner of a selection; return false if failed" |
7894 |
||
7895 |
%{ /* NOCONTEXT */ |
|
7896 |
Window win; |
|
7897 |
||
7898 |
if (__isExternalAddress(aWindowId) |
|
7899 |
&& __isAtomID(selectionID) |
|
7900 |
&& ISCONNECTED) { |
|
1344 | 7901 |
Display *dpy = myDpy; |
7902 |
||
7903 |
win = _WindowVal(aWindowId); |
|
7904 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7905 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7906 |
RETURN (false); |
|
7907 |
} |
|
7908 |
RETURN (true); |
|
295 | 7909 |
} |
7910 |
%} |
|
7911 |
. |
|
7912 |
self primitiveFailed. |
|
7913 |
^ nil |
|
7914 |
! |
|
7915 |
||
1344 | 7916 |
setTextProperty:propertyID value:aString for:aWindowID |
295 | 7917 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
7918 |
! |
|
7919 |
||
1344 | 7920 |
setTextSelection:aString owner:aWindowId |
295 | 7921 |
"set the text selection, and make aWindowId be the owner. |
7922 |
This can be used by any other X application." |
|
7923 |
||
7924 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 7925 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 7926 |
]. |
7927 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
7928 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
7929 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 7930 |
! ! |
7931 |
||
7932 |
!XWorkstation methodsFor:'window stuff'! |
|
7933 |
||
1344 | 7934 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 7935 |
"clear a rectangular area to viewbackground" |
7936 |
||
7937 |
%{ /* NOCONTEXT */ |
|
7938 |
||
7939 |
int w, h; |
|
7940 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7941 |
if (ISCONNECTED) { |
1344 | 7942 |
if (__isExternalAddress(aWindowId) |
7943 |
&& __bothSmallInteger(x, y) |
|
7944 |
&& __bothSmallInteger(width, height)) { |
|
7945 |
w = __intVal(width); |
|
7946 |
h = __intVal(height); |
|
7947 |
/* |
|
7948 |
* need this check here: some servers simply dump core with bad args |
|
7949 |
*/ |
|
7950 |
if ((w >= 0) && (h >= 0)) { |
|
7951 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
|
7952 |
} |
|
7953 |
RETURN ( self ); |
|
7954 |
} |
|
295 | 7955 |
} |
7956 |
%} |
|
7957 |
. |
|
7958 |
self primitiveFailed |
|
7959 |
! |
|
7960 |
||
1344 | 7961 |
clearWindow:aWindowId |
295 | 7962 |
"clear a window to viewbackground" |
7963 |
||
7964 |
%{ /* NOCONTEXT */ |
|
7965 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7966 |
if (ISCONNECTED) { |
1344 | 7967 |
if (__isExternalAddress(aWindowId)) { |
7968 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7969 |
RETURN ( self ); |
|
7970 |
} |
|
295 | 7971 |
} |
7972 |
%} |
|
7973 |
. |
|
7974 |
self primitiveFailed |
|
7975 |
! |
|
7976 |
||
1344 | 7977 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 7978 |
"configure stacking operation of aWindowId w.r.t siblingId" |
7979 |
||
7980 |
%{ /* NOCONTEXT */ |
|
7981 |
||
7982 |
XWindowChanges chg; |
|
7983 |
int mask = CWSibling | CWStackMode; |
|
7984 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7985 |
if (ISCONNECTED) { |
1344 | 7986 |
if (__isExternalAddress(aWindowId) |
7987 |
&& __isExternalAddress(siblingId)) { |
|
7988 |
if (modeSymbol == @symbol(above)) { |
|
7989 |
chg.stack_mode = Above; |
|
7990 |
} else if (modeSymbol == @symbol(below)) { |
|
7991 |
chg.stack_mode = Below; |
|
7992 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7993 |
chg.stack_mode = TopIf; |
|
7994 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7995 |
chg.stack_mode = BottomIf; |
|
7996 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7997 |
chg.stack_mode = Opposite; |
|
7998 |
} else { |
|
7999 |
mask = CWSibling; |
|
8000 |
} |
|
8001 |
||
8002 |
chg.sibling = _WindowVal(siblingId); |
|
8003 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
8004 |
mask, &chg); |
|
8005 |
RETURN ( self ); |
|
8006 |
} |
|
295 | 8007 |
} |
8008 |
bad: ; |
|
8009 |
%} |
|
8010 |
. |
|
8011 |
self primitiveFailed |
|
8012 |
! |
|
8013 |
||
1344 | 8014 |
lowerWindow:aWindowId |
295 | 8015 |
"bring a window to back" |
8016 |
||
8017 |
%{ /* NOCONTEXT */ |
|
8018 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8019 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8020 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8021 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
8022 |
RETURN ( self ); |
|
295 | 8023 |
} |
8024 |
%} |
|
8025 |
. |
|
8026 |
self primitiveFailed |
|
8027 |
! |
|
8028 |
||
1344 | 8029 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 8030 |
"make a window visible - either as icon or as a real view - needed for restart" |
8031 |
||
8032 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
8033 |
||
8034 |
aBoolean ifTrue:[ |
|
1344 | 8035 |
wicon := aView icon. |
8036 |
wicon notNil ifTrue:[ |
|
8037 |
wiconId := wicon id |
|
8038 |
]. |
|
8039 |
wiconView := aView iconView. |
|
8040 |
wiconView notNil ifTrue:[ |
|
8041 |
wiconViewId := wiconView id |
|
8042 |
]. |
|
8043 |
wlabel := aView label. |
|
295 | 8044 |
]. |
8045 |
%{ |
|
8046 |
||
8047 |
XWMHints wmhints; |
|
8048 |
XSizeHints szhints; |
|
8049 |
Window win; |
|
8050 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8051 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8052 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8053 |
Display *dpy = myDpy; |
8054 |
||
8055 |
win = _WindowVal(aWindowId); |
|
8056 |
||
8057 |
szhints.flags = 0; |
|
8058 |
if (__bothSmallInteger(xPos, yPos)) { |
|
8059 |
szhints.x = __intVal(xPos); |
|
8060 |
szhints.y = __intVal(yPos); |
|
8061 |
szhints.flags |= USPosition; |
|
8062 |
} |
|
8063 |
if (__bothSmallInteger(w, h)) { |
|
8064 |
szhints.width = __intVal(w); |
|
8065 |
szhints.height = __intVal(h); |
|
8066 |
szhints.flags |= USSize; |
|
8067 |
} |
|
8068 |
||
8069 |
if (aBoolean == true) { |
|
8070 |
char *windowName; |
|
8071 |
Pixmap iconBitmap = (Pixmap)0; |
|
8072 |
Window iconWindow; |
|
8073 |
||
8074 |
if (__isExternalAddress(wiconId)) |
|
8075 |
iconBitmap = _PixmapVal(wiconId); |
|
8076 |
else |
|
8077 |
iconBitmap = (Pixmap)0; |
|
8078 |
||
8079 |
if (__isExternalAddress(wiconViewId)) |
|
8080 |
iconWindow = _WindowVal(wiconViewId); |
|
8081 |
else |
|
8082 |
iconWindow = (Window)0; |
|
8083 |
||
8084 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
8085 |
windowName = (char *)_stringVal(wlabel); |
|
8086 |
else |
|
8087 |
windowName = ""; |
|
8088 |
||
8089 |
if (iconBitmap || windowName) { |
|
8090 |
XSetStandardProperties(dpy, win, |
|
8091 |
windowName, windowName, |
|
8092 |
iconBitmap, |
|
8093 |
0, 0, &szhints); |
|
8094 |
} |
|
8095 |
||
8096 |
wmhints.flags = 0; |
|
8097 |
if (iconBitmap) { |
|
8098 |
wmhints.flags |= IconPixmapHint; |
|
8099 |
wmhints.icon_pixmap = iconBitmap; |
|
8100 |
} |
|
8101 |
if (iconWindow) { |
|
8102 |
wmhints.flags |= IconWindowHint; |
|
8103 |
wmhints.icon_window = iconWindow; |
|
8104 |
} |
|
8105 |
||
8106 |
wmhints.initial_state = IconicState; |
|
8107 |
wmhints.flags |= StateHint; |
|
8108 |
XSetWMHints(dpy, win, &wmhints); |
|
8109 |
} |
|
8110 |
||
8111 |
if (szhints.flags) { |
|
8112 |
XSetNormalHints(dpy, win, &szhints); |
|
8113 |
} |
|
8114 |
||
8115 |
XMapWindow(dpy, win); |
|
8116 |
RETURN ( self ); |
|
295 | 8117 |
} |
8118 |
%} |
|
8119 |
. |
|
8120 |
self primitiveFailed |
|
8121 |
! |
|
8122 |
||
1344 | 8123 |
mapWindow:aWindowId |
295 | 8124 |
"make a window visible" |
8125 |
||
8126 |
%{ /* NOCONTEXT */ |
|
8127 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8128 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8129 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8130 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
8131 |
RETURN ( self ); |
|
295 | 8132 |
} |
8133 |
%} |
|
8134 |
. |
|
8135 |
self primitiveFailed |
|
8136 |
! |
|
8137 |
||
1344 | 8138 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 8139 |
"move and resize a window" |
8140 |
||
8141 |
%{ /* NOCONTEXT */ |
|
8142 |
||
8143 |
int newWidth, newHeight; |
|
8144 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8145 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8146 |
&& __isExternalAddress(aWindowId) |
295 | 8147 |
&& __bothSmallInteger(w, h) |
8148 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 8149 |
newWidth = __intVal(w); |
8150 |
newHeight = __intVal(h); |
|
8151 |
if (newWidth < 1) newWidth = 1; |
|
8152 |
if (newHeight < 1) newHeight = 1; |
|
8153 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
8154 |
__intVal(x), __intVal(y), |
|
8155 |
newWidth, newHeight); |
|
8156 |
RETURN ( self ); |
|
295 | 8157 |
} |
8158 |
%} |
|
8159 |
. |
|
8160 |
self primitiveFailed |
|
8161 |
! |
|
8162 |
||
1344 | 8163 |
moveWindow:aWindowId x:x y:y |
295 | 8164 |
"move a window" |
8165 |
||
8166 |
%{ /* NOCONTEXT */ |
|
8167 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8168 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8169 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1344 | 8170 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
8171 |
RETURN ( self ); |
|
295 | 8172 |
} |
8173 |
%} |
|
8174 |
. |
|
8175 |
self primitiveFailed |
|
8176 |
! |
|
8177 |
||
1344 | 8178 |
raiseWindow:aWindowId |
295 | 8179 |
"bring a window to front" |
8180 |
||
8181 |
%{ /* NOCONTEXT */ |
|
8182 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8183 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8184 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8185 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
8186 |
RETURN ( self ); |
|
295 | 8187 |
} |
8188 |
%} |
|
8189 |
. |
|
8190 |
self primitiveFailed |
|
8191 |
! |
|
8192 |
||
1344 | 8193 |
resizeWindow:aWindowId width:w height:h |
295 | 8194 |
"resize a window" |
8195 |
||
8196 |
%{ /* NOCONTEXT */ |
|
8197 |
||
8198 |
int newWidth, newHeight; |
|
8199 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8200 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8201 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 8202 |
newWidth = __intVal(w); |
8203 |
newHeight = __intVal(h); |
|
8204 |
if (newWidth < 1) newWidth = 1; |
|
8205 |
if (newHeight < 1) newHeight = 1; |
|
8206 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
8207 |
RETURN ( self ); |
|
295 | 8208 |
} |
8209 |
%} |
|
8210 |
. |
|
8211 |
self primitiveFailed |
|
8212 |
! |
|
8213 |
||
1344 | 8214 |
setBackingStore:how in:aWindowId |
295 | 8215 |
"turn on/off backing-store for a window" |
8216 |
||
8217 |
%{ /* NOCONTEXT */ |
|
8218 |
||
8219 |
XSetWindowAttributes wa; |
|
8220 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8221 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8222 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8223 |
if (__INST(ignoreBackingStore) != true) { |
8224 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
8225 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
8226 |
else if (how == true) wa.backing_store = Always; |
|
8227 |
else wa.backing_store = 0; |
|
8228 |
BEGIN_INTERRUPTSBLOCKED |
|
8229 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
8230 |
END_INTERRUPTSBLOCKED |
|
8231 |
} |
|
8232 |
RETURN ( self ); |
|
295 | 8233 |
} |
8234 |
%}. |
|
8235 |
self primitiveFailed |
|
8236 |
! |
|
8237 |
||
1344 | 8238 |
setBitGravity:how in:aWindowId |
295 | 8239 |
"set bit gravity for a window" |
8240 |
||
8241 |
%{ /* NOCONTEXT */ |
|
8242 |
||
8243 |
XSetWindowAttributes wa; |
|
8244 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8245 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8246 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8247 |
if (how == @symbol(NorthWest)) { |
8248 |
wa.bit_gravity = NorthWestGravity; |
|
8249 |
} else if (how == @symbol(NorthEast)) { |
|
8250 |
wa.bit_gravity = NorthEastGravity; |
|
8251 |
} else if (how == @symbol(SouthWest)) { |
|
8252 |
wa.bit_gravity = SouthWestGravity; |
|
8253 |
} else if (how == @symbol(SouthEast)) { |
|
8254 |
wa.bit_gravity = SouthEastGravity; |
|
8255 |
} else if (how == @symbol(Center)) { |
|
8256 |
wa.bit_gravity = CenterGravity; |
|
8257 |
} else if (how == @symbol(North)) { |
|
8258 |
wa.bit_gravity = NorthGravity; |
|
8259 |
} else if (how == @symbol(South)) { |
|
8260 |
wa.bit_gravity = SouthGravity; |
|
8261 |
} else if (how == @symbol(West)) { |
|
8262 |
wa.bit_gravity = WestGravity; |
|
8263 |
} else if (how == @symbol(East)) { |
|
8264 |
wa.bit_gravity = EastGravity; |
|
8265 |
} else { |
|
8266 |
wa.bit_gravity = NorthWestGravity; |
|
8267 |
} |
|
8268 |
||
8269 |
BEGIN_INTERRUPTSBLOCKED |
|
8270 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
8271 |
END_INTERRUPTSBLOCKED |
|
8272 |
RETURN ( self ); |
|
295 | 8273 |
} |
8274 |
%}. |
|
8275 |
self primitiveFailed |
|
8276 |
! |
|
8277 |
||
1344 | 8278 |
setCursor:aCursorId in:aWindowId |
295 | 8279 |
"define a windows cursor" |
8280 |
||
8281 |
%{ /* NOCONTEXT */ |
|
8282 |
||
8283 |
Display *dpy = myDpy; |
|
8284 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8285 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8286 |
&& __isExternalAddress(aWindowId) |
295 | 8287 |
&& __isExternalAddress(aCursorId)) { |
1344 | 8288 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
8289 |
RETURN ( self ); |
|
295 | 8290 |
} |
8291 |
%}. |
|
8292 |
self primitiveFailed |
|
8293 |
! |
|
8294 |
||
1344 | 8295 |
setIconName:aString in:aWindowId |
295 | 8296 |
"define a windows iconname" |
8297 |
||
8298 |
%{ /* NOCONTEXT */ |
|
8299 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8300 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8301 |
&& __isExternalAddress(aWindowId) |
295 | 8302 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8303 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8304 |
RETURN ( self ); |
|
295 | 8305 |
} |
8306 |
%}. |
|
8307 |
self primitiveFailed |
|
8308 |
! |
|
8309 |
||
1344 | 8310 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 8311 |
"turn on/off save-under for a window" |
8312 |
||
8313 |
%{ /* NOCONTEXT */ |
|
8314 |
||
8315 |
XSetWindowAttributes wa; |
|
8316 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8317 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8318 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8319 |
if (__INST(hasSaveUnder) == true) { |
8320 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
8321 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
8322 |
} |
|
8323 |
RETURN ( self ); |
|
295 | 8324 |
} |
8325 |
%}. |
|
8326 |
self primitiveFailed |
|
8327 |
! |
|
8328 |
||
1344 | 8329 |
setTransient:aWindowId for:aMainWindowId |
295 | 8330 |
"set aWindowId to be a transient of aMainWindow" |
8331 |
||
8332 |
%{ /* NOCONTEXT */ |
|
8333 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8334 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8335 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8336 |
Window w; |
8337 |
||
8338 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
8339 |
w = (Window) 0; |
|
8340 |
} else { |
|
8341 |
if (__isExternalAddress(aMainWindowId)) { |
|
8342 |
w = _WindowVal(aMainWindowId); |
|
8343 |
} else { |
|
8344 |
goto getOutOfHere; |
|
8345 |
} |
|
8346 |
} |
|
8347 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
|
8348 |
RETURN ( self ); |
|
295 | 8349 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
8350 |
getOutOfHere: ; |
295 | 8351 |
%}. |
8352 |
self primitiveFailed |
|
8353 |
! |
|
8354 |
||
1344 | 8355 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 8356 |
"set the windows background color. This is the color with which |
8357 |
the view is filled whenever exposed. Do not confuse this with |
|
8358 |
the background drawing color, which is used with opaque drawing." |
|
8359 |
||
8360 |
%{ /* NOCONTEXT */ |
|
8361 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8362 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8363 |
&& __isExternalAddress(aWindowId) |
295 | 8364 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8365 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8366 |
RETURN ( self ); |
|
295 | 8367 |
} |
8368 |
%}. |
|
8369 |
self primitiveFailed |
|
8370 |
! |
|
8371 |
||
1344 | 8372 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 8373 |
"set the windows background pattern to be a form. |
8374 |
This is the pattern with which the view is filled whenever exposed. |
|
8375 |
Do not confuse this with the background drawing color, which is used |
|
8376 |
with opaque drawing." |
|
8377 |
||
8378 |
%{ /* NOCONTEXT */ |
|
8379 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8380 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8381 |
&& __isExternalAddress(aWindowId) |
295 | 8382 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8383 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8384 |
RETURN ( self ); |
|
295 | 8385 |
} |
8386 |
%}. |
|
8387 |
self primitiveFailed |
|
8388 |
! |
|
8389 |
||
1344 | 8390 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 8391 |
"set the windows border color" |
8392 |
||
8393 |
%{ /* NOCONTEXT */ |
|
8394 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8395 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8396 |
&& __isExternalAddress(aWindowId) |
295 | 8397 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8398 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8399 |
RETURN ( self ); |
|
295 | 8400 |
} |
8401 |
%}. |
|
8402 |
self primitiveFailed |
|
8403 |
! |
|
8404 |
||
1344 | 8405 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 8406 |
"set the windows border pattern" |
8407 |
||
8408 |
%{ /* NOCONTEXT */ |
|
8409 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8410 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8411 |
&& __isExternalAddress(aWindowId) |
295 | 8412 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8413 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8414 |
RETURN ( self ); |
|
295 | 8415 |
} |
8416 |
%} |
|
8417 |
. |
|
8418 |
self primitiveFailed |
|
8419 |
! |
|
8420 |
||
1344 | 8421 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 8422 |
"set the windows border shape" |
8423 |
||
8424 |
hasShapeExtension ifFalse:[^ self]. |
|
8425 |
||
8426 |
%{ /* NOCONTEXT */ |
|
8427 |
||
8428 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8429 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8430 |
&& __isExternalAddress(aWindowId) |
295 | 8431 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8432 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
8433 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
8434 |
RETURN ( self ); |
|
295 | 8435 |
} |
8436 |
#endif |
|
8437 |
%}. |
|
8438 |
self primitiveFailed |
|
8439 |
! |
|
8440 |
||
1344 | 8441 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 8442 |
"set the windows border width" |
8443 |
||
8444 |
%{ /* NOCONTEXT */ |
|
8445 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8446 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8447 |
&& __isExternalAddress(aWindowId) |
295 | 8448 |
&& __isSmallInteger(aNumber)) { |
1344 | 8449 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
8450 |
RETURN ( self ); |
|
295 | 8451 |
} |
8452 |
%}. |
|
8453 |
self primitiveFailed |
|
8454 |
! |
|
8455 |
||
1344 | 8456 |
setWindowClass:wClass name:wName in:aWindowId |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8457 |
"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
|
8458 |
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
|
8459 |
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
|
8460 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8461 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8462 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8463 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8464 |
XClassHint classhint; |
8465 |
||
8466 |
classhint.res_class = classhint.res_name = 0; |
|
8467 |
||
8468 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
8469 |
classhint.res_class = (char *)_stringVal(wClass); |
|
8470 |
} else if (wClass != nil) |
|
8471 |
goto error; |
|
8472 |
||
8473 |
if (__isString(wName) || __isSymbol(wName)) { |
|
8474 |
classhint.res_name = (char *)_stringVal(wName); |
|
8475 |
} else if (wName != nil) |
|
8476 |
goto error; |
|
8477 |
||
8478 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
|
8479 |
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
|
8480 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8481 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8482 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8483 |
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
|
8484 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8485 |
|
1344 | 8486 |
setWindowGravity:how in:aWindowId |
295 | 8487 |
"set window gravity for a window" |
8488 |
||
8489 |
%{ /* NOCONTEXT */ |
|
8490 |
||
8491 |
XSetWindowAttributes wa; |
|
8492 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8493 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8494 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8495 |
if (how == @symbol(NorthWest)) { |
8496 |
wa.win_gravity = NorthWestGravity; |
|
8497 |
} else if (how == @symbol(NorthEast)) { |
|
8498 |
wa.win_gravity = NorthEastGravity; |
|
8499 |
} else if (how == @symbol(SouthWest)) { |
|
8500 |
wa.win_gravity = SouthWestGravity; |
|
8501 |
} else if (how == @symbol(SouthEast)) { |
|
8502 |
wa.win_gravity = SouthEastGravity; |
|
8503 |
} else if (how == @symbol(Center)) { |
|
8504 |
wa.win_gravity = CenterGravity; |
|
8505 |
} else if (how == @symbol(North)) { |
|
8506 |
wa.win_gravity = NorthGravity; |
|
8507 |
} else if (how == @symbol(South)) { |
|
8508 |
wa.win_gravity = SouthGravity; |
|
8509 |
} else if (how == @symbol(West)) { |
|
8510 |
wa.win_gravity = WestGravity; |
|
8511 |
} else if (how == @symbol(East)) { |
|
8512 |
wa.win_gravity = EastGravity; |
|
8513 |
} else { |
|
8514 |
wa.win_gravity = NorthWestGravity; |
|
8515 |
} |
|
8516 |
||
8517 |
BEGIN_INTERRUPTSBLOCKED |
|
8518 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8519 |
END_INTERRUPTSBLOCKED |
|
8520 |
RETURN ( self ); |
|
295 | 8521 |
} |
8522 |
%}. |
|
8523 |
self primitiveFailed |
|
8524 |
! |
|
8525 |
||
1344 | 8526 |
setWindowIcon:aForm in:aWindowId |
295 | 8527 |
"define a bitmap to be used as icon" |
8528 |
||
8529 |
|iconId| |
|
8530 |
||
8531 |
aForm notNil ifTrue:[ |
|
1344 | 8532 |
iconId := aForm id |
295 | 8533 |
]. |
8534 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8535 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8536 |
&& __isExternalAddress(iconId) |
295 | 8537 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8538 |
XWMHints hints; |
8539 |
||
8540 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8541 |
hints.flags = IconPixmapHint; |
|
8542 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8543 |
RETURN ( self ); |
|
295 | 8544 |
} |
8545 |
%}. |
|
8546 |
self primitiveFailed |
|
8547 |
! |
|
8548 |
||
1376 | 8549 |
setWindowIcon:aForm mask:aMaskForm in:aWindowId |
8550 |
"define a windows icon and iconMask. |
|
8551 |
X does not support iconMasks (does it ?) - |
|
8552 |
therefore, igonre it." |
|
8553 |
||
8554 |
self setWindowIcon:aForm in:aWindowId |
|
8555 |
! |
|
8556 |
||
1344 | 8557 |
setWindowIconWindow:aView in:aWindowId |
295 | 8558 |
"define a window to be used as icon" |
8559 |
||
8560 |
|iconWindowId| |
|
8561 |
||
8562 |
aView notNil ifTrue:[ |
|
1344 | 8563 |
iconWindowId := aView id |
295 | 8564 |
]. |
8565 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8566 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8567 |
&& __isExternalAddress(iconWindowId) |
295 | 8568 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8569 |
XWMHints wmhints; |
8570 |
||
8571 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
8572 |
wmhints.flags = IconWindowHint; |
|
8573 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
8574 |
RETURN ( self ); |
|
295 | 8575 |
} |
8576 |
%}. |
|
8577 |
self primitiveFailed |
|
8578 |
! |
|
8579 |
||
1344 | 8580 |
setWindowName:aString in:aWindowId |
295 | 8581 |
"define a windows name" |
8582 |
||
8583 |
%{ /* NOCONTEXT */ |
|
8584 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8585 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8586 |
&& __isExternalAddress(aWindowId) |
295 | 8587 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8588 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8589 |
RETURN ( self ); |
|
295 | 8590 |
} |
8591 |
%}. |
|
8592 |
self primitiveFailed |
|
8593 |
! |
|
8594 |
||
1344 | 8595 |
setWindowShape:aPixmapId in:aWindowId |
295 | 8596 |
"set the windows shape" |
8597 |
||
8598 |
hasShapeExtension ifFalse:[^ self]. |
|
8599 |
||
8600 |
%{ /* NOCONTEXT */ |
|
8601 |
||
8602 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8603 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8604 |
&& __isExternalAddress(aWindowId) |
295 | 8605 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8606 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
8607 |
0, 0, |
|
8608 |
_PixmapVal(aPixmapId), ShapeSet); |
|
8609 |
RETURN ( self ); |
|
295 | 8610 |
} |
8611 |
#endif |
|
8612 |
%}. |
|
8613 |
self primitiveFailed |
|
8614 |
! |
|
8615 |
||
1344 | 8616 |
unmapWindow:aWindowId |
295 | 8617 |
"make a window invisible" |
8618 |
||
8619 |
%{ /* NOCONTEXT */ |
|
8620 |
||
1214 | 8621 |
if (!ISCONNECTED) { |
1344 | 8622 |
RETURN ( self ); |
1214 | 8623 |
} |
8624 |
||
8625 |
if (__isExternalAddress(aWindowId)) { |
|
1344 | 8626 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
8627 |
RETURN ( self ); |
|
8628 |
} |
|
8629 |
%}. |
|
295 | 8630 |
self primitiveFailed |
8631 |
! ! |
|
8632 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8633 |
!XWorkstation class methodsFor:'documentation'! |
295 | 8634 |
|
8635 |
version |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
8636 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.221 1997-04-02 18:46:45 cg Exp $' |
295 | 8637 |
! ! |
8638 |
XWorkstation initialize! |