author | Claus Gittinger <cg@exept.de> |
Thu, 10 Apr 1997 19:36:06 +0200 | |
changeset 1576 | b75c64bb5849 |
parent 1567 | 71215c933fd9 |
child 1579 | 692c2f62d94e |
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 |
|
1535 | 19 |
lengthAtom wmStateAtom listOfXFonts buttonsPressed eventRootX |
20 |
eventRootY displayName eventTrace dispatchingExpose rgbVisual |
|
21 |
virtualRootId rootId eventBuffer altModifierMask metaModifierMask |
|
1392
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 |
1537 | 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 |
|
1164 |
icon:wicon iconMask:wiconMask |
|
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:[ |
|
1537 | 1173 |
self primitiveFailed. |
1174 |
^ nil |
|
150 | 1175 |
]. |
0 | 1176 |
|
46 | 1177 |
origin notNil ifTrue:[ |
1537 | 1178 |
xpos := origin x. |
1179 |
ypos := origin y. |
|
46 | 1180 |
] ifFalse:[ |
1537 | 1181 |
xpos := ypos := 0. |
0 | 1182 |
]. |
46 | 1183 |
extent notNil ifTrue:[ |
1537 | 1184 |
wwidth := extent x. |
1185 |
wheight := extent y. |
|
46 | 1186 |
] ifFalse:[ |
1537 | 1187 |
wwidth := wheight := 100. |
46 | 1188 |
]. |
1189 |
minExt notNil ifTrue:[ |
|
1537 | 1190 |
minWidth := minExt x. |
1191 |
minHeight := minExt y |
|
0 | 1192 |
]. |
46 | 1193 |
maxExt notNil ifTrue:[ |
1537 | 1194 |
maxWidth := maxExt x. |
1195 |
maxHeight := maxExt y |
|
46 | 1196 |
]. |
1197 |
||
0 | 1198 |
wsuperView notNil ifTrue:[ |
1537 | 1199 |
wsuperViewId := wsuperView id |
0 | 1200 |
]. |
1201 |
wcursor isNil ifTrue:[ |
|
1537 | 1202 |
'XWorkstation [info]: cursor nil - defaulted' infoPrintCR |
0 | 1203 |
] ifFalse:[ |
1537 | 1204 |
wcursorId := wcursor id |
0 | 1205 |
]. |
1206 |
||
1207 |
wicon notNil ifTrue:[ |
|
1537 | 1208 |
wiconId := wicon id. |
1209 |
wiconMask notNil ifTrue:[ |
|
1210 |
wiconMaskId := wiconMask id |
|
1211 |
] |
|
0 | 1212 |
]. |
1213 |
wiconView notNil ifTrue:[ |
|
1537 | 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; |
|
1537 | 1233 |
Pixmap backPixmap = (Pixmap)0, |
1234 |
iconBitmap = (Pixmap)0, |
|
1235 |
iconMask = (Pixmap)0; |
|
0 | 1236 |
int flags = 0, depth, ioClass; |
1237 |
Window iconWindow; |
|
1238 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1239 |
Atom WmQuitAppAtom; |
|
1240 |
Atom atoms[3]; |
|
1241 |
int atomCount = 0, isTopWindow = 0; |
|
1242 |
||
1243 |
sizehints.flags = 0; |
|
1244 |
sizehints.width = 100; |
|
1245 |
sizehints.height = 100; |
|
1246 |
sizehints.x = 0; |
|
1247 |
sizehints.y = 0; |
|
1248 |
||
97 | 1249 |
if (__bothSmallInteger(wwidth, wheight)) { |
1537 | 1250 |
sizehints.flags |= PSize; |
1251 |
sizehints.width = __intVal(wwidth); |
|
1252 |
sizehints.height = __intVal(wheight); |
|
0 | 1253 |
} |
97 | 1254 |
if (__bothSmallInteger(xpos, ypos)) { |
1537 | 1255 |
sizehints.flags |= PPosition; |
1256 |
sizehints.x = __intVal(xpos); |
|
1257 |
sizehints.y = __intVal(ypos); |
|
0 | 1258 |
} |
97 | 1259 |
if (__bothSmallInteger(minWidth, minHeight)) { |
1537 | 1260 |
sizehints.flags |= PMinSize; |
1261 |
sizehints.min_width = __intVal(minWidth); |
|
1262 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1263 |
} |
97 | 1264 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
1537 | 1265 |
sizehints.flags |= PMaxSize; |
1266 |
sizehints.max_width = __intVal(maxWidth); |
|
1267 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1268 |
} |
1269 |
||
37 | 1270 |
bg = WhitePixel(dpy, screen); |
0 | 1271 |
|
97 | 1272 |
if (__isSmallInteger(bWidth)) { |
1537 | 1273 |
bw = __intVal(bWidth); |
46 | 1274 |
} else { |
1537 | 1275 |
bw = 0; |
0 | 1276 |
} |
1277 |
||
72 | 1278 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1279 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1280 |
if (__isExternalAddress(wsuperViewId)) { |
1537 | 1281 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1282 |
} else { |
1537 | 1283 |
parentWindow = RootWindow(dpy, screen); |
1284 |
isTopWindow = 1; |
|
0 | 1285 |
} |
1286 |
||
157 | 1287 |
if (wisPopUpView == true) |
1537 | 1288 |
xswa.override_redirect = 1; |
0 | 1289 |
else |
1537 | 1290 |
xswa.override_redirect = 0; |
0 | 1291 |
|
1292 |
if (winputOnly == true) |
|
1537 | 1293 |
ioClass = InputOnly; |
0 | 1294 |
else |
1537 | 1295 |
ioClass = InputOutput; |
0 | 1296 |
|
97 | 1297 |
if (__isSmallInteger(weventMask)) { |
1537 | 1298 |
xswa.event_mask = __intVal(weventMask); |
0 | 1299 |
} else { |
1537 | 1300 |
xswa.event_mask = 0; |
0 | 1301 |
} |
1302 |
||
1303 |
if (ioClass == InputOnly) { |
|
1537 | 1304 |
bw = 0; |
1305 |
depth = 0; |
|
1306 |
flags |= CWEventMask; |
|
0 | 1307 |
} else { |
1537 | 1308 |
depth = DefaultDepth(dpy,screen); |
1309 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1310 |
||
1311 |
if (backPixmap != (Pixmap)0) { |
|
1312 |
xswa.background_pixmap = backPixmap; |
|
1313 |
flags |= CWBackPixmap; |
|
1314 |
} else { |
|
1315 |
xswa.background_pixel = bg; |
|
1316 |
flags |= CWBackPixel; |
|
1317 |
} |
|
1318 |
xswa.border_pixel = bd; |
|
0 | 1319 |
} |
23 | 1320 |
|
0 | 1321 |
visual.visualid = CopyFromParent; |
150 | 1322 |
if (__isSmallInteger(preferredDepth)) { |
1537 | 1323 |
depth = __intVal(preferredDepth); |
23 | 1324 |
} |
54 | 1325 |
|
1326 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1327 |
if (preferredVisual != nil) { |
1537 | 1328 |
XVisualInfo vi; |
1329 |
int cls; |
|
1330 |
||
1331 |
if (preferredVisual == @symbol(StaticGray)) |
|
1332 |
cls = StaticGray; |
|
1333 |
else if (preferredVisual == @symbol(GrayScale)) |
|
1334 |
cls = GrayScale; |
|
1335 |
else if (preferredVisual == @symbol(StaticColor)) |
|
1336 |
cls = StaticColor; |
|
1337 |
else if (preferredVisual == @symbol(PseudoColor)) |
|
1338 |
cls = PseudoColor; |
|
1339 |
else if (preferredVisual == @symbol(TrueColor)) |
|
1340 |
cls = TrueColor; |
|
1341 |
else if (preferredVisual == @symbol(DirectColor)) |
|
1342 |
cls = DirectColor; |
|
1343 |
else |
|
1344 |
cls = PseudoColor; |
|
1345 |
||
1346 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
|
1347 |
visual.visualid = vi.visualid; |
|
163 | 1348 |
/* |
1537 | 1349 |
printf("visualId=%x\n", vi.visualid); |
163 | 1350 |
*/ |
1537 | 1351 |
} |
23 | 1352 |
} |
0 | 1353 |
|
1354 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
1537 | 1355 |
sizehints.x, sizehints.y, |
1356 |
sizehints.width, sizehints.height, |
|
1357 |
bw, depth, ioClass, &visual, |
|
1358 |
flags, &xswa); |
|
54 | 1359 |
END_INTERRUPTSBLOCKED |
0 | 1360 |
|
1361 |
if (! newWindow) { |
|
1537 | 1362 |
RETURN ( nil ); |
0 | 1363 |
} |
1364 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1365 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1366 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1367 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1368 |
|
54 | 1369 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1370 |
/* |
1371 |
* define its cursor |
|
1372 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1373 |
if (__isExternalAddress(wcursorId)) { |
1537 | 1374 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1375 |
} |
1376 |
||
1377 |
/* |
|
1378 |
* define its icon and name |
|
1379 |
* (only makes sense for topWindows) |
|
1380 |
*/ |
|
1381 |
if (isTopWindow) { |
|
1537 | 1382 |
if (__isExternalAddress(wiconId)) |
1383 |
iconBitmap = _PixmapVal(wiconId); |
|
1384 |
else |
|
1385 |
iconBitmap = (Pixmap)0; |
|
1386 |
||
1387 |
if (__isExternalAddress(wiconMaskId)) |
|
1388 |
iconMask = _PixmapVal(wiconMaskId); |
|
1389 |
else |
|
1390 |
iconMask = (Pixmap)0; |
|
1391 |
||
1392 |
if (__isExternalAddress(wiconViewId)) |
|
1393 |
iconWindow = _WindowVal(wiconViewId); |
|
1394 |
else |
|
1395 |
iconWindow = (Window)0; |
|
1396 |
||
1397 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1398 |
windowName = (char *)_stringVal(wlabel); |
|
1399 |
else |
|
1400 |
windowName = ""; |
|
1401 |
||
1402 |
if (iconBitmap || windowName) { |
|
1403 |
XSetStandardProperties(dpy, newWindow, |
|
1404 |
windowName, windowName, |
|
1405 |
iconBitmap, |
|
1406 |
0, 0, &sizehints); |
|
1407 |
||
1408 |
} |
|
1409 |
||
1410 |
wmhints.flags = 0; |
|
1411 |
if (iconBitmap) { |
|
1412 |
wmhints.flags |= IconPixmapHint; |
|
1413 |
wmhints.icon_pixmap = iconBitmap; |
|
1414 |
} |
|
1415 |
if (iconMask) { |
|
1416 |
wmhints.flags |= IconMaskHint; |
|
1417 |
wmhints.icon_mask = iconMask; |
|
1418 |
} |
|
1419 |
if (iconWindow) { |
|
1420 |
wmhints.flags |= IconWindowHint; |
|
1421 |
wmhints.icon_window = iconWindow; |
|
1422 |
} |
|
0 | 1423 |
/* |
1537 | 1424 |
wmhints.flags |= InputHint; |
1425 |
wmhints.input = True; |
|
0 | 1426 |
*/ |
1537 | 1427 |
XSetWMHints(dpy, newWindow, &wmhints); |
1428 |
||
1429 |
/* |
|
1430 |
* tell window manager to not kill us but send an event instead |
|
1431 |
*/ |
|
1432 |
/* |
|
1433 |
* get atoms first (if not already known) |
|
1434 |
*/ |
|
1435 |
if (__INST(protocolsAtom) == nil) { |
|
1436 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
1437 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
|
0 | 1438 |
#ifdef USE_SAVEYOURSELF_ATOM |
1537 | 1439 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
1440 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
|
0 | 1441 |
#endif |
1442 |
#ifdef USE_QUIT_APP_ATOM |
|
1537 | 1443 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
1444 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
|
0 | 1445 |
#endif |
1537 | 1446 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1447 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
|
1448 |
} else { |
|
0 | 1449 |
#ifdef USE_QUIT_APP_ATOM |
1537 | 1450 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1451 |
#else |
1537 | 1452 |
WmQuitAppAtom = 0; |
0 | 1453 |
#endif |
1537 | 1454 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1455 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1456 |
#ifdef USE_SAVEYOURSELF_ATOM |
1537 | 1457 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1458 |
#else |
1537 | 1459 |
WmSaveYourselfAtom = 0; |
0 | 1460 |
#endif |
1537 | 1461 |
} |
1462 |
||
1463 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1464 |
#ifdef USE_SAVEYOURSELF_ATOM |
1537 | 1465 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1466 |
#endif |
1467 |
#ifdef USE_QUIT_APP_ATOM |
|
1537 | 1468 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1469 |
#endif |
1537 | 1470 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1471 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1472 |
} |
1473 |
||
54 | 1474 |
END_INTERRUPTSBLOCKED |
1475 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1476 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1477 |
%}. |
0 | 1478 |
self addKnownView:aView withId:windowId. |
1479 |
^ windowId |
|
1480 |
! |
|
1481 |
||
1482 |
destroyGC:aGCId |
|
1483 |
||
1484 |
%{ /* NOCONTEXT */ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1485 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1486 |
if (! ISCONNECTED) { |
1344 | 1487 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1488 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1489 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1490 |
if (__isExternalAddress(aGCId)) { |
1344 | 1491 |
GC gc = _GCVal(aGCId); |
1492 |
||
1493 |
if (gc) { |
|
1494 |
BEGIN_INTERRUPTSBLOCKED |
|
1495 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1496 |
#ifdef COUNT_RESOURCES |
1344 | 1497 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1498 |
#endif |
1344 | 1499 |
END_INTERRUPTSBLOCKED |
1500 |
} |
|
1501 |
RETURN ( self ); |
|
0 | 1502 |
} |
118 | 1503 |
%}. |
0 | 1504 |
self primitiveFailed |
1505 |
! |
|
1506 |
||
295 | 1507 |
destroyPixmap:aDrawableId |
0 | 1508 |
|
1509 |
%{ /* NOCONTEXT */ |
|
1510 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1511 |
if (! ISCONNECTED) { |
1344 | 1512 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1513 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1514 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1515 |
if (__isExternalAddress(aDrawableId)) { |
1344 | 1516 |
Pixmap pix = _PixmapVal(aDrawableId); |
1517 |
||
1518 |
if (pix) { |
|
1519 |
BEGIN_INTERRUPTSBLOCKED |
|
1520 |
XFreePixmap(myDpy, pix); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1521 |
#ifdef COUNT_RESOURCES |
1344 | 1522 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1523 |
#endif |
1344 | 1524 |
END_INTERRUPTSBLOCKED |
1525 |
} |
|
1526 |
RETURN ( self ); |
|
0 | 1527 |
} |
118 | 1528 |
%}. |
295 | 1529 |
self primitiveFailed |
1530 |
! |
|
1531 |
||
1532 |
destroyView:aView withId:aWindowId |
|
1533 |
%{ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1534 |
if (! ISCONNECTED) { |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1535 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1536 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1537 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1538 |
if (__isExternalAddress(aWindowId)) { |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1539 |
Window win = _WindowVal(aWindowId); |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1540 |
|
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1541 |
if (win) { |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1542 |
BEGIN_INTERRUPTSBLOCKED |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1543 |
XDestroyWindow(myDpy, win); |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1544 |
#ifdef COUNT_RESOURCES |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1545 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1546 |
#endif |
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1547 |
END_INTERRUPTSBLOCKED |
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1548 |
} |
295 | 1549 |
} |
1550 |
%}. |
|
1480
7fd8dff4cfc3
pass view + id to removeKnownView
Claus Gittinger <cg@exept.de>
parents:
1468
diff
changeset
|
1551 |
self removeKnownView:aView withId:aWindowId |
0 | 1552 |
! |
1553 |
||
1554 |
dpsContextFor:aDrawableId and:aGCId |
|
1555 |
||
1556 |
%{ /* NOCONTEXT */ |
|
1557 |
#ifdef XXDPS |
|
555 | 1558 |
int screen = __intVal(__INST(screen)); |
0 | 1559 |
DPSContext dps; |
1560 |
int height; |
|
1561 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1562 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1563 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1564 |
&& ISCONNECTED) { |
1344 | 1565 |
BEGIN_INTERRUPTSBLOCKED |
1566 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1567 |
_GCVal(aGCId), |
|
1568 |
0, height, 0, colormap, NULL, 0, |
|
1569 |
XDPSDefaultTextBackstop, |
|
1570 |
XDPSDefaultErrorProc, |
|
1571 |
NULL); |
|
1572 |
END_INTERRUPTSBLOCKED |
|
1573 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
|
0 | 1574 |
} |
1575 |
#endif |
|
1576 |
%} |
|
1577 |
. |
|
43 | 1578 |
self primitiveFailed. |
1579 |
^ nil |
|
295 | 1580 |
! |
1581 |
||
1582 |
gcFor:aDrawableId |
|
132 | 1583 |
|
1584 |
%{ /* NOCONTEXT */ |
|
555 | 1585 |
int screen = __intVal(__INST(screen)); |
295 | 1586 |
GC gc; |
1587 |
||
1588 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1344 | 1589 |
BEGIN_INTERRUPTSBLOCKED |
1590 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1591 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1592 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1593 |
#ifdef COUNT_RESOURCES |
1344 | 1594 |
if (gc) |
1595 |
__cnt_gc++; |
|
1089 | 1596 |
#endif |
1597 |
||
1344 | 1598 |
END_INTERRUPTSBLOCKED |
1599 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1600 |
} |
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 |
self primitiveFailed. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1603 |
^ nil |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1604 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1605 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1606 |
gcForBitmap:aDrawableId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1607 |
"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
|
1608 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1609 |
%{ /* NOCONTEXT */ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1610 |
int screen = __intVal(__INST(screen)); |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1611 |
GC gc; |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1612 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1613 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
1344 | 1614 |
BEGIN_INTERRUPTSBLOCKED |
1615 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1616 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1617 |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1618 |
#ifdef COUNT_RESOURCES |
1344 | 1619 |
if (gc) |
1620 |
__cnt_gc++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1621 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1622 |
|
1344 | 1623 |
END_INTERRUPTSBLOCKED |
1624 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1625 |
} |
1626 |
%}. |
|
1627 |
self primitiveFailed. |
|
1628 |
^ nil |
|
295 | 1629 |
! |
1630 |
||
1631 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1632 |
|
1633 |
%{ /* UNLIMITEDSTACK */ |
|
1634 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1635 |
Display *dpy; |
555 | 1636 |
int screen = __intVal(__INST(screen)); |
295 | 1637 |
Pixmap newBitmap; |
1638 |
unsigned int b_width, b_height; |
|
1639 |
REGISTER unsigned char *cp; |
|
1640 |
REGISTER unsigned char *pBits; |
|
1641 |
unsigned char *b_bits, *allocatedBits; |
|
1642 |
int index, row; |
|
1643 |
REGISTER int col; |
|
1644 |
unsigned bits; |
|
1645 |
static char reverseBitTable[256]; |
|
1646 |
static firstCall = 1; |
|
1647 |
int nBytes; |
|
1648 |
unsigned char fastBits[10000]; |
|
1649 |
OBJ num, *op; |
|
1650 |
int bytesPerRow; |
|
1651 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1652 |
if (! ISCONNECTED) { |
1344 | 1653 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1654 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1655 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1656 |
dpy = myDpy; |
295 | 1657 |
if (firstCall) { |
1344 | 1658 |
for (index=0; index < 256; index++) { |
1659 |
reverseBitTable[index] = 0; |
|
1660 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1661 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1662 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1663 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1664 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1665 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1666 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1667 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1668 |
} |
|
1669 |
firstCall = 0; |
|
295 | 1670 |
} |
1671 |
||
1672 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1344 | 1673 |
newBitmap = (Pixmap)0; |
1674 |
b_width = __intVal(w); |
|
1675 |
b_height = __intVal(h); |
|
1676 |
bytesPerRow = (b_width + 7) / 8; |
|
1677 |
nBytes = b_height * bytesPerRow; |
|
1678 |
if (nBytes < sizeof(fastBits)) { |
|
1679 |
cp = b_bits = fastBits; |
|
1680 |
allocatedBits = 0; |
|
1681 |
} else { |
|
1682 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1683 |
if (! cp) goto fail; |
|
1684 |
} |
|
1685 |
||
1686 |
if (__qClass(anArray) == @global(Array)) { |
|
1687 |
index = 1; |
|
1688 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1689 |
for (row = b_height; row; row--) { |
|
1690 |
for (col = bytesPerRow; col; col--) { |
|
1691 |
num = *op++; |
|
1692 |
if (! __isSmallInteger(num)) goto fail; |
|
1693 |
bits = __intVal(num); |
|
1694 |
*cp++ = reverseBitTable[bits]; |
|
1695 |
} |
|
1696 |
} |
|
1697 |
} else { |
|
1698 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1699 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1700 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1701 |
*cp++ = reverseBitTable[*pBits++]; |
|
1702 |
} |
|
1703 |
} else { |
|
1704 |
goto fail; |
|
1705 |
} |
|
1706 |
} |
|
1707 |
||
1708 |
BEGIN_INTERRUPTSBLOCKED |
|
1709 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1710 |
(char *)b_bits, |
|
1711 |
b_width, b_height); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1712 |
#ifdef COUNT_RESOURCES |
1344 | 1713 |
if (newBitmap) |
1714 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1715 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1716 |
|
1344 | 1717 |
END_INTERRUPTSBLOCKED |
295 | 1718 |
fail: ; |
1344 | 1719 |
if (allocatedBits) |
1720 |
free(allocatedBits); |
|
1721 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1722 |
} |
1723 |
%} |
|
295 | 1724 |
! |
1725 |
||
1726 |
realRootWindowFor:aView |
|
1727 |
"the name of this method is historic; |
|
1728 |
- it will vanish" |
|
1729 |
||
1730 |
|id| |
|
1731 |
||
1732 |
id := self realRootWindowId. |
|
1733 |
self addKnownView:aView withId:id. |
|
1734 |
^ id |
|
1735 |
! |
|
1736 |
||
1737 |
realRootWindowId |
|
1738 |
"return the id of the real root window. |
|
1739 |
This may not be the window you see as background, |
|
1740 |
since some window managers install a virtual root window on top |
|
1741 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1742 |
care of any virtual root." |
|
0 | 1743 |
|
1744 |
%{ /* NOCONTEXT */ |
|
1745 |
||
555 | 1746 |
int screen = __intVal(__INST(screen)); |
295 | 1747 |
Window root; |
1748 |
OBJ id; |
|
1749 |
||
555 | 1750 |
if (__INST(rootId) != nil) { |
1344 | 1751 |
RETURN (__INST(rootId)); |
295 | 1752 |
} |
0 | 1753 |
|
150 | 1754 |
if (ISCONNECTED) { |
1344 | 1755 |
root = RootWindow(myDpy, screen); |
1756 |
if (! root) { |
|
1757 |
id = nil; |
|
1758 |
} else { |
|
1759 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
|
1760 |
} |
|
1761 |
RETURN (id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1762 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1763 |
%}. |
295 | 1764 |
self primitiveFailed |
1765 |
! |
|
1766 |
||
1767 |
rootWindowFor:aView |
|
1768 |
|id| |
|
1769 |
||
1770 |
id := self rootWindowId. |
|
1771 |
self addKnownView:aView withId:id. |
|
0 | 1772 |
^ id |
1773 |
! |
|
1774 |
||
295 | 1775 |
rootWindowId |
1776 |
"return the id of the root window. |
|
1777 |
This is the window you see as background, |
|
1778 |
however, it may or may not be the real physical root window, |
|
1779 |
since some window managers install a virtual root window on top |
|
1780 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1781 |
|
0 | 1782 |
%{ /* NOCONTEXT */ |
555 | 1783 |
int screen = __intVal(__INST(screen)); |
295 | 1784 |
Window rootWin, vRootWin; |
1785 |
OBJ id; |
|
1786 |
||
555 | 1787 |
if (__INST(virtualRootId) != nil) { |
1344 | 1788 |
RETURN (__INST(virtualRootId)); |
295 | 1789 |
} |
0 | 1790 |
|
169 | 1791 |
if (ISCONNECTED) { |
1344 | 1792 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
295 | 1793 |
#ifndef IRIS |
1344 | 1794 |
BEGIN_INTERRUPTSBLOCKED |
1795 |
/* |
|
1796 |
* on IRIS, this creates a badwindow error - why ? |
|
1797 |
* children contains a funny window (000034) |
|
1798 |
*/ |
|
1799 |
||
1800 |
/* |
|
1801 |
* care for virtual root windows (tvtwm & friends) |
|
1802 |
*/ |
|
1803 |
{ |
|
1804 |
Atom vRootAtom = None; |
|
1805 |
int i; |
|
1806 |
Window rootReturn, parentReturn; |
|
1807 |
Window* children = (Window *)0; |
|
1808 |
unsigned int numChildren; |
|
1809 |
||
1810 |
if (XQueryTree(myDpy, rootWin, |
|
1811 |
&rootReturn, &parentReturn, |
|
1812 |
&children, &numChildren)) { |
|
1813 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1814 |
if (vRootAtom != None) { |
|
1815 |
for (i=0; i < numChildren; i++) { |
|
1816 |
Atom actual_type; |
|
1817 |
int actual_format; |
|
1818 |
unsigned long nitems, bytesafter; |
|
1819 |
Window* newRoot = (Window*) 0; |
|
1820 |
||
1821 |
if (children[i]) { |
|
1822 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1823 |
0L, 1L, False, XA_WINDOW, |
|
1824 |
&actual_type, &actual_format, |
|
1825 |
&nitems, &bytesafter, |
|
1826 |
(unsigned char**) &newRoot |
|
1827 |
) == Success && newRoot) { |
|
1828 |
vRootWin = *newRoot; |
|
1829 |
XFree(newRoot); /* XXX */ |
|
1830 |
break; |
|
1831 |
} |
|
1832 |
} |
|
1833 |
} |
|
1834 |
} |
|
1835 |
if (children) XFree( children ); |
|
1836 |
} |
|
1837 |
} |
|
1838 |
END_INTERRUPTSBLOCKED |
|
295 | 1839 |
#endif |
1840 |
} |
|
1841 |
||
1842 |
/* cannot happen */ |
|
1843 |
if (! vRootWin) { |
|
1344 | 1844 |
vRootWin = rootWin; |
1845 |
if (! rootWin) { |
|
1846 |
RETURN ( nil ); |
|
1847 |
} |
|
295 | 1848 |
} |
555 | 1849 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1850 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1851 |
RETURN ( id ); |
63 | 1852 |
%} |
0 | 1853 |
! ! |
1854 |
||
1855 |
!XWorkstation methodsFor:'color stuff'! |
|
1856 |
||
295 | 1857 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1858 |
"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
|
1859 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1860 |
|
1861 |
%{ /* NOCONTEXT */ |
|
1862 |
||
555 | 1863 |
int screen = __intVal(__INST(screen)); |
295 | 1864 |
XColor color; |
1865 |
unsigned long dummy; |
|
1866 |
Status ok; |
|
1867 |
||
1209 | 1868 |
if (ISCONNECTED) { |
1344 | 1869 |
Display *dpy = myDpy; |
1870 |
||
1871 |
BEGIN_INTERRUPTSBLOCKED |
|
1872 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1873 |
&dummy, 0, &color.pixel, 1); |
|
1874 |
END_INTERRUPTSBLOCKED |
|
1875 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1876 |
#ifdef COUNT_RESOURCES |
1344 | 1877 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1878 |
#endif |
1344 | 1879 |
RETURN ( __MKSMALLINT(color.pixel) ); |
1880 |
} |
|
0 | 1881 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1882 |
%}. |
43 | 1883 |
^ nil |
0 | 1884 |
! |
1885 |
||
1886 |
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
|
1887 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1888 |
Dont use this method, colornames are mostly X specific" |
1889 |
||
1890 |
%{ /* NOCONTEXT */ |
|
1891 |
||
1892 |
char *colorname; |
|
1893 |
XColor scolor, ecolor; |
|
555 | 1894 |
int screen = __intVal(__INST(screen)); |
850 | 1895 |
int id; |
54 | 1896 |
Status ok; |
0 | 1897 |
|
150 | 1898 |
if (ISCONNECTED) { |
1344 | 1899 |
Display *dpy = myDpy; |
1900 |
||
1901 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1902 |
colorname = (char *)_stringVal(aString); |
|
1903 |
||
1904 |
BEGIN_INTERRUPTSBLOCKED |
|
1905 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1906 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1907 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1908 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1909 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1910 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1911 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1912 |
RETURN ( __MKSMALLINT(id) ); |
|
1913 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1914 |
#endif |
1344 | 1915 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1916 |
} |
|
1917 |
END_INTERRUPTSBLOCKED |
|
1918 |
if (! ok) { |
|
1919 |
RETURN ( nil ); |
|
1920 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1921 |
#ifdef COUNT_RESOURCES |
1344 | 1922 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1923 |
#endif |
1344 | 1924 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1925 |
} |
|
0 | 1926 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1927 |
%}. |
43 | 1928 |
self primitiveFailed. |
1929 |
^ nil |
|
0 | 1930 |
! |
1931 |
||
295 | 1932 |
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
|
1933 |
"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
|
1934 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1935 |
|
1936 |
|r g b| |
|
1937 |
||
1938 |
r := self percentToXColorValue:redVal. |
|
1939 |
g := self percentToXColorValue:greenVal. |
|
1940 |
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
|
1941 |
^ 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
|
1942 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1943 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1944 |
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
|
1945 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1946 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1947 |
Display *dpy; |
295 | 1948 |
XColor ecolor; |
555 | 1949 |
int screen = __intVal(__INST(screen)); |
295 | 1950 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1951 |
int id; |
295 | 1952 |
|
1953 |
if (__bothSmallInteger(r, g) |
|
1954 |
&& __isSmallInteger(b) |
|
1955 |
&& ISCONNECTED) { |
|
1344 | 1956 |
ecolor.red = __intVal(r); |
1957 |
ecolor.green= __intVal(g); |
|
1958 |
ecolor.blue = __intVal(b); |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1959 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1960 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1961 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1962 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1963 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1964 |
RETURN ( __MKSMALLINT(id) ); |
|
1965 |
} |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1966 |
#endif |
1344 | 1967 |
dpy = myDpy; |
1968 |
BEGIN_INTERRUPTSBLOCKED |
|
1969 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1970 |
END_INTERRUPTSBLOCKED |
|
1971 |
if (! ok) { |
|
1972 |
RETURN ( nil ); |
|
1973 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1974 |
#ifdef COUNT_RESOURCES |
1344 | 1975 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1976 |
#endif |
1344 | 1977 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1978 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1979 |
%}. |
295 | 1980 |
self primitiveFailed. |
1981 |
^ nil |
|
1982 |
! |
|
1983 |
||
1984 |
freeColor:colorIndex |
|
1985 |
"free a display color when its no longer needed" |
|
0 | 1986 |
|
1987 |
%{ /* NOCONTEXT */ |
|
1988 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1989 |
Display *dpy; |
295 | 1990 |
unsigned long color; |
555 | 1991 |
int screen = __intVal(__INST(screen)); |
295 | 1992 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1993 |
#ifdef QUICK_TRUE_COLORS |
555 | 1994 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1344 | 1995 |
/* no need to do anything on TrueColor displays ... */ |
1996 |
RETURN (self); |
|
295 | 1997 |
} |
1998 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1999 |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2000 |
if (! ISCONNECTED) { |
1344 | 2001 |
RETURN (self); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2002 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2003 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2004 |
if (__isSmallInteger(colorIndex)) { |
1344 | 2005 |
dpy = myDpy; |
2006 |
color = (long) __intVal(colorIndex); |
|
2007 |
BEGIN_INTERRUPTSBLOCKED |
|
2008 |
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
|
2009 |
#ifdef COUNT_RESOURCES |
1344 | 2010 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2011 |
#endif |
1344 | 2012 |
END_INTERRUPTSBLOCKED |
2013 |
RETURN ( self ); |
|
0 | 2014 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2015 |
%}. |
295 | 2016 |
self primitiveFailed |
2017 |
! |
|
2018 |
||
2019 |
getRGBFrom:index into:aBlock |
|
2020 |
"get rgb components (0..100) of color in map at:index, |
|
2021 |
and evaluate the 3-arg block, aBlock with them" |
|
2022 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2023 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2024 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2025 |
self getScaledRGBFrom:index into:[:r :g :b | |
1344 | 2026 |
val := aBlock |
2027 |
value:(r * 100.0 / 16rFFFF) |
|
2028 |
value:(g * 100.0 / 16rFFFF) |
|
2029 |
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
|
2030 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2031 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2032 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2033 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2034 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2035 |
"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
|
2036 |
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
|
2037 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2038 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2039 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
1430 | 2040 |
r isNil ifTrue:[ |
2041 |
^ nil |
|
2042 |
]. |
|
2043 |
val := aBlock |
|
2044 |
value:(r * 100.0 / 16rFFFF) |
|
2045 |
value:(g * 100.0 / 16rFFFF) |
|
2046 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2047 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2048 |
^ val |
1056 | 2049 |
|
1430 | 2050 |
"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
|
2051 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2052 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2053 |
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
|
2054 |
"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
|
2055 |
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
|
2056 |
|
295 | 2057 |
|r g b| |
2058 |
%{ |
|
555 | 2059 |
int screen = __intVal(__INST(screen)); |
295 | 2060 |
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
|
2061 |
int sr, sg, sb; |
295 | 2062 |
int bits, scale, shift; |
2063 |
||
1209 | 2064 |
if (ISCONNECTED |
2065 |
&& __isSmallInteger(index)) { |
|
1344 | 2066 |
Display *dpy = myDpy; |
2067 |
||
2068 |
color.pixel = __intVal(index); |
|
2069 |
BEGIN_INTERRUPTSBLOCKED |
|
2070 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2071 |
END_INTERRUPTSBLOCKED |
|
2072 |
||
2073 |
/* |
|
2074 |
* have to compensate for an error in X ?, which does not scale |
|
2075 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2076 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2077 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2078 |
*/ |
|
2079 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2080 |
scale = (1<<bits) - 1; |
|
2081 |
shift = 16 - bits; |
|
2082 |
||
2083 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2084 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2085 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2086 |
r = __MKSMALLINT(sr); |
|
2087 |
g = __MKSMALLINT(sg); |
|
2088 |
b = __MKSMALLINT(sb); |
|
295 | 2089 |
} |
2090 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2091 |
^ aBlock value:r value:g value:b |
295 | 2092 |
! |
2093 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2094 |
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
|
2095 |
"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
|
2096 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2097 |
|
2098 |
|r g b| |
|
2099 |
||
2100 |
displayId isNil ifTrue:[ |
|
1430 | 2101 |
self pimitiveFailed. |
2102 |
^ nil |
|
295 | 2103 |
]. |
2104 |
%{ |
|
555 | 2105 |
int screen = __intVal(__INST(screen)); |
295 | 2106 |
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
|
2107 |
int sr, sg, sb; |
295 | 2108 |
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
|
2109 |
int bits, scale, shift; |
295 | 2110 |
|
1209 | 2111 |
if (ISCONNECTED |
2112 |
&& __isString(colorName) || __isSymbol(colorName)) { |
|
1430 | 2113 |
Display *dpy = myDpy; |
1209 | 2114 |
|
1430 | 2115 |
BEGIN_INTERRUPTSBLOCKED |
2116 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2117 |
(char *)_stringVal(colorName), &color)) { |
|
2118 |
/* |
|
2119 |
* have to compensate for an error in X ?, which does not scale |
|
2120 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2121 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2122 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2123 |
*/ |
|
2124 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2125 |
scale = (1<<bits) - 1; |
|
2126 |
shift = 16 - bits; |
|
2127 |
||
2128 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2129 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2130 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2131 |
r = __MKSMALLINT(sr); |
|
2132 |
g = __MKSMALLINT(sg); |
|
2133 |
b = __MKSMALLINT(sb); |
|
2134 |
} |
|
2135 |
END_INTERRUPTSBLOCKED |
|
295 | 2136 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2137 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2138 |
^ aBlock value:r value:g value:b |
295 | 2139 |
! |
2140 |
||
2141 |
listOfAvailableColors |
|
2142 |
"return a list of all available colornames. |
|
2143 |
This should not be used, since colornames are very |
|
2144 |
display-specific (here X-specific)." |
|
2145 |
||
2146 |
|aStream list line index colorName| |
|
2147 |
||
2148 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2149 |
aStream isNil ifTrue:[^ nil]. |
|
2150 |
list := OrderedCollection new. |
|
2151 |
[aStream atEnd] whileFalse:[ |
|
1344 | 2152 |
line := aStream nextLine. |
2153 |
line notNil ifTrue:[ |
|
2154 |
"skip the r/g/b numbers" |
|
2155 |
index := 1. |
|
2156 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2157 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2158 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2159 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2160 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2161 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2162 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2163 |
colorName := line copyFrom:index. |
|
2164 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2165 |
list add:colorName |
|
2166 |
] |
|
2167 |
] |
|
295 | 2168 |
]. |
2169 |
aStream close. |
|
2170 |
^ list sort |
|
1047 | 2171 |
|
2172 |
" |
|
2173 |
Screen current listOfAvailableColors |
|
2174 |
" |
|
2175 |
||
2176 |
"Modified: 11.9.1996 / 15:26:28 / stefan" |
|
295 | 2177 |
! |
2178 |
||
2179 |
percentToXColorValue:aPercentage |
|
2180 |
"given a color-component value in percent (0..100), return the corresponding |
|
2181 |
x-component value (0..65k) as an integer" |
|
2182 |
||
2183 |
%{ /* NOCONTEXT */ |
|
2184 |
||
2185 |
if (__isSmallInteger(aPercentage)) { |
|
1344 | 2186 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2187 |
} |
2188 |
if (__isFloat(aPercentage)) { |
|
1344 | 2189 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2190 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2191 |
%}. |
295 | 2192 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2193 |
! |
2194 |
||
892 | 2195 |
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
|
2196 |
"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
|
2197 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2198 |
|
2199 |
%{ /* NOCONTEXT */ |
|
2200 |
||
2201 |
char *colorname; |
|
2202 |
XColor color; |
|
555 | 2203 |
int screen = __intVal(__INST(screen)); |
0 | 2204 |
int r, g, b; |
2205 |
int ok = 1; |
|
2206 |
||
892 | 2207 |
if (__isSmallInteger(sred)) |
1344 | 2208 |
r = __intVal(sred); |
0 | 2209 |
else ok = 0; |
2210 |
||
892 | 2211 |
if (__isSmallInteger(sgreen)) |
1344 | 2212 |
g = __intVal(sgreen); |
0 | 2213 |
else ok = 0; |
2214 |
||
892 | 2215 |
if (__isSmallInteger(sblue)) |
1344 | 2216 |
b = __intVal(sblue); |
0 | 2217 |
else ok = 0; |
2218 |
||
1209 | 2219 |
if (ISCONNECTED |
2220 |
&& __isSmallInteger(index) && ok) { |
|
1344 | 2221 |
Display *dpy = myDpy; |
2222 |
||
2223 |
color.pixel = __intVal(index); |
|
2224 |
color.red = r; |
|
2225 |
color.green = g; |
|
2226 |
color.blue = b; |
|
2227 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2228 |
||
2229 |
BEGIN_INTERRUPTSBLOCKED |
|
2230 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2231 |
END_INTERRUPTSBLOCKED |
|
2232 |
RETURN ( self ); |
|
0 | 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 |
%}. |
0 | 2235 |
self primitiveFailed |
295 | 2236 |
! ! |
2237 |
||
2238 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2239 |
||
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2240 |
builtInCursorShapes |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2241 |
"return a collection of standard cursor names. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2242 |
Those are built into the XServer and need not be created as |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2243 |
user cursors. |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2244 |
(actually, there are more than those below ...)" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2245 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2246 |
"/ if you add something here, also add to #shapeNumberFromCursor ... |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2247 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2248 |
^ #( |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2249 |
#upLeftArrow "/ XC_top_left_arrow |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2250 |
#upRightHand "/ XC_hand1 |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2251 |
#upDownArrow "/ XC_sb_v_double_arrow |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2252 |
#leftRightArrow "/ XC_sb_h_double_arrow |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2253 |
#upLimitArrow "/ XC_top_side |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2254 |
#downLimitArrow "/ XC_bottom_side |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2255 |
#leftLimitArrow "/ XC_left_side |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2256 |
#rightLimitArrow "/ XC_right_side |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2257 |
#text "/ XC_xterm |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2258 |
#upRightArrow "/ XC_draft_large |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2259 |
#leftHand "/ XC_hand2 |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2260 |
#questionMark "/ XC_question_arrow |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2261 |
#cross "/ XC_X_cursor |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2262 |
#wait "/ XC_watch |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2263 |
#crossHair "/ XC_tcross |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2264 |
#origin "/ XC_ul_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2265 |
#topLeft "/ XC_ul_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2266 |
#corner "/ XC_lr_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2267 |
#bottomRight "/ XC_lr_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2268 |
#topRight "/ XC_ur_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2269 |
#bottomLeft "/ XC_ll_angle |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2270 |
#square "/ XC_dotbox |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2271 |
#fourWay "/ XC_fleur |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2272 |
#crossCursor "/ XC_X_cursor |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2273 |
) |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2274 |
|
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2275 |
"Created: 8.4.1997 / 10:12:30 / cg" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2276 |
"Modified: 8.4.1997 / 10:31:46 / cg" |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2277 |
! |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2278 |
|
295 | 2279 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
2280 |
"change a cursors colors" |
|
2281 |
||
2282 |
|fgR fgG fgB bgR bgG bgB| |
|
2283 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2284 |
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
|
2285 |
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
|
2286 |
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
|
2287 |
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
|
2288 |
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
|
2289 |
bgB := bgColor scaledBlue. |
0 | 2290 |
%{ |
295 | 2291 |
XColor fgcolor, bgcolor; |
2292 |
||
1209 | 2293 |
if (ISCONNECTED |
2294 |
&& __isExternalAddress(aCursorId) |
|
295 | 2295 |
&& __bothSmallInteger(fgG, fgB) |
2296 |
&& __bothSmallInteger(bgR, bgG) |
|
2297 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2298 |
||
1344 | 2299 |
fgcolor.red = __intVal(fgR); |
2300 |
fgcolor.green= __intVal(fgG); |
|
2301 |
fgcolor.blue = __intVal(fgB); |
|
2302 |
bgcolor.red = __intVal(bgR); |
|
2303 |
bgcolor.green= __intVal(bgG); |
|
2304 |
bgcolor.blue = __intVal(bgB); |
|
2305 |
BEGIN_INTERRUPTSBLOCKED |
|
2306 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
2307 |
END_INTERRUPTSBLOCKED |
|
2308 |
RETURN ( self ); |
|
72 | 2309 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2310 |
%}. |
0 | 2311 |
self primitiveFailed |
70 | 2312 |
! |
2313 |
||
295 | 2314 |
createCursorShape:aShape |
974 | 2315 |
"create a cursor given a shape-symbol. This only works |
2316 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2317 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2318 |
|
2319 |
|number id| |
|
2320 |
||
2321 |
displayId isNil ifTrue:[ |
|
1344 | 2322 |
self primitiveFailed. |
2323 |
^ nil |
|
295 | 2324 |
]. |
2325 |
number := self shapeNumberFromSymbol:aShape. |
|
2326 |
%{ |
|
2327 |
Cursor newCursor; |
|
2328 |
||
1209 | 2329 |
if (ISCONNECTED |
2330 |
&& __isSmallInteger(number)) { |
|
1344 | 2331 |
BEGIN_INTERRUPTSBLOCKED |
2332 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2333 |
#ifdef COUNT_RESOURCES |
1344 | 2334 |
if (newCursor) |
2335 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2336 |
#endif |
1344 | 2337 |
END_INTERRUPTSBLOCKED |
2338 |
if (newCursor != (Cursor)0) { |
|
2339 |
id = __MKOBJ(newCursor); |
|
2340 |
} |
|
0 | 2341 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2342 |
%}. |
295 | 2343 |
^ id |
2344 |
! |
|
2345 |
||
974 | 2346 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2347 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2348 |
||
2349 |
|id sourceId maskId| |
|
2350 |
||
2351 |
displayId isNil ifTrue:[ |
|
1344 | 2352 |
self primitiveFailed. |
2353 |
^ nil |
|
295 | 2354 |
]. |
2355 |
sourceId := sourceForm id. |
|
2356 |
maskId := maskForm id. |
|
2357 |
%{ |
|
2358 |
Cursor newCursor; |
|
2359 |
XColor fgColor, bgColor; |
|
2360 |
||
1209 | 2361 |
if (ISCONNECTED |
2362 |
&& __isExternalAddress(sourceId) |
|
295 | 2363 |
&& __isExternalAddress(maskId) |
2364 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2365 |
fgColor.red = 0; /* fg is black */ |
2366 |
fgColor.green = 0; |
|
2367 |
fgColor.blue = 0; |
|
2368 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2369 |
bgColor.green = 0xFFFF; |
|
2370 |
bgColor.blue = 0xFFFF; |
|
2371 |
||
2372 |
BEGIN_INTERRUPTSBLOCKED |
|
2373 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2374 |
_PixmapVal(sourceId), |
|
2375 |
_PixmapVal(maskId), |
|
2376 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2377 |
#ifdef COUNT_RESOURCES |
1344 | 2378 |
if (newCursor) |
2379 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2380 |
#endif |
1344 | 2381 |
END_INTERRUPTSBLOCKED |
2382 |
if (newCursor != (Cursor)0) { |
|
2383 |
id = __MKOBJ(newCursor); |
|
2384 |
} |
|
0 | 2385 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2386 |
%}. |
295 | 2387 |
^ id |
2388 |
! |
|
2389 |
||
2390 |
destroyCursor:aCursorId |
|
974 | 2391 |
"release a cursor - frees any device resources" |
0 | 2392 |
|
2393 |
%{ /* NOCONTEXT */ |
|
2394 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2395 |
if (! ISCONNECTED) { |
1344 | 2396 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2397 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2398 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2399 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2400 |
Cursor curs = _CursorVal(aCursorId); |
2401 |
||
2402 |
if (curs) { |
|
2403 |
BEGIN_INTERRUPTSBLOCKED |
|
2404 |
XFreeCursor(myDpy, curs); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2405 |
#ifdef COUNT_RESOURCES |
1344 | 2406 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2407 |
#endif |
1344 | 2408 |
END_INTERRUPTSBLOCKED |
2409 |
} |
|
2410 |
RETURN ( self ); |
|
0 | 2411 |
} |
974 | 2412 |
%}. |
0 | 2413 |
self primitiveFailed |
295 | 2414 |
! |
2415 |
||
974 | 2416 |
needDeviceFormsForCursor |
2417 |
^ true |
|
2418 |
! |
|
2419 |
||
295 | 2420 |
shapeNumberFromSymbol:shape |
974 | 2421 |
"given a shape-symbol, return the corresponding cursor-number, |
2422 |
or nil if no such standard cursor exists." |
|
295 | 2423 |
|
1563
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2424 |
"/this is pure X-knowlegde - but you may easily add more |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2425 |
"/ if you add something here, also add to #builtInCursorShapes ... |
5a634cfaffad
allow device to specify its builtIn cursors
Claus Gittinger <cg@exept.de>
parents:
1558
diff
changeset
|
2426 |
|
295 | 2427 |
|
2428 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2429 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2430 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2431 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2432 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2433 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2434 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2435 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2436 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2437 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2438 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2439 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2440 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2441 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2442 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2443 |
((shape == #origin) |
|
2444 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2445 |
((shape == #corner) |
|
2446 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2447 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2448 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2449 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2450 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2451 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2452 |
|
2453 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2454 |
^ nil |
0 | 2455 |
! ! |
2456 |
||
1543 | 2457 |
!XWorkstation methodsFor:'drag & drop'! |
2458 |
||
1556 | 2459 |
dndDrop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
2460 |
"drop something in some alien view, using the DND protocol. |
|
2461 |
Returns false, if the drop could not be performed." |
|
2462 |
||
2463 |
|msgType dropColl anyFile anyDir anyText anyOther |
|
2464 |
dropType dropTypeCode strings sz idx val| |
|
2465 |
||
2466 |
(msgType := self atomIDOf:'DndProtocol') notNil ifTrue:[ |
|
2467 |
||
2468 |
"/ DND can drop files, file, dir, links, dirLink and text |
|
2469 |
"/ check for this. |
|
2470 |
||
2471 |
dropObjects isCollection ifFalse:[ |
|
2472 |
dropColl := Array with:dropObjects |
|
2473 |
] ifTrue:[ |
|
2474 |
dropColl := dropObjects |
|
2475 |
]. |
|
2476 |
anyFile := anyDir := anyText := anyOther := false. |
|
2477 |
dropColl do:[:aDropObject | |
|
2478 |
aDropObject isFileObject ifTrue:[ |
|
2479 |
aDropObject theObject isDirectory ifTrue:[ |
|
2480 |
anyDir := true |
|
2481 |
] ifFalse:[ |
|
2482 |
anyFile := true |
|
2483 |
] |
|
2484 |
] ifFalse:[ |
|
2485 |
aDropObject isTextObject ifTrue:[ |
|
2486 |
anyText := true |
|
2487 |
] ifFalse:[ |
|
2488 |
anyOther := true |
|
2489 |
] |
|
2490 |
] |
|
2491 |
]. |
|
2492 |
||
2493 |
anyOther ifTrue:[ |
|
2494 |
"/ DND does not support this ... |
|
2495 |
'XWorkstation [info]: DND can only drop files or text' infoPrintCR. |
|
2496 |
^ false |
|
2497 |
]. |
|
2498 |
anyText ifTrue:[ |
|
2499 |
(anyFile or:[anyDir]) ifTrue:[ |
|
2500 |
"/ DND does not support mixed types |
|
2501 |
'XWorkstation [info]: DND cannot drop both files and text' infoPrintCR. |
|
2502 |
^ false |
|
2503 |
] |
|
2504 |
]. |
|
2505 |
||
2506 |
anyFile ifTrue:[ |
|
2507 |
dropType := #DndFiles. |
|
2508 |
dropColl size == 1 ifTrue:[ |
|
2509 |
dropType := #DndFile |
|
2510 |
] |
|
2511 |
] ifFalse:[ |
|
2512 |
anyDir ifTrue:[ |
|
2513 |
dropType := #DndFiles. |
|
2514 |
dropColl size == 1 ifTrue:[ |
|
2515 |
dropType := #DndDir |
|
2516 |
] |
|
2517 |
] ifFalse:[ |
|
2518 |
anyText ifTrue:[ |
|
2519 |
dropColl size == 1 ifTrue:[ |
|
2520 |
dropType := #DndText |
|
2521 |
] ifFalse:[ |
|
2522 |
"/ can only drop a single text object |
|
2523 |
'XWorkstation [info]: DND can only drop a single text' infoPrintCR. |
|
2524 |
^ false |
|
2525 |
] |
|
2526 |
] ifFalse:[ |
|
2527 |
"/ mhmh ... |
|
2528 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
|
2529 |
^ false |
|
2530 |
] |
|
2531 |
] |
|
2532 |
]. |
|
2533 |
||
2534 |
dropTypeCode := self dndDropTypes indexOf:dropType. |
|
2535 |
dropTypeCode == 0 ifTrue:[ |
|
2536 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
|
2537 |
^ false |
|
2538 |
]. |
|
2539 |
dropTypeCode := dropTypeCode - 1. |
|
2540 |
||
2541 |
||
2542 |
"/ place the selection inTo the DndSelection property |
|
2543 |
"/ of the rootView ... |
|
2544 |
"/ ... need a single string, with 0-terminated parts. |
|
2545 |
||
2546 |
strings := OrderedCollection new. |
|
2547 |
sz := 0. |
|
2548 |
dropColl do:[:anObject | |
|
2549 |
|s| |
|
2550 |
||
2551 |
anObject isFileObject ifTrue:[ |
|
2552 |
s := anObject theObject pathName asString |
|
2553 |
] ifFalse:[ |
|
2554 |
s := anObject theObject asString |
|
2555 |
]. |
|
2556 |
strings add:s. |
|
2557 |
sz := sz + (s size) + 1. |
|
2558 |
]. |
|
2559 |
val := String new:sz. |
|
2560 |
idx := 1. |
|
2561 |
strings do:[:aString | |
|
2562 |
val replaceFrom:idx to:(idx + aString size - 1) with:aString startingAt:1. |
|
2563 |
idx := idx + aString size. |
|
2564 |
val at:idx put:(Character value:0). |
|
2565 |
idx := idx + 1 |
|
2566 |
]. |
|
2567 |
||
2568 |
self |
|
2569 |
setProperty:(self atomIDOf:'DndSelection') |
|
2570 |
type:(stringAtom) |
|
2571 |
value:val |
|
2572 |
for:rootId. |
|
2573 |
||
2574 |
^ self |
|
2575 |
sendClientEvent:msgType |
|
2576 |
format:32 |
|
2577 |
to:destinationId |
|
2578 |
data1:dropTypeCode |
|
2579 |
data2:0 |
|
2580 |
data3:(destinationId) |
|
2581 |
data4:nil |
|
2582 |
data5:nil. |
|
2583 |
]. |
|
2584 |
||
2585 |
^ false |
|
2586 |
||
2587 |
"Created: 6.4.1997 / 13:39:37 / cg" |
|
1558 | 2588 |
"Modified: 6.4.1997 / 14:30:43 / cg" |
1556 | 2589 |
! |
2590 |
||
2591 |
dndDropTypes |
|
2592 |
"return the dropTypes as supported by DND" |
|
2593 |
||
2594 |
^ #( |
|
2595 |
DndUnknown "/ 0 |
|
2596 |
DndRawData "/ 1 |
|
2597 |
DndFile "/ 2 |
|
2598 |
DndFiles "/ 3 |
|
2599 |
DndText "/ 4 |
|
2600 |
DndDir "/ 5 |
|
2601 |
DndLink "/ 6 |
|
2602 |
DndExe "/ 7 |
|
2603 |
) |
|
2604 |
||
2605 |
"Created: 6.4.1997 / 12:57:56 / cg" |
|
2606 |
"Modified: 6.4.1997 / 13:38:52 / cg" |
|
2607 |
! |
|
2608 |
||
1543 | 2609 |
drop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
1556 | 2610 |
"drop something in some alien view. |
2611 |
Returns false, if the drop could not be performed." |
|
2612 |
||
2613 |
"/ |
|
1543 | 2614 |
"/ see, if the display supports the DND protocol ... |
1556 | 2615 |
"/ |
1543 | 2616 |
(self atomIDOf:'DndProtocol') notNil ifTrue:[ |
1556 | 2617 |
^ self |
2618 |
dndDrop:dropObjects |
|
2619 |
inWindowID:destinationId |
|
2620 |
position:destinationPoint |
|
2621 |
rootPosition:rootPoint |
|
1543 | 2622 |
]. |
2623 |
||
1556 | 2624 |
"/ add more drag&drop protocols here. |
2625 |
||
2626 |
^ false |
|
2627 |
||
2628 |
"Modified: 6.4.1997 / 13:40:37 / cg" |
|
1543 | 2629 |
! ! |
2630 |
||
0 | 2631 |
!XWorkstation methodsFor:'drawing'! |
2632 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2633 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2634 |
"do a bit-blt; copy bits from the rectangle defined by |
2635 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2636 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2637 |
argument is not integer." |
|
0 | 2638 |
|
2639 |
%{ /* NOCONTEXT */ |
|
2640 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2641 |
GC gc; |
0 | 2642 |
Drawable source, dest; |
2643 |
||
1209 | 2644 |
if (ISCONNECTED |
2645 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2646 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2647 |
&& __isExternalAddress(destId) |
97 | 2648 |
&& __bothSmallInteger(w, h) |
2649 |
&& __bothSmallInteger(srcX, srcY) |
|
2650 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2651 |
gc = _GCVal(dstGCId); |
2652 |
source = (Drawable) _WindowVal(sourceId); |
|
2653 |
dest = (Drawable) _WindowVal(destId); |
|
2654 |
XCopyArea(myDpy, source, dest, gc, |
|
2655 |
__intVal(srcX), __intVal(srcY), |
|
2656 |
__intVal(w), __intVal(h), |
|
2657 |
__intVal(dstX), __intVal(dstY)); |
|
2658 |
RETURN ( self ); |
|
0 | 2659 |
} |
118 | 2660 |
%}. |
2661 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2662 |
or any non integer coordinate" |
|
2663 |
||
0 | 2664 |
self primitiveFailed |
2665 |
! |
|
2666 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2667 |
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
|
2668 |
"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
|
2669 |
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
|
2670 |
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
|
2671 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2672 |
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
|
2673 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2674 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2675 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2676 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2677 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2678 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2679 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2680 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2681 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2682 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2683 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2684 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2685 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2686 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2687 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2688 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2689 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2690 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2691 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2692 |
XCopyArea(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2693 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2694 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2695 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2696 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2697 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2698 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2699 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2700 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2701 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2702 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2703 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2704 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2705 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2706 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2707 |
"do a bit-blt, but only copy the low-bit plane; |
2708 |
copy bits from the rectangle defined by |
|
2709 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2710 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2711 |
argument is not integer." |
|
0 | 2712 |
|
2713 |
%{ /* NOCONTEXT */ |
|
2714 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2715 |
GC gc; |
0 | 2716 |
Drawable source, dest; |
2717 |
||
1209 | 2718 |
if (ISCONNECTED |
2719 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2720 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2721 |
&& __isExternalAddress(destId) |
97 | 2722 |
&& __bothSmallInteger(w, h) |
2723 |
&& __bothSmallInteger(srcX, srcY) |
|
2724 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2725 |
gc = _GCVal(dstGCId); |
2726 |
source = (Drawable) _WindowVal(sourceId); |
|
2727 |
dest = (Drawable) _WindowVal(destId); |
|
2728 |
XCopyPlane(myDpy, source, dest, gc, |
|
2729 |
__intVal(srcX), __intVal(srcY), |
|
2730 |
__intVal(w), __intVal(h), |
|
2731 |
__intVal(dstX), __intVal(dstY), 1); |
|
2732 |
RETURN ( self ); |
|
0 | 2733 |
} |
118 | 2734 |
%}. |
2735 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2736 |
or any non integer coordinate" |
|
2737 |
||
0 | 2738 |
self primitiveFailed |
2739 |
! |
|
2740 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2741 |
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
|
2742 |
"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
|
2743 |
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
|
2744 |
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
|
2745 |
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
|
2746 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2747 |
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
|
2748 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2749 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2750 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2751 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2752 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2753 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2754 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2755 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2756 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2757 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2758 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2759 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2760 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2761 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2762 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2763 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2764 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2765 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2766 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2767 |
XCopyPlane(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2768 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2769 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2770 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2771 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2772 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2773 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2774 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2775 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2776 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2777 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2778 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2779 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2780 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2781 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2782 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2783 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2784 |
|
2785 |
%{ /* NOCONTEXT */ |
|
2786 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2787 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2788 |
Window win; |
0 | 2789 |
int w, h, angle1, angle2; |
2790 |
double f; |
|
2791 |
||
97 | 2792 |
if (__isSmallInteger(startAngle)) |
1344 | 2793 |
angle1 = __intVal(startAngle) * 64; |
36 | 2794 |
else if (__isFloat(startAngle)) { |
1344 | 2795 |
f = __floatVal(startAngle); |
2796 |
angle1 = f * 64; |
|
0 | 2797 |
} |
97 | 2798 |
if (__isSmallInteger(angle)) |
1344 | 2799 |
angle2 = __intVal(angle) * 64; |
36 | 2800 |
else if (__isFloat(angle)) { |
1344 | 2801 |
f = __floatVal(angle); |
2802 |
angle2 = f * 64; |
|
0 | 2803 |
} |
1209 | 2804 |
if (ISCONNECTED |
2805 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2806 |
&& __isExternalAddress(aDrawableId) |
97 | 2807 |
&& __bothSmallInteger(x, y) |
2808 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2809 |
win = _WindowVal(aDrawableId); |
2810 |
gc = _GCVal(aGCId); |
|
2811 |
w = __intVal(width); |
|
2812 |
h = __intVal(height); |
|
2813 |
/* |
|
2814 |
* need this check here: some servers simply dump core with bad args |
|
2815 |
*/ |
|
2816 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2817 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2818 |
w, h, angle1, angle2); |
|
2819 |
} |
|
2820 |
RETURN ( self ); |
|
0 | 2821 |
} |
73 | 2822 |
%}. |
2823 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2824 |
self primitiveFailed |
2825 |
! |
|
2826 |
||
295 | 2827 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2828 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2829 |
||
2830 |
%{ /* NOCONTEXT */ |
|
2831 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2832 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2833 |
Window win; |
295 | 2834 |
|
1209 | 2835 |
if (ISCONNECTED |
2836 |
&& __isExternalAddress(aGCId) |
|
295 | 2837 |
&& __isExternalAddress(aDrawableId) |
2838 |
&& __bothSmallInteger(x0, y0) |
|
2839 |
&& __bothSmallInteger(x1, y1)) { |
|
1511
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2840 |
gc = _GCVal(aGCId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2841 |
win = _WindowVal(aDrawableId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2842 |
|
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2843 |
if ((x0 == x1) && (y0 == y1)) { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2844 |
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
|
2845 |
} else { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2846 |
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
|
2847 |
__intVal(x1), __intVal(y1)); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2848 |
} |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2849 |
RETURN ( self ); |
295 | 2850 |
} |
2851 |
%}. |
|
2852 |
"badGC, badDrawable or coordinates not integer" |
|
2853 |
self primitiveFailed |
|
2854 |
! |
|
2855 |
||
2856 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2857 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2858 |
||
2859 |
%{ /* NOCONTEXT */ |
|
2860 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2861 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2862 |
Window win; |
295 | 2863 |
|
1209 | 2864 |
if (ISCONNECTED |
2865 |
&& __isExternalAddress(aGCId) |
|
295 | 2866 |
&& __isExternalAddress(aDrawableId) |
2867 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2868 |
gc = _GCVal(aGCId); |
2869 |
win = _WindowVal(aDrawableId); |
|
2870 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
|
2871 |
RETURN ( self ); |
|
295 | 2872 |
} |
2873 |
%}. |
|
2874 |
"badGC, badDrawable or x/y not integer" |
|
2875 |
self primitiveFailed |
|
2876 |
! |
|
2877 |
||
2878 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2879 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2880 |
define the polygon. |
|
2881 |
If any coordinate is not integer, an error is triggered." |
|
2882 |
||
2883 |
|numberOfPoints newPoints| |
|
2884 |
||
2885 |
numberOfPoints := aPolygon size. |
|
2886 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2887 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2888 |
Window win; |
295 | 2889 |
OBJ point, x, y; |
2890 |
int i, num; |
|
2891 |
XPoint *points; |
|
2892 |
XPoint qPoints[100]; |
|
377 | 2893 |
int mustFree = 0; |
295 | 2894 |
|
1209 | 2895 |
if (ISCONNECTED |
2896 |
&& __isExternalAddress(aGCId) |
|
295 | 2897 |
&& __isExternalAddress(aDrawableId) |
2898 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 2899 |
gc = _GCVal(aGCId); |
2900 |
win = _WindowVal(aDrawableId); |
|
2901 |
num = __intVal(numberOfPoints); |
|
2902 |
/* |
|
2903 |
* avoid a (slow) malloc, if the number of points is small |
|
2904 |
*/ |
|
2905 |
if (num > 100) { |
|
2906 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2907 |
if (! points) goto fail; |
|
2908 |
mustFree = 1; |
|
2909 |
} else |
|
2910 |
points = qPoints; |
|
2911 |
||
2912 |
for (i=0; i<num; i++) { |
|
2913 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2914 |
if (! __isPoint(point)) goto fail; |
|
2915 |
x = _point_X(point); |
|
2916 |
y = _point_Y(point); |
|
2917 |
if (! __bothSmallInteger(x, y)) |
|
2918 |
goto fail; |
|
2919 |
points[i].x = __intVal(x); |
|
2920 |
points[i].y = __intVal(y); |
|
2921 |
} |
|
2922 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
2923 |
if (mustFree) |
|
2924 |
free(points); |
|
2925 |
RETURN ( self ); |
|
295 | 2926 |
} |
2927 |
fail: ; |
|
377 | 2928 |
if (mustFree) |
1344 | 2929 |
free(points); |
295 | 2930 |
%}. |
2931 |
"badGC, badDrawable or coordinates not integer" |
|
2932 |
self primitiveFailed |
|
2933 |
! |
|
2934 |
||
2935 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2936 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2937 |
||
2938 |
%{ /* NOCONTEXT */ |
|
2939 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2940 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2941 |
Window win; |
295 | 2942 |
int w, h; |
2943 |
||
1209 | 2944 |
if (ISCONNECTED |
2945 |
&& __isExternalAddress(aGCId) |
|
295 | 2946 |
&& __isExternalAddress(aDrawableId) |
2947 |
&& __bothSmallInteger(x, y) |
|
2948 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2949 |
gc = _GCVal(aGCId); |
2950 |
win = _WindowVal(aDrawableId); |
|
2951 |
w = __intVal(width); |
|
2952 |
h = __intVal(height); |
|
2953 |
/* |
|
2954 |
* need this check here: some servers simply dump core with bad args |
|
2955 |
*/ |
|
2956 |
if ((w >= 0) && (h >= 0)) { |
|
2957 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
|
2958 |
} |
|
2959 |
RETURN ( self ); |
|
295 | 2960 |
} |
2961 |
%}. |
|
2962 |
"badGC, badDrawable or coordinates not integer" |
|
2963 |
self primitiveFailed |
|
2964 |
! |
|
2965 |
||
2966 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2967 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2968 |
foreground and background characters. |
|
2969 |
If the coordinates are not integers, an error is triggered." |
|
2970 |
||
2971 |
%{ /* NOCONTEXT */ |
|
2972 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2973 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2974 |
Window win; |
295 | 2975 |
unsigned char *cp; |
2976 |
OBJ cls; |
|
2977 |
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
|
2978 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2979 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2980 |
int nInstBytes; |
295 | 2981 |
|
1209 | 2982 |
if (ISCONNECTED |
2983 |
&& __isExternalAddress(aGCId) |
|
295 | 2984 |
&& __isExternalAddress(aDrawableId) |
2985 |
&& __isNonNilObject(aString) |
|
2986 |
&& __bothSmallInteger(index1, index2) |
|
2987 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2988 |
gc = _GCVal(aGCId); |
2989 |
win = _WindowVal(aDrawableId); |
|
2990 |
cls = __qClass(aString); |
|
2991 |
||
2992 |
i1 = __intVal(index1) - 1; |
|
2993 |
if (i1 >= 0) { |
|
2994 |
i2 = __intVal(index2) - 1; |
|
2995 |
if (i2 < i1) { |
|
2996 |
RETURN (self); |
|
2997 |
} |
|
2998 |
||
2999 |
cp = _stringVal(aString); |
|
3000 |
l = i2 - i1 + 1; |
|
3001 |
||
3002 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3003 |
n = _stringSize(aString); |
|
3004 |
if (i2 < n) { |
|
3005 |
cp += i1; |
|
3006 |
if (l > 1000) l = 1000; |
|
3007 |
if (opaque == true) |
|
3008 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3009 |
else |
|
3010 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3011 |
RETURN ( self ); |
|
3012 |
} |
|
3013 |
} |
|
3014 |
||
3015 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3016 |
cp += nInstBytes; |
|
3017 |
||
3018 |
if (__isBytes(aString)) { |
|
3019 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3020 |
||
3021 |
if (i2 < n) { |
|
3022 |
cp += i1; |
|
3023 |
if (l > 1000) l = 1000; |
|
3024 |
if (opaque == true) |
|
3025 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3026 |
else |
|
3027 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
3028 |
RETURN ( self ); |
|
3029 |
} |
|
3030 |
} |
|
3031 |
||
3032 |
/* TWOBYTESTRINGS */ |
|
3033 |
if (__isWords(aString)) { |
|
3034 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3035 |
||
3036 |
if (i2 < n) { |
|
3037 |
union { |
|
3038 |
char b[2]; |
|
3039 |
unsigned short s; |
|
3040 |
} u; |
|
3041 |
int i; |
|
3042 |
XChar2b *cp2 = (XChar2b *)0; |
|
3043 |
int mustFree = 0; |
|
3044 |
||
3045 |
cp += (i1 * 2); |
|
3046 |
if (l > 1000) l = 1000; |
|
3047 |
||
3048 |
/* |
|
3049 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3050 |
* X expects them MSB first |
|
3051 |
* convert as required |
|
3052 |
*/ |
|
3053 |
||
3054 |
u.s = 0x1234; |
|
3055 |
if (u.b[0] != 0x12) { |
|
3056 |
if (l <= NLOCALBUFFER) { |
|
3057 |
cp2 = xlatebuffer; |
|
3058 |
} else { |
|
3059 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
3060 |
mustFree = 1; |
|
3061 |
} |
|
3062 |
for (i=0; i<l; i++) { |
|
3063 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3064 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3065 |
} |
|
3066 |
cp = (char *) cp2; |
|
3067 |
} |
|
3068 |
||
3069 |
if (opaque == true) |
|
3070 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3071 |
else |
|
3072 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3073 |
||
3074 |
if (mustFree) { |
|
3075 |
free(cp2); |
|
3076 |
} |
|
3077 |
||
3078 |
RETURN ( self ); |
|
3079 |
} |
|
3080 |
} |
|
3081 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3082 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3083 |
#undef NLOCALBUFFER |
295 | 3084 |
%}. |
3085 |
"x/y not integer, badGC or drawable, or not a string" |
|
3086 |
self primitiveFailed |
|
3087 |
! |
|
3088 |
||
3089 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3090 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
3091 |
foreground and background characters. |
|
3092 |
If the coordinates are not integers, an error is triggered." |
|
3093 |
||
3094 |
%{ /* NOCONTEXT */ |
|
3095 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3096 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3097 |
Window win; |
295 | 3098 |
unsigned char *cp; |
3099 |
int n; |
|
3100 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3101 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3102 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3103 |
int nInstBytes; |
295 | 3104 |
|
1209 | 3105 |
if (ISCONNECTED |
3106 |
&& __isExternalAddress(aGCId) |
|
295 | 3107 |
&& __isExternalAddress(aDrawableId) |
3108 |
&& __isNonNilObject(aString) |
|
3109 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3110 |
gc = _GCVal(aGCId); |
3111 |
win = _WindowVal(aDrawableId); |
|
3112 |
cls = __qClass(aString); |
|
3113 |
||
3114 |
cp = _stringVal(aString); |
|
3115 |
||
3116 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3117 |
n = _stringSize(aString); |
|
3118 |
if (n > 1000) n = 1000; |
|
3119 |
if (opaque == true) |
|
3120 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3121 |
else |
|
3122 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3123 |
RETURN ( self ); |
|
3124 |
} |
|
3125 |
||
3126 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3127 |
cp += nInstBytes; |
|
3128 |
||
3129 |
if (__isBytes(aString)) { |
|
3130 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3131 |
||
3132 |
if (n > 1000) n = 1000; |
|
3133 |
if (opaque == true) |
|
3134 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3135 |
else |
|
3136 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3137 |
RETURN ( self ); |
|
3138 |
} |
|
3139 |
||
3140 |
/* TWOBYTESTRINGS */ |
|
3141 |
if (__isWords(aString)) { |
|
3142 |
union { |
|
3143 |
char b[2]; |
|
3144 |
unsigned short s; |
|
3145 |
} u; |
|
3146 |
int i; |
|
3147 |
XChar2b *cp2; |
|
3148 |
int mustFree = 0; |
|
3149 |
||
3150 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3151 |
if (n > 1000) n = 1000; |
|
3152 |
||
3153 |
/* |
|
3154 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3155 |
* X expects them MSB first |
|
3156 |
* convert as required |
|
3157 |
*/ |
|
3158 |
||
3159 |
u.s = 0x1234; |
|
3160 |
if (u.b[0] != 0x12) { |
|
3161 |
if (n <= NLOCALBUFFER) { |
|
3162 |
cp2 = xlatebuffer; |
|
3163 |
} else { |
|
3164 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
3165 |
mustFree = 1; |
|
3166 |
} |
|
3167 |
||
3168 |
for (i=0; i<n; i++) { |
|
3169 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3170 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3171 |
} |
|
3172 |
cp = (char *) cp2; |
|
3173 |
} |
|
3174 |
||
3175 |
if (opaque == true) |
|
3176 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3177 |
else |
|
3178 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3179 |
||
3180 |
||
3181 |
if (mustFree) { |
|
3182 |
free(cp2); |
|
3183 |
} |
|
3184 |
||
3185 |
RETURN ( self ); |
|
3186 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3187 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3188 |
#undef NLOCALBUFFER |
295 | 3189 |
%}. |
3190 |
"x/y not integer, badGC or drawable, or not a string" |
|
3191 |
self primitiveFailed |
|
3192 |
! |
|
3193 |
||
3194 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3195 |
width:imageWidth height:imageHeight |
3196 |
x:srcx y:srcy |
|
3197 |
into:aDrawableId |
|
3198 |
x:dstx y:dsty |
|
3199 |
width:w height:h |
|
3200 |
with:aGCId |
|
295 | 3201 |
|
3202 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3203 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3204 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3205 |
depth and pixel-units to be different. |
|
3206 |
It has to be checked elsewhere, that the server can do it with the given |
|
3207 |
depth - otherwise, primitive failure will be signalled. |
|
3208 |
Also it is assumed, that the colormap is setup correctly and the |
|
3209 |
colors are allocated - otherwise the colors may be wrong." |
|
3210 |
||
3211 |
" |
|
3212 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3213 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3214 |
" |
|
3215 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3216 |
width:imageWidth height:imageHeight |
3217 |
x:srcx y:srcy |
|
3218 |
into:aDrawableId |
|
3219 |
x:dstx y:dsty |
|
3220 |
width:w height:h |
|
3221 |
with:aGCId) |
|
295 | 3222 |
ifFalse:[ |
1344 | 3223 |
" |
3224 |
also happens, if a segmentation violation occurs in the |
|
3225 |
XPutImage ... |
|
3226 |
" |
|
3227 |
self primitiveFailed |
|
295 | 3228 |
]. |
3229 |
! |
|
3230 |
||
3231 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3232 |
width:imageWidth height:imageHeight |
3233 |
x:srcx y:srcy |
|
3234 |
into:aDrawableId |
|
3235 |
x:dstx y:dsty |
|
3236 |
width:w height:h |
|
3237 |
with:aGCId |
|
295 | 3238 |
|
3239 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3240 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3241 |
Individual source pixels must have imageDepth bits. |
|
3242 |
It has to be checked elsewhere, that the server can do it with the given |
|
3243 |
depth - otherwise, primitive failure will be signalled. |
|
3244 |
Also it is assumed, that the colormap is setup correctly and the |
|
3245 |
colors are allocated - otherwise the colors may be wrong." |
|
3246 |
||
3247 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3248 |
width:imageWidth height:imageHeight |
3249 |
x:srcx y:srcy |
|
3250 |
into:aDrawableId |
|
3251 |
x:dstx y:dsty |
|
3252 |
width:w height:h |
|
3253 |
with:aGCId |
|
295 | 3254 |
|
3255 |
! |
|
3256 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3257 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3258 |
in:aDrawableId with:aGCId |
90 | 3259 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3260 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3261 |
|
3262 |
%{ /* NOCONTEXT */ |
|
3263 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3264 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3265 |
Window win; |
0 | 3266 |
int w, h, angle1, angle2; |
3267 |
double f; |
|
3268 |
||
97 | 3269 |
if (__isSmallInteger(startAngle)) |
1344 | 3270 |
angle1 = __intVal(startAngle) * 64; |
36 | 3271 |
else if (__isFloat(startAngle)) { |
1344 | 3272 |
f = __floatVal(startAngle); |
3273 |
angle1 = f * 64; |
|
0 | 3274 |
} |
97 | 3275 |
if (__isSmallInteger(angle)) |
1344 | 3276 |
angle2 = __intVal(angle) * 64; |
36 | 3277 |
else if (__isFloat(angle)) { |
1344 | 3278 |
f = __floatVal(angle); |
3279 |
angle2 = f * 64; |
|
0 | 3280 |
} |
1209 | 3281 |
if (ISCONNECTED |
3282 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3283 |
&& __isExternalAddress(aDrawableId) |
97 | 3284 |
&& __bothSmallInteger(x, y) |
3285 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3286 |
gc = _GCVal(aGCId); |
3287 |
win = _WindowVal(aDrawableId); |
|
3288 |
w = __intVal(width); |
|
3289 |
h = __intVal(height); |
|
3290 |
/* |
|
3291 |
* need this check here: some servers simply dump core with bad args |
|
3292 |
*/ |
|
3293 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
3294 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
3295 |
w, h, angle1, angle2); |
|
3296 |
} |
|
3297 |
RETURN ( self ); |
|
0 | 3298 |
} |
73 | 3299 |
%}. |
3300 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3301 |
self primitiveFailed |
3302 |
! |
|
3303 |
||
3304 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3305 |
"fill a polygon given by its points. |
3306 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3307 |
|
3308 |
|numberOfPoints| |
|
0 | 3309 |
|
3310 |
numberOfPoints := aPolygon size. |
|
3311 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3312 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3313 |
Window win; |
73 | 3314 |
OBJ point, x, y; |
3315 |
int i, num; |
|
3316 |
XPoint *points; |
|
3317 |
XPoint qPoints[100]; |
|
377 | 3318 |
int mustFree = 0; |
73 | 3319 |
|
1209 | 3320 |
if (ISCONNECTED |
3321 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3322 |
&& __isExternalAddress(aDrawableId) |
97 | 3323 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3324 |
gc = _GCVal(aGCId); |
3325 |
win = _WindowVal(aDrawableId); |
|
3326 |
num = __intVal(numberOfPoints); |
|
3327 |
if (num < 3) { |
|
3328 |
RETURN ( self ); |
|
3329 |
} |
|
3330 |
/* |
|
3331 |
* avoid (slow) malloc, if not many points |
|
3332 |
*/ |
|
3333 |
if (num > 100) { |
|
3334 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3335 |
if (! points) goto fail; |
|
3336 |
mustFree = 1; |
|
3337 |
} else |
|
3338 |
points = qPoints; |
|
3339 |
for (i=0; i<num; i++) { |
|
3340 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3341 |
if (! __isPoint(point)) goto fail; |
|
3342 |
x = _point_X(point); |
|
3343 |
y = _point_Y(point); |
|
3344 |
if (! __bothSmallInteger(x, y)) |
|
3345 |
goto fail; |
|
3346 |
points[i].x = __intVal(x); |
|
3347 |
points[i].y = __intVal(y); |
|
3348 |
} |
|
3349 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
3350 |
if (mustFree) |
|
3351 |
free(points); |
|
3352 |
RETURN ( self ); |
|
377 | 3353 |
|
0 | 3354 |
fail: ; |
1344 | 3355 |
if (mustFree) |
3356 |
free(points); |
|
0 | 3357 |
} |
73 | 3358 |
%}. |
3359 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3360 |
self primitiveFailed |
3361 |
! |
|
3362 |
||
295 | 3363 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3364 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3365 |
||
3366 |
%{ /* NOCONTEXT */ |
|
3367 |
||
3368 |
int w, h; |
|
3369 |
||
1209 | 3370 |
if (ISCONNECTED |
3371 |
&& __isExternalAddress(aGCId) |
|
295 | 3372 |
&& __isExternalAddress(aDrawableId) |
3373 |
&& __bothSmallInteger(x, y) |
|
3374 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3375 |
w = __intVal(width); |
3376 |
h = __intVal(height); |
|
3377 |
/* |
|
3378 |
* need this check here: some servers simply dump core with bad args |
|
3379 |
*/ |
|
3380 |
if ((w >= 0) && (h >= 0)) { |
|
3381 |
XFillRectangle(myDpy, |
|
3382 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3383 |
__intVal(x), __intVal(y), w, h); |
|
3384 |
} |
|
3385 |
RETURN ( self ); |
|
295 | 3386 |
} |
3387 |
%}. |
|
3388 |
"badGC, badDrawable or coordinates not integer" |
|
3389 |
self primitiveFailed |
|
43 | 3390 |
! |
3391 |
||
3392 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3393 |
width:imageWidth height:imageHeight |
3394 |
x:srcx y:srcy |
|
3395 |
into:aDrawableId |
|
3396 |
x:dstx y:dsty |
|
3397 |
width:w height:h |
|
3398 |
with:aGCId |
|
0 | 3399 |
|
132 | 3400 |
"since XPutImage may allocate huge amount of stack space |
3401 |
(some implementations use alloca), this must run with unlimited stack." |
|
3402 |
||
12 | 3403 |
%{ /* UNLIMITEDSTACK */ |
0 | 3404 |
|
43 | 3405 |
/* |
3406 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3407 |
* XPutImage |
|
3408 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3409 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3410 |
Window win; |
43 | 3411 |
XImage image; |
377 | 3412 |
int imgWdth; |
43 | 3413 |
|
1209 | 3414 |
if (ISCONNECTED |
3415 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3416 |
&& __isExternalAddress(aDrawableId) |
97 | 3417 |
&& __bothSmallInteger(srcx, srcy) |
3418 |
&& __bothSmallInteger(dstx, dsty) |
|
3419 |
&& __bothSmallInteger(w, h) |
|
3420 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3421 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3422 |
&& __isByteArray(imageBits)) { |
1344 | 3423 |
Display *dpy = myDpy; |
3424 |
||
3425 |
gc = _GCVal(aGCId); |
|
3426 |
win = _WindowVal(aDrawableId); |
|
3427 |
if (! gc || !win) |
|
3428 |
goto fail; |
|
46 | 3429 |
#ifdef ARGDEBUG |
1344 | 3430 |
printf("args ok\n"); |
46 | 3431 |
#endif |
1344 | 3432 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3433 |
image.width = imgWdth = __intVal(imageWidth); |
|
3434 |
image.height = __intVal(imageHeight); |
|
3435 |
image.xoffset = 0; |
|
3436 |
image.format = ZPixmap; |
|
3437 |
image.byte_order = MSBFirst; |
|
3438 |
image.bitmap_unit = 8; |
|
3439 |
image.bitmap_bit_order = MSBFirst; |
|
3440 |
image.bitmap_pad = 8; |
|
3441 |
image.depth = __intVal(imageDepth); |
|
3442 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3443 |
switch (image.bits_per_pixel) { |
|
3444 |
case 1: |
|
3445 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3446 |
break; |
|
3447 |
case 2: |
|
3448 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3449 |
break; |
|
3450 |
case 4: |
|
3451 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3452 |
break; |
|
3453 |
case 8: |
|
3454 |
image.bytes_per_line = imgWdth; |
|
3455 |
break; |
|
3456 |
case 16: |
|
3457 |
image.bytes_per_line = imgWdth*2; |
|
3458 |
break; |
|
3459 |
case 24: |
|
3460 |
image.bytes_per_line = imgWdth*3; |
|
3461 |
break; |
|
3462 |
case 32: |
|
3463 |
image.bytes_per_line = imgWdth*4; |
|
3464 |
break; |
|
3465 |
default: |
|
46 | 3466 |
#ifdef ARGDEBUG |
1344 | 3467 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3468 |
#endif |
1344 | 3469 |
goto fail; |
3470 |
} |
|
3471 |
image.red_mask = 0xFFFF; |
|
3472 |
image.green_mask = 0xFFFF; |
|
3473 |
image.blue_mask = 0xFFFF; |
|
3474 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
|
3475 |
__intVal(dstx), __intVal(dsty), |
|
3476 |
__intVal(w), __intVal(h)); |
|
3477 |
RETURN ( true ); |
|
43 | 3478 |
} |
46 | 3479 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3480 |
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
|
3481 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3482 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3483 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3484 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3485 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3486 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3487 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3488 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3489 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3490 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3491 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3492 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3493 |
#endif |
3494 |
||
0 | 3495 |
fail: ; |
3496 |
%} |
|
3497 |
. |
|
12 | 3498 |
^ false |
0 | 3499 |
! ! |
3500 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3501 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3502 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3503 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3504 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3505 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3506 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3507 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3508 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3509 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3510 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3511 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3512 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3513 |
|
1540 | 3514 |
clientMessage:event dataOffset:offs view:targetView |
3515 |
self halt. |
|
3516 |
||
3517 |
"Created: 4.4.1997 / 17:23:12 / cg" |
|
3518 |
! |
|
3519 |
||
1543 | 3520 |
clientMessage:event type:type format:format dataOffset:offs view:targetView |
3521 |
|sensor data| |
|
3522 |
||
3523 |
data := event copyFrom:offs + 1. |
|
3524 |
||
3525 |
"/ DND drag&drop protocol |
|
3526 |
type == (self atomIDOf:'DndProtocol') ifTrue:[ |
|
3527 |
format == 32 ifTrue:[ |
|
3528 |
self dndMessage:event data:data view:targetView. |
|
3529 |
^ self |
|
3530 |
] |
|
3531 |
]. |
|
3532 |
||
3533 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
3534 |
sensor clientMessage:type format:format eventData:data view:targetView |
|
3535 |
] ifFalse:[ |
|
3536 |
" |
|
3537 |
not posted, if there is no sensor ... |
|
3538 |
" |
|
3539 |
] |
|
3540 |
||
3541 |
"Created: 4.4.1997 / 17:49:26 / cg" |
|
3542 |
"Modified: 4.4.1997 / 18:00:18 / cg" |
|
3543 |
! |
|
3544 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3545 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3546 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3547 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3548 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3549 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3550 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3551 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3552 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3553 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3554 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3555 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3556 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3557 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3558 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3559 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3560 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3561 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3562 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3563 |
|
1543 | 3564 |
dndMessage:event data:data view:targetView |
3565 |
"handle a DND drag&drop protocol message" |
|
3566 |
||
1553 | 3567 |
|sensor dropType dropValue names i1 i2 t| |
1543 | 3568 |
|
3569 |
dropType := data doubleWordAt:1. |
|
3570 |
||
3571 |
"/ see def's in DragAndDropTypes.h |
|
1556 | 3572 |
dropType := (self dndDropTypes) at:dropType+1 ifAbsent:#DndNotDnd. |
1543 | 3573 |
|
3574 |
self |
|
3575 |
getProperty:(self atomIDOf:'DndSelection') |
|
3576 |
from:rootId |
|
3577 |
into:[:type :value | |
|
1552 | 3578 |
t := type. |
1543 | 3579 |
dropValue := value |
3580 |
]. |
|
3581 |
||
1558 | 3582 |
"/ preconvert into a collection |
3583 |
"/ of fileNames, string or byteArray |
|
3584 |
"/ Notice: we do not yet convert into dropObjects |
|
3585 |
"/ here, to allow arbitrary data to be handled by |
|
3586 |
"/ redefined dropMessage methods in applications. |
|
3587 |
"/ Conversion is done for some well known types |
|
3588 |
"/ in the default dropMessage handling of SimpleView. |
|
3589 |
||
1543 | 3590 |
dropType == #DndFiles ifTrue:[ |
3591 |
"/ actually, a list of fileNames |
|
1558 | 3592 |
t ~~ stringAtom ifTrue:[ |
1554 | 3593 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
3594 |
^ self |
|
3595 |
]. |
|
3596 |
||
1543 | 3597 |
names := OrderedCollection new. |
3598 |
i1 := 1. |
|
3599 |
[i1 ~~ 0] whileTrue:[ |
|
3600 |
i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
|
3601 |
i2 ~~ 0 ifTrue:[ |
|
1552 | 3602 |
names add:(dropValue copyFrom:i1 to:(i2-1)). |
1543 | 3603 |
i1 := i2 + 1. |
3604 |
] ifFalse:[ |
|
3605 |
i1 := i2 |
|
3606 |
]. |
|
3607 |
]. |
|
3608 |
dropValue := names. |
|
1553 | 3609 |
dropValue := dropValue collect:[:nm | nm asFilename]. |
1554 | 3610 |
dropType := #files. |
1558 | 3611 |
] ifFalse:[ (dropType == #DndFile) ifTrue:[ |
3612 |
t ~~ stringAtom ifTrue:[ |
|
3613 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3614 |
^ self |
|
3615 |
]. |
|
3616 |
||
3617 |
dropValue := dropValue asFilename. |
|
3618 |
dropType := #file. |
|
3619 |
] ifFalse:[ (dropType == #DndDir) ifTrue:[ |
|
3620 |
t ~~ stringAtom ifTrue:[ |
|
3621 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3622 |
^ self |
|
3623 |
]. |
|
3624 |
||
3625 |
dropValue := dropValue asFilename. |
|
3626 |
dropType := #directory. |
|
3627 |
] ifFalse:[ (dropType == #DndText) ifTrue:[ |
|
3628 |
t ~~ stringAtom ifTrue:[ |
|
3629 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3630 |
^ self |
|
3631 |
]. |
|
3632 |
||
3633 |
dropValue := dropValue. |
|
3634 |
dropType := #text. |
|
3635 |
] ifFalse:[ (dropType == #DndExe) ifTrue:[ |
|
3636 |
t ~~ stringAtom ifTrue:[ |
|
3637 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3638 |
^ self |
|
3639 |
]. |
|
3640 |
||
3641 |
dropValue := dropValue. |
|
3642 |
dropType := #executable. |
|
3643 |
] ifFalse:[ (dropType == #DndLink) ifTrue:[ |
|
3644 |
t ~~ stringAtom ifTrue:[ |
|
3645 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3646 |
^ self |
|
3647 |
]. |
|
3648 |
||
3649 |
dropValue := dropValue. |
|
3650 |
dropType := #link. |
|
3651 |
] ifFalse:[ (dropType == #DndRawData) ifTrue:[ |
|
3652 |
dropValue := dropValue. |
|
3653 |
dropType := #rawData. |
|
1552 | 3654 |
] ifFalse:[ |
1558 | 3655 |
'XWorkstation [info]: unsupported dropType: ' infoPrint. dropType infoPrintCR. |
3656 |
'XWorkstation [info]: data: ' infoPrint. dropValue infoPrintCR. |
|
3657 |
||
3658 |
dropValue := dropValue. |
|
3659 |
dropType := #unknown. |
|
3660 |
]]]]]]]. |
|
1543 | 3661 |
|
3662 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
3663 |
sensor dropMessage:dropType data:dropValue view:targetView |
|
3664 |
] ifFalse:[ |
|
3665 |
" |
|
3666 |
not posted, if there is no sensor ... |
|
3667 |
" |
|
3668 |
] |
|
3669 |
||
3670 |
"Created: 4.4.1997 / 17:59:37 / cg" |
|
1558 | 3671 |
"Modified: 6.4.1997 / 14:50:44 / cg" |
1543 | 3672 |
! |
3673 |
||
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3674 |
gravityNotifyView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3675 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3676 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3677 |
"/ aView gravityNotify |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3678 |
! |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3679 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3680 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3681 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3682 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3683 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3684 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3685 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3686 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3687 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3688 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3689 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3690 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3691 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3692 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3693 |
reparentedView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3694 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3695 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3696 |
"/ aView reparented |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3697 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3698 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3699 |
resizeRequestView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3700 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3701 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3702 |
"/ aView resizeRequest |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3703 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3704 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3705 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3706 |
"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
|
3707 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3708 |
|
1344 | 3709 |
"/ |
3710 |
"/ workaround a bug in olvwm: it clears selections |
|
3711 |
"/ on window raise. |
|
3712 |
"/ In this case, keep my last own selection. |
|
3713 |
"/ |
|
3714 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3715 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3716 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3717 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3718 |
"/ noone is interrested in that ... |
1344 | 3719 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3720 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3721 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3722 |
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
|
3723 |
"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
|
3724 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3725 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3726 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3727 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3728 |
propertyID == 0 ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3729 |
"invalid olvwm behavior" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3730 |
s := self getLastCopyBuffer |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3731 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3732 |
targetID == self atomIDOfSTRING ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3733 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3734 |
a returned string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3735 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3736 |
s := self getTextProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3737 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3738 |
(s endsWith:Character cr) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3739 |
s := s asStringCollection copyWith:'' |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3740 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3741 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3742 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3743 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3744 |
a returned object |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3745 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3746 |
s := self getObjectProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3747 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3748 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3749 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3750 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3751 |
(sensor := aView sensor) notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3752 |
sensor pasteFromClipBoard:s view:aView |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3753 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3754 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3755 |
if there is no sensor ... |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3756 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3757 |
aView pasteFromClipBoard:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3758 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3759 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3760 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3761 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3762 |
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
|
3763 |
"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
|
3764 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3765 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3766 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3767 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3768 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3769 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3770 |
"/ 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
|
3771 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3772 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3773 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3774 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3775 |
setLengthProperty:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3776 |
value:s size |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3777 |
for:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3778 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3779 |
sendSelectionNotifySelection:selectionID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3780 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3781 |
target:targetID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3782 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3783 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3784 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3785 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3786 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3787 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3788 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3789 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3790 |
"/ the other view wants the selection as string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3791 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3792 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3793 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3794 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3795 |
sendSelection:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3796 |
property:propertyID |
1345 | 3797 |
target:targetID |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3798 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3799 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3800 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3801 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3802 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3803 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3804 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3805 |
"/ (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
|
3806 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3807 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3808 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3809 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3810 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3811 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3812 |
sendSelection:(stream contents) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3813 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3814 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3815 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3816 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3817 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3818 |
|
86 | 3819 |
!XWorkstation methodsFor:'event handling'! |
0 | 3820 |
|
3821 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3822 |
"central event handling method: |
|
54 | 3823 |
get next event and send appropriate message to the sensor or view. |
0 | 3824 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3825 |
otherwise only events for the view with given id are processed. |
3826 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3827 |
handled." |
|
3828 |
||
54 | 3829 |
(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
|
3830 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3831 |
ex return |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3832 |
] do:[ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3833 |
self dispatchLastEvent. |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3834 |
] |
54 | 3835 |
]. |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3836 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3837 |
"Modified: 26.3.1997 / 19:00:41 / cg" |
12 | 3838 |
! |
3839 |
||
295 | 3840 |
dispatchExposeEventFor:aViewIdOrNil |
3841 |
"get next expose event and send appropriate message to the sensor or view. |
|
3842 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3843 |
otherwise only events for the view with given id are processed." |
|
3844 |
||
3845 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3846 |
! |
3847 |
||
3848 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3849 |
|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
|
3850 |
eventType| |
12 | 3851 |
|
3852 |
%{ /* STACK: 8000 */ |
|
3853 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3854 |
|
1209 | 3855 |
Display *dpy; |
135 | 3856 |
OBJ eB; |
3857 |
XEvent *ev; |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3858 |
int ev_x, ev_y; |
135 | 3859 |
|
3860 |
# define ae ((XAnyEvent *)ev) |
|
3861 |
# define ee ((XExposeEvent *)ev) |
|
3862 |
# define ke ((XKeyPressedEvent *)ev) |
|
3863 |
# define be ((XButtonPressedEvent *)ev) |
|
3864 |
# define ce ((XConfigureEvent *)ev) |
|
3865 |
# define me ((XMotionEvent *)ev) |
|
3866 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3867 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3868 |
# define de ((XDestroyWindowEvent *)ev) |
|
3869 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3870 |
# define mape ((XMappingEvent *)ev) |
135 | 3871 |
|
0 | 3872 |
KeySym keySym; |
3873 |
unsigned char buffer[10]; |
|
3874 |
int i, nchars; |
|
3875 |
char *keySymString; |
|
3876 |
char keySymStringBuffer[32]; |
|
3877 |
unsigned nextMultiClickTime; |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3878 |
OBJ upDown, t; |
115 | 3879 |
|
3880 |
struct inlineCache *ipS; |
|
0 | 3881 |
static struct inlineCache vid = _ILC1; |
12 | 3882 |
|
3883 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
3884 |
static struct inlineCache gexpS = _ILC6; |
12 | 3885 |
static struct inlineCache nexpS = _ILC1; |
3886 |
static struct inlineCache motS = _ILC4; |
|
3887 |
static struct inlineCache bpS = _ILC4; |
|
3888 |
static struct inlineCache bmpS = _ILC4; |
|
3889 |
static struct inlineCache bspS = _ILC4; |
|
3890 |
static struct inlineCache brS = _ILC4; |
|
3891 |
static struct inlineCache focInS = _ILC1; |
|
3892 |
static struct inlineCache focOutS = _ILC1; |
|
3893 |
static struct inlineCache peS = _ILC4; |
|
3894 |
static struct inlineCache plS = _ILC2; |
|
54 | 3895 |
static struct inlineCache termS = _ILC1; |
3896 |
static struct inlineCache savtermS = _ILC1; |
|
3897 |
static struct inlineCache destrS = _ILC1; |
|
3898 |
static struct inlineCache unmapS = _ILC1; |
|
3899 |
static struct inlineCache mapS = _ILC1; |
|
3900 |
static struct inlineCache confS = _ILC5; |
|
70 | 3901 |
static struct inlineCache coveredS = _ILC2; |
1543 | 3902 |
static struct inlineCache clientMsg = _ILC5; |
12 | 3903 |
|
3904 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3905 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3906 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3907 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3908 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3909 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3910 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3911 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3912 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3913 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3914 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3915 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3916 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3917 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3918 |
static struct inlineCache mapping = _ILC2; |
70 | 3919 |
static struct inlineCache vis = _ILC1; |
12 | 3920 |
|
3921 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3922 |
static struct inlineCache skrS = _ILC4; |
12 | 3923 |
|
1209 | 3924 |
if (! ISCONNECTED) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3925 |
RETURN (false); |
1209 | 3926 |
} |
3927 |
||
3928 |
dpy = myDpy; |
|
3929 |
||
1210 | 3930 |
eB = __INST(eventBuffer); |
3931 |
||
135 | 3932 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3933 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3934 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3935 |
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
|
3936 |
RETURN (false); |
135 | 3937 |
} |
3938 |
||
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3939 |
/* |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3940 |
* 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
|
3941 |
* avoid creation & lookup then. |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3942 |
*/ |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3943 |
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
|
3944 |
if (__isExternalAddress(t)) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3945 |
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
|
3946 |
theView = __INST(lastView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3947 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3948 |
} |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3949 |
} |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3950 |
|
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3951 |
if (theView == nil) { |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3952 |
windowID = __MKOBJ(ae->window); |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3953 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
1540 | 3954 |
/* |
3955 |
* #viewFromId: could lead to a GC - refetch event ptr |
|
3956 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3957 |
eB = __INST(eventBuffer); |
1540 | 3958 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3959 |
} |
12 | 3960 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3961 |
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
|
3962 |
RETURN (nil); |
12 | 3963 |
} |
3964 |
||
3965 |
/* |
|
3966 |
* key, button and pointer events are sent to the sensor, |
|
3967 |
* or (if there is none) to the delegate. |
|
3968 |
* or (if there is none) to the view. |
|
26 | 3969 |
* |
3970 |
* expose events are sent to the sensor, |
|
3971 |
* or (if there is none) to the view |
|
3972 |
* |
|
12 | 3973 |
* sensor and delegate get view as additional argument |
115 | 3974 |
* all of this has been taken out of here to corresponding methods |
3975 |
* in DeviceWorkstation. |
|
12 | 3976 |
*/ |
90 | 3977 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3978 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3979 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3980 |
#endif |
135 | 3981 |
switch (ev->type) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3982 |
case KeyRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3983 |
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
|
3984 |
ipS = &skrS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3985 |
upDown = false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3986 |
goto keyPressAndRelease; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3987 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3988 |
case KeyPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3989 |
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
|
3990 |
ipS = &skpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3991 |
upDown = true; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3992 |
/* FALL INTO */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3993 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3994 |
keyPressAndRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3995 |
__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
|
3996 |
__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
|
3997 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3998 |
__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
|
3999 |
__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
|
4000 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4001 |
__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
|
4002 |
__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
|
4003 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4004 |
__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
|
4005 |
__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
|
4006 |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4007 |
ev_x = ke->x; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4008 |
ev_y = ke->y; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4009 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4010 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4011 |
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
|
4012 |
if (nchars |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4013 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4014 |
|| (buffer[0] >= 0x80))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4015 |
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
|
4016 |
keySymString = NULL; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4017 |
} else { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4018 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4019 |
switch (keySym) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4020 |
case XK_Control_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4021 |
case XK_Control_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4022 |
__INST(ctrlDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4023 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4024 |
case XK_Shift_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4025 |
case XK_Shift_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4026 |
__INST(shiftDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4027 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4028 |
case XK_Meta_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4029 |
case XK_Meta_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4030 |
__INST(metaDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4031 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4032 |
case XK_Alt_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4033 |
case XK_Alt_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4034 |
__INST(altDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4035 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4036 |
} |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4037 |
#endif |
150 | 4038 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4039 |
keySymString = XKeysymToString(keySym); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4040 |
if (keySymString) { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4041 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4042 |
if (keySymString[0] == 'D') { |
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 |
* 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
|
4045 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4046 |
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
|
4047 |
keySymString = "DeleteLine"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4048 |
} 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
|
4049 |
keySymString = "DeleteWord"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4050 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4051 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4052 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4053 |
* make names compatible |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4054 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4055 |
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
|
4056 |
keySymString = "CursorDown"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4057 |
} 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
|
4058 |
keySymString = "CursorUp"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4059 |
} 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
|
4060 |
keySymString = "CursorLeft"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4061 |
} 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
|
4062 |
keySymString = "CursorRight"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4063 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4064 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4065 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4066 |
arg = __MKSTRING(keySymString); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
4067 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4068 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4069 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4070 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4071 |
if (arg == nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4072 |
/* 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
|
4073 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4074 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4075 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4076 |
(*(*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
|
4077 |
arg, |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4078 |
__MKSMALLINT(ev_x), |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4079 |
__MKSMALLINT(ev_y), |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4080 |
theView); |
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 |
case ButtonPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4084 |
__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
|
4085 |
__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
|
4086 |
__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
|
4087 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4088 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4089 |
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
|
4090 |
else |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4091 |
nextMultiClickTime = 0; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4092 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4093 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4094 |
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
|
4095 |
int _multiClickTime; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4096 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4097 |
_multiClickTime = __longIntVal(t); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4098 |
if (be->time < _multiClickTime) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4099 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1540 | 4100 |
/* |
4101 |
* MKUINT could lead to a GC - refetch event ptr |
|
4102 |
*/ |
|
4103 |
eB = __INST(eventBuffer); |
|
4104 |
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
|
4105 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4106 |
ipS = &bmpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4107 |
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
|
4108 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4109 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4110 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4111 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4112 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1540 | 4113 |
/* |
4114 |
* MKUINT could lead to a GC - refetch event ptr |
|
4115 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4116 |
eB = __INST(eventBuffer); |
1540 | 4117 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
4118 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4119 |
#ifdef NO_LONGER |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4120 |
if (be->state & ShiftMask) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4121 |
ipS = &bspS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4122 |
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
|
4123 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4124 |
} |
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4125 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4126 |
ipS = &bpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4127 |
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
|
4128 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4129 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4130 |
/* NOT REACHED */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4131 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4132 |
case ButtonRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4133 |
__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
|
4134 |
__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
|
4135 |
__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
|
4136 |
ipS = &brS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4137 |
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
|
4138 |
/* fall into */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4139 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4140 |
sendButtonEvent: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4141 |
butt = __MKSMALLINT(be->button); |
12 | 4142 |
#ifdef NOTDEF |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4143 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4144 |
* 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
|
4145 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4146 |
if (__INST(metaDown) == true) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4147 |
butt = __MKSMALLINT(2); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4148 |
else |
0 | 4149 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4150 |
butt = __AT_(__INST(buttonTranslation), butt); |
1540 | 4151 |
/* |
4152 |
* #at: could lead to a GC - refetch event ptr |
|
4153 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4154 |
eB = __INST(eventBuffer); |
1540 | 4155 |
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
|
4156 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4157 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4158 |
(*(*ipS).ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4159 |
symS, nil, ipS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4160 |
butt, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4161 |
__MKSMALLINT(ke->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4162 |
__MKSMALLINT(ke->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4163 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4164 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4165 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4166 |
case MotionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4167 |
if (__INST(motionEventCompression) != false) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4168 |
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
|
4169 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4170 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4171 |
__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
|
4172 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 4173 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4174 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4175 |
__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
|
4176 |
__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
|
4177 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4178 |
__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
|
4179 |
__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
|
4180 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4181 |
__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
|
4182 |
__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
|
4183 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4184 |
(*motS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4185 |
@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
|
4186 |
__MKSMALLINT(me->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4187 |
__MKSMALLINT(me->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4188 |
__MKSMALLINT(me->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4189 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4190 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4191 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4192 |
case FocusIn: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4193 |
(*focInS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4194 |
@symbol(focusInView:), nil, &focInS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4195 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4196 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4197 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4198 |
case FocusOut: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4199 |
(*focOutS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4200 |
@symbol(focusOutView:), nil, &focOutS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4201 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4202 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4203 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4204 |
case EnterNotify: |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4205 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4206 |
__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
|
4207 |
__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
|
4208 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4209 |
__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
|
4210 |
__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
|
4211 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4212 |
__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
|
4213 |
__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
|
4214 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4215 |
(*peS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4216 |
@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
|
4217 |
__MKSMALLINT(ewe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4218 |
__MKSMALLINT(ewe->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4219 |
__MKSMALLINT(ewe->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4220 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4221 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4222 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4223 |
case LeaveNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4224 |
(*plS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4225 |
@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
|
4226 |
__MKSMALLINT(lwe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4227 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4228 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4229 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4230 |
case GraphicsExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4231 |
(*gexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4232 |
@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
|
4233 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4234 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4235 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4236 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4237 |
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
|
4238 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4239 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4240 |
if (ee->count != 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4241 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4242 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4243 |
/* fall into */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4244 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4245 |
case NoExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4246 |
(*nexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4247 |
@symbol(noExposeView:), nil, &nexpS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4248 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4249 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4250 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4251 |
case Expose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4252 |
(*expS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4253 |
@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
|
4254 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4255 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4256 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4257 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4258 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4259 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4260 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4261 |
case ConfigureNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4262 |
if (ce->above != None) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4263 |
siblingID = __MKOBJ(ce->above); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4264 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, siblingID); |
1540 | 4265 |
/* |
4266 |
* MKOBJ or #viewFromId: could lead to a GC - refetch event ptr |
|
4267 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4268 |
eB = __INST(eventBuffer); |
1540 | 4269 |
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
|
4270 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4271 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4272 |
(*confS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4273 |
@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
|
4274 |
__MKSMALLINT(ce->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4275 |
__MKSMALLINT(ce->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4276 |
__MKSMALLINT(ce->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4277 |
__MKSMALLINT(ce->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4278 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4279 |
if (sibling != nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4280 |
(*coveredS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4281 |
@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
|
4282 |
theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4283 |
sibling); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4284 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4285 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4286 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4287 |
case ClientMessage: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4288 |
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
|
4289 |
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
|
4290 |
|| (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
|
4291 |
(*termS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4292 |
@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
|
4293 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4294 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4295 |
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
|
4296 |
(*savtermS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4297 |
@symbol(saveAndTerminateView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4298 |
, nil, &savtermS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4299 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4300 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4301 |
} |
1540 | 4302 |
/* |
4303 |
* any other client message |
|
4304 |
*/ |
|
4305 |
i = (char *)(&(ev->xclient.data)) - (char *)ev; |
|
4306 |
(*clientMsg.ilc_func)(self, |
|
1543 | 4307 |
@symbol(clientMessage:type:format:dataOffset:view:) |
1540 | 4308 |
, nil, &clientMsg |
1543 | 4309 |
, __INST(eventBuffer) |
4310 |
,__MKSMALLINT(ev->xclient.message_type) |
|
4311 |
,__MKSMALLINT(ev->xclient.format) |
|
4312 |
,__MKSMALLINT(i), |
|
4313 |
theView); |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4314 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4315 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4316 |
case DestroyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4317 |
(*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
|
4318 |
, nil, &destrS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4319 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4320 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4321 |
case UnmapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4322 |
(*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
|
4323 |
, nil, &unmapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4324 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4325 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4326 |
case MapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4327 |
(*mapS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4328 |
@symbol(mappedView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4329 |
, nil, &mapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4330 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4331 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4332 |
case KeymapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4333 |
(*keymap.ilc_func)(theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4334 |
@symbol(keyMapChange) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4335 |
, nil, &keymap); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4336 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4337 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4338 |
case VisibilityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4339 |
switch (ve->state) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4340 |
case VisibilityUnobscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4341 |
arg = @symbol(unobscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4342 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4343 |
case VisibilityPartiallyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4344 |
arg = @symbol(partiallyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4345 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4346 |
case VisibilityFullyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4347 |
arg = @symbol(fullyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4348 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4349 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4350 |
(*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
|
4351 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4352 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4353 |
case CreateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4354 |
(*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
|
4355 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4356 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4357 |
case MapRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4358 |
(*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
|
4359 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4360 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4361 |
case ReparentNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4362 |
(*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
|
4363 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4364 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4365 |
case ConfigureRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4366 |
(*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
|
4367 |
break; |
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 |
case GravityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4370 |
(*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
|
4371 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4372 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4373 |
case ResizeRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4374 |
(*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
|
4375 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4376 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4377 |
case CirculateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4378 |
(*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
|
4379 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4380 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4381 |
case CirculateRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4382 |
(*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
|
4383 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4384 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4385 |
case PropertyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4386 |
(*prop.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4387 |
@symbol(propertyChangeView) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4388 |
, nil, &prop, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4389 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4390 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4391 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4392 |
case SelectionClear: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4393 |
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
|
4394 |
(*selClear.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4395 |
@symbol(selectionClear:view:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4396 |
, nil, &selClear, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4397 |
selectionID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4398 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4399 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4400 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4401 |
case SelectionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4402 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4403 |
* 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
|
4404 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4405 |
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
|
4406 |
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
|
4407 |
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
|
4408 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4409 |
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
|
4410 |
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
|
4411 |
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
|
4412 |
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
|
4413 |
(*selNotify.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4414 |
@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
|
4415 |
, nil, &selNotify, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4416 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4417 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4418 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4419 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4420 |
case SelectionRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4421 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4422 |
* someone wants the selection |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4423 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4424 |
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
|
4425 |
ev->xselectionrequest.property, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4426 |
ev->xselectionrequest.target, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4427 |
ev->xselectionrequest.selection, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4428 |
ev->xselectionrequest.requestor)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4429 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4430 |
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
|
4431 |
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
|
4432 |
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
|
4433 |
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
|
4434 |
(*selReq.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4435 |
@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
|
4436 |
, nil, &selReq, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4437 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4438 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4439 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4440 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4441 |
case ColormapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4442 |
(*colormap.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4443 |
@symbol(colorMapChangeView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4444 |
, nil, &colormap, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4445 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4446 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4447 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4448 |
case MappingNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4449 |
switch(mape->request) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4450 |
case MappingModifier: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4451 |
arg = @symbol(mappingModifier); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4452 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4453 |
case MappingKeyboard: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4454 |
arg = @symbol(mappingKeyboard); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4455 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4456 |
case MappingPointer: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4457 |
arg = @symbol(mappingPointer); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4458 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4459 |
default: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4460 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4461 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4462 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4463 |
(*mapping.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4464 |
@symbol(mappingChanged:event:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4465 |
, nil, &mapping, arg, eB); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4466 |
break; |
0 | 4467 |
} |
135 | 4468 |
#undef ae |
0 | 4469 |
#undef ee |
4470 |
#undef ke |
|
4471 |
#undef be |
|
4472 |
#undef ce |
|
4473 |
#undef me |
|
4474 |
#undef ewe |
|
4475 |
#undef lwe |
|
4476 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4477 |
#undef mape |
0 | 4478 |
%} |
4479 |
. |
|
4480 |
^ true |
|
4481 |
! |
|
4482 |
||
1344 | 4483 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4484 |
"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
|
4485 |
(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
|
4486 |
This code is somewhat special, since X has a concept of graphic |
295 | 4487 |
expose events (which are sent after a bitblt). After such a bitblt, |
4488 |
we only handle exposes until the graphicsExpose arrives. |
|
4489 |
Other systems may not need such a kludge" |
|
4490 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4491 |
"interested in exposes only ?" |
295 | 4492 |
dispatchingExpose notNil ifTrue:[ |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4493 |
[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
|
4494 |
self dispatchExposeEventFor:dispatchingExpose |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4495 |
]. |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4496 |
^ self |
295 | 4497 |
]. |
4498 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4499 |
[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
|
4500 |
(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
|
4501 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4502 |
ex return |
1491 | 4503 |
] do:[ |
4504 |
self dispatchLastEvent |
|
4505 |
] |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4506 |
]. |
295 | 4507 |
] |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4508 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4509 |
"Modified: 26.3.1997 / 19:04:17 / cg" |
295 | 4510 |
! |
4511 |
||
1344 | 4512 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4513 |
"dispose (throw away) specific events. If aWindowId is nil, |
4514 |
events matching the mask are thrown away regardless of which |
|
4515 |
view they are for. Otherwise, only matching events for that |
|
4516 |
view are flushed." |
|
0 | 4517 |
|
4518 |
%{ /* NOCONTEXT */ |
|
4519 |
||
4520 |
XEvent ev; |
|
4521 |
Window win; |
|
4522 |
||
1209 | 4523 |
if (ISCONNECTED |
4524 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4525 |
Display *dpy = myDpy; |
4526 |
||
4527 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4528 |
win = _WindowVal(aWindowIdOrNil); |
|
4529 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4530 |
} else { |
|
4531 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4532 |
} |
|
4533 |
RETURN ( self ); |
|
0 | 4534 |
} |
4535 |
%} |
|
4536 |
. |
|
4537 |
self primitiveFailed |
|
4538 |
! |
|
4539 |
||
1344 | 4540 |
eventMaskFor:anEventSymbol |
295 | 4541 |
"return the eventMask bit-constant corresponding to an event symbol" |
4542 |
||
4543 |
%{ /* NOCONTEXT */ |
|
4544 |
||
4545 |
int m = 0; |
|
4546 |
||
4547 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4548 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4549 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4550 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4551 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4552 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4553 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4554 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4555 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4556 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4557 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4558 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4559 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4560 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4561 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4562 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4563 |
RETURN (__MKSMALLINT(m)); |
295 | 4564 |
%} |
4565 |
! |
|
4566 |
||
1344 | 4567 |
eventPending |
310 | 4568 |
"return true, if any event is pending. |
4569 |
This looks for both the internal queue and the display connection." |
|
12 | 4570 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4571 |
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
|
4572 |
|
12 | 4573 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4574 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4575 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4576 |
^ self eventPendingWithSync:false |
0 | 4577 |
! |
4578 |
||
1344 | 4579 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4580 |
"return true, if a specific event is pending" |
4581 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4582 |
^ 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
|
4583 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4584 |
|
1344 | 4585 |
eventPendingWithSync:doSync |
7 | 4586 |
"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
|
4587 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4588 |
before checking." |
0 | 4589 |
|
12 | 4590 |
%{ /* UNLIMITEDSTACK */ |
0 | 4591 |
|
150 | 4592 |
if (ISCONNECTED) { |
1344 | 4593 |
Display *dpy = myDpy; |
4594 |
||
4595 |
if (doSync == true) { |
|
4596 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4597 |
} |
|
4598 |
if (XPending(dpy)) { |
|
4599 |
RETURN (true); |
|
4600 |
} |
|
150 | 4601 |
} |
4602 |
RETURN ( false ); |
|
0 | 4603 |
%} |
4604 |
! |
|
4605 |
||
1344 | 4606 |
eventQueued |
341 | 4607 |
"return true, if any event is queued" |
4608 |
||
4609 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 4610 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 4611 |
]. |
4612 |
^ self eventQueuedAlready |
|
4613 |
||
4614 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
4615 |
! |
|
4616 |
||
1344 | 4617 |
eventQueuedAlready |
341 | 4618 |
"return true, if any event is queued internally. |
4619 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
4620 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
4621 |
the display connection)." |
|
4622 |
||
4623 |
%{ /* UNLIMITEDSTACK */ |
|
4624 |
||
4625 |
if (ISCONNECTED) { |
|
1344 | 4626 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
4627 |
RETURN (true); |
|
4628 |
} |
|
341 | 4629 |
} |
4630 |
RETURN ( false ); |
|
4631 |
%} |
|
4632 |
! |
|
4633 |
||
1344 | 4634 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 4635 |
"return true, if any of the masked events is pending" |
4636 |
||
4637 |
%{ /* UNLIMITEDSTACK */ |
|
4638 |
||
4639 |
XEvent ev; |
|
4640 |
Window win; |
|
4641 |
int thereIsOne; |
|
4642 |
||
4643 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 4644 |
Display *dpy = myDpy; |
4645 |
||
4646 |
if (doSync == true) { |
|
4647 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4648 |
} |
|
4649 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4650 |
win = _WindowVal(aWindowIdOrNil); |
|
4651 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
4652 |
} else { |
|
4653 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
4654 |
} |
|
4655 |
if (thereIsOne) { |
|
4656 |
XPutBackEvent(dpy, &ev); |
|
4657 |
RETURN ( true ); |
|
4658 |
} |
|
295 | 4659 |
} |
4660 |
RETURN ( false ); |
|
4661 |
%} |
|
4662 |
! |
|
4663 |
||
1344 | 4664 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 4665 |
"return true, if any expose event is pending for a specific view, |
4666 |
or any view (if the arg is nil). |
|
4667 |
This is an X specific, only required after a scroll operation." |
|
7 | 4668 |
|
12 | 4669 |
%{ /* UNLIMITEDSTACK */ |
7 | 4670 |
|
4671 |
XEvent ev; |
|
4672 |
Window win; |
|
81 | 4673 |
int thereIsOne; |
4674 |
||
150 | 4675 |
if (ISCONNECTED) { |
1344 | 4676 |
Display *dpy = myDpy; |
4677 |
||
4678 |
if (doSync == true) { |
|
4679 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4680 |
} |
|
4681 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4682 |
win = _WindowVal(aWindowIdOrNil); |
|
4683 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
4684 |
} else { |
|
4685 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
4686 |
} |
|
4687 |
if (thereIsOne) { |
|
4688 |
XPutBackEvent(dpy, &ev); |
|
4689 |
RETURN ( true ); |
|
4690 |
} |
|
81 | 4691 |
} |
4692 |
RETURN ( false ); |
|
4693 |
%} |
|
4694 |
! |
|
4695 |
||
1344 | 4696 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 4697 |
"read next event - put into local eventBuffer. |
4698 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
4699 |
otherwise only events for that specific view will be fetched. |
|
4700 |
Returns true, if there was an event, false otherwise. |
|
4701 |
This method may block - so you better check for pending events |
|
4702 |
before calling for it. |
|
4703 |
||
4704 |
Sorry I had to split dispatch into this fetch method and an extra |
|
4705 |
handle method to allow unlimitedstack here. |
|
4706 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
4707 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
4708 |
" |
|
81 | 4709 |
|
4710 |
%{ /* UNLIMITEDSTACK */ |
|
4711 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4712 |
Display *dpy; |
295 | 4713 |
Window win, wWanted; |
4714 |
int evMask; |
|
4715 |
OBJ eB; |
|
4716 |
XEvent *ev; |
|
4717 |
||
4718 |
if (! ISCONNECTED) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4719 |
RETURN (false); |
295 | 4720 |
} |
4721 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4722 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4723 |
|
555 | 4724 |
eB = __INST(eventBuffer); |
295 | 4725 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4726 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4727 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4728 |
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
|
4729 |
RETURN (false); |
295 | 4730 |
} |
4731 |
ev->type = 0; |
|
4732 |
||
4733 |
if (__isSmallInteger(eventMask)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4734 |
evMask = __intVal(eventMask); |
295 | 4735 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4736 |
evMask = ~0; |
295 | 4737 |
} |
4738 |
||
4739 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4740 |
wWanted = _WindowVal(aViewIdOrNil); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4741 |
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
|
4742 |
RETURN ( true ); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4743 |
} |
295 | 4744 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4745 |
if (evMask == ~0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4746 |
XNextEvent(dpy, ev); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4747 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4748 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4749 |
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
|
4750 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4751 |
} |
295 | 4752 |
} |
4753 |
%}. |
|
4754 |
^ false |
|
4755 |
! |
|
4756 |
||
1344 | 4757 |
handleAllEvents |
295 | 4758 |
"from now on, handle any kind of event" |
4759 |
||
4760 |
dispatchingExpose := nil |
|
4761 |
! |
|
4762 |
||
1344 | 4763 |
handleExposeOnlyFor:aView |
295 | 4764 |
"from now on, handle expose events only" |
4765 |
||
4766 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4767 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4768 |
|
1344 | 4769 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4770 |
"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
|
4771 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4772 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4773 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 4774 |
self refreshKeyboardMapping:eB. |
4775 |
"Maybe some of our modifiers have been changed" |
|
4776 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4777 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4778 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4779 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4780 |
! |
4781 |
||
1344 | 4782 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4783 |
"tell X that we are only interested in events from aMask, which |
295 | 4784 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4785 |
||
4786 |
%{ /* NOCONTEXT */ |
|
4787 |
||
4788 |
int mask; |
|
4789 |
||
1209 | 4790 |
if (ISCONNECTED |
4791 |
&& __isExternalAddress(aWindowId) |
|
295 | 4792 |
&& __isSmallInteger(aMask)) { |
1344 | 4793 |
mask = __intVal(aMask); |
295 | 4794 |
|
4795 |
#ifdef OLD |
|
1344 | 4796 |
/* these may not be disabled */ |
4797 |
mask |= ExposureMask | StructureNotifyMask | |
|
4798 |
KeyPressMask | KeyReleaseMask | |
|
4799 |
EnterWindowMask | LeaveWindowMask | |
|
4800 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 4801 |
#endif |
4802 |
||
1344 | 4803 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
4804 |
RETURN ( self ); |
|
295 | 4805 |
} |
4806 |
%} |
|
4807 |
. |
|
4808 |
self primitiveFailed |
|
4809 |
! |
|
4810 |
||
1344 | 4811 |
startDispatch |
295 | 4812 |
"redefined to clear dispatchingExpose, which is a special X feature" |
4813 |
||
4814 |
dispatching ifTrue:[^ self]. |
|
4815 |
dispatchingExpose := nil. |
|
4816 |
super startDispatch |
|
0 | 4817 |
! ! |
295 | 4818 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4819 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4820 |
|
1567 | 4821 |
sendClientEvent:msgType format:msgFormat to:targetWindowID data1:d1 data2:d2 data3:d3 data4:d4 data5:d5 |
1556 | 4822 |
"send a ClientMessage to some other (possibly: non-ST/X) view. |
1567 | 4823 |
The client message gets message_type and msgFormat as specified by |
1556 | 4824 |
the arguments. The additional data arguments specify up to |
4825 |
5 longWords of user data; each may be an integer or nil. |
|
4826 |
It is passed transparently in the events data field. |
|
4827 |
See XProtocol specification for more details." |
|
4828 |
||
4829 |
"/ Event.xclient.type = ClientMessage; |
|
4830 |
"/ Event.xclient.display = dpy; |
|
4831 |
"/ Event.xclient.message_type = msgType; |
|
1567 | 4832 |
"/ Event.xclient.format = msgFormat; |
1556 | 4833 |
"/ Event.xclient.window = targetWindowID; |
4834 |
"/ Event.xclient.data.l[0] = d1 |
|
4835 |
"/ Event.xclient.data.l[1] = d2 |
|
4836 |
"/ Event.xclient.data.l[2] = d3 |
|
4837 |
"/ Event.xclient.data.l[3] = d4 |
|
4838 |
"/ Event.xclient.data.l[4] = d5 |
|
4839 |
"/ |
|
4840 |
"/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event); |
|
4841 |
||
4842 |
%{ /* NOCONTEXT */ |
|
4843 |
int type; |
|
4844 |
int state; |
|
4845 |
||
4846 |
if (ISCONNECTED |
|
4847 |
&& __isInteger(msgType) |
|
1567 | 4848 |
&& __isInteger(msgFormat) |
1556 | 4849 |
&& (__isExternalAddress(targetWindowID) || __isInteger(targetWindowID))) { |
4850 |
Display *dpy = myDpy; |
|
4851 |
XEvent ev; |
|
4852 |
Status result; |
|
4853 |
||
4854 |
if (__isInteger(d1)) { |
|
4855 |
ev.xclient.data.l[0] = __longIntVal(d1); |
|
4856 |
} else { |
|
4857 |
if (__isExternalAddress(d1)) { |
|
4858 |
ev.xclient.data.l[0] = (int)__externalAddressVal(d1); |
|
4859 |
} else { |
|
4860 |
ev.xclient.data.l[0] = 0; |
|
4861 |
} |
|
4862 |
} |
|
4863 |
if (__isInteger(d2)) { |
|
4864 |
ev.xclient.data.l[1] = __longIntVal(d2); |
|
4865 |
} else { |
|
4866 |
if (__isExternalAddress(d2)) { |
|
4867 |
ev.xclient.data.l[1] = (int)__externalAddressVal(d2); |
|
4868 |
} else { |
|
4869 |
ev.xclient.data.l[1] = 0; |
|
4870 |
} |
|
4871 |
} |
|
4872 |
if (__isInteger(d3)) { |
|
4873 |
ev.xclient.data.l[2] = __longIntVal(d3); |
|
4874 |
} else { |
|
4875 |
if (__isExternalAddress(d3)) { |
|
4876 |
ev.xclient.data.l[2] = (int)__externalAddressVal(d3); |
|
4877 |
} else { |
|
4878 |
ev.xclient.data.l[2] = 0; |
|
4879 |
} |
|
4880 |
} |
|
4881 |
if (__isInteger(d4)) { |
|
4882 |
ev.xclient.data.l[3] = __longIntVal(d4); |
|
4883 |
} else { |
|
4884 |
if (__isExternalAddress(d4)) { |
|
4885 |
ev.xclient.data.l[3] = (int)__externalAddressVal(d4); |
|
4886 |
} else { |
|
4887 |
ev.xclient.data.l[3] = 0; |
|
4888 |
} |
|
4889 |
} |
|
4890 |
if (__isInteger(d5)) { |
|
4891 |
ev.xclient.data.l[4] = __longIntVal(d5); |
|
4892 |
} else { |
|
4893 |
if (__isExternalAddress(d5)) { |
|
4894 |
ev.xclient.data.l[4] = (int)__externalAddressVal(d5); |
|
4895 |
} else { |
|
4896 |
ev.xclient.data.l[4] = 0; |
|
4897 |
} |
|
4898 |
} |
|
4899 |
||
4900 |
if (__isExternalAddress(targetWindowID)) { |
|
4901 |
ev.xclient.window = _WindowVal(targetWindowID); |
|
4902 |
} else { |
|
4903 |
ev.xclient.window = (Window)__longIntVal(targetWindowID); |
|
4904 |
} |
|
4905 |
||
4906 |
ev.xclient.type = ClientMessage; |
|
4907 |
ev.xclient.display = dpy; |
|
4908 |
ev.xclient.message_type = __longIntVal(msgType); |
|
1567 | 4909 |
ev.xclient.format = __longIntVal(msgFormat); |
1556 | 4910 |
|
4911 |
result = XSendEvent(dpy, ev.xclient.window, True, NoEventMask , &ev); |
|
4912 |
||
4913 |
if ((result == BadValue) || (result == BadWindow)) { |
|
4914 |
DPRINTF(("bad status in sendClientEvent\n")); |
|
4915 |
RETURN ( false ) |
|
4916 |
} |
|
4917 |
RETURN (true) |
|
4918 |
} |
|
4919 |
%}. |
|
4920 |
self primitiveFailed. |
|
4921 |
^ false |
|
4922 |
! |
|
4923 |
||
1344 | 4924 |
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
|
4925 |
"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
|
4926 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4927 |
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
|
4928 |
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
|
4929 |
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
|
4930 |
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
|
4931 |
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
|
4932 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4933 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4934 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4935 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4936 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4937 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4938 |
if (__isSmallInteger(stateMask)) { |
1344 | 4939 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4940 |
} else { |
1344 | 4941 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4942 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4943 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4944 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4945 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4946 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4947 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 4948 |
Display *dpy = myDpy; |
4949 |
||
4950 |
XEvent ev; |
|
4951 |
Window target; |
|
4952 |
Status result; |
|
4953 |
KeySym keySym, *syms; |
|
4954 |
int screen = __intVal(__INST(screen)); |
|
4955 |
char s[2]; |
|
4956 |
int nSyms; |
|
4957 |
||
4958 |
if ((typeSymbol == @symbol(keyPress)) |
|
4959 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
4960 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
4961 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
4962 |
} else { |
|
4963 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
4964 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
4965 |
s[1] = '\0'; |
|
4966 |
keySym = XStringToKeysym(s); |
|
4967 |
} else { |
|
4968 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
4969 |
} |
|
4970 |
} |
|
4971 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
4972 |
||
4973 |
if (stateMask == nil) { |
|
4974 |
/* |
|
4975 |
* get the modifier from the keySym |
|
4976 |
*/ |
|
4977 |
nSyms = 0; |
|
4978 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
4979 |
if (syms) { |
|
4980 |
int i; |
|
4981 |
||
4982 |
for (i=0; i<nSyms; i++) { |
|
4983 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4984 |
#ifdef MODIFIERDEBUG |
1344 | 4985 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4986 |
#endif |
1344 | 4987 |
if (i) state = (1 << (i-1)); |
4988 |
break; |
|
4989 |
} |
|
4990 |
} |
|
4991 |
XFree(syms); |
|
4992 |
} |
|
4993 |
} |
|
4994 |
} else { |
|
4995 |
if ((typeSymbol == @symbol(buttonPress)) |
|
4996 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
4997 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
4998 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
4999 |
} else { |
|
5000 |
ev.xbutton.button = 1; |
|
5001 |
} |
|
5002 |
} else { |
|
5003 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
5004 |
RETURN (false); |
|
5005 |
} |
|
5006 |
} |
|
5007 |
||
5008 |
if (typeSymbol == @symbol(keyPress)) |
|
5009 |
ev.xany.type = KeyPress; |
|
5010 |
else if (typeSymbol == @symbol(keyRelease)) |
|
5011 |
ev.xany.type = KeyRelease; |
|
5012 |
else if (typeSymbol == @symbol(buttonPress)) |
|
5013 |
ev.xany.type = ButtonPress; |
|
5014 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
5015 |
ev.xany.type = ButtonRelease; |
|
5016 |
||
5017 |
if (__isExternalAddress(targetId)) { |
|
5018 |
target = _WindowVal(targetId); |
|
5019 |
} else { |
|
5020 |
target = (Window) __longIntVal(targetId); |
|
5021 |
} |
|
5022 |
ev.xkey.window = target; |
|
5023 |
ev.xkey.same_screen = 1; |
|
5024 |
ev.xkey.subwindow = 0; |
|
5025 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
5026 |
ev.xkey.x = __intVal(xPos); |
|
5027 |
ev.xkey.y = __intVal(yPos); |
|
5028 |
ev.xkey.state = state; |
|
5029 |
ev.xkey.time = CurrentTime; |
|
5030 |
||
5031 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
|
5032 |
if ((result == BadValue) || (result == BadWindow)) { |
|
5033 |
DPRINTF(("bad status\n")); |
|
5034 |
RETURN ( false ) |
|
5035 |
} |
|
5036 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5037 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5038 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5039 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5040 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5041 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5042 |
|
1344 | 5043 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5044 |
"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
|
5045 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5046 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5047 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 5048 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5049 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5050 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5051 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5052 |
aCharacterOrString isString ifTrue:[ |
1344 | 5053 |
aCharacterOrString do:[:char | |
5054 |
self simulateKeyboardInput:char inViewId:viewId |
|
5055 |
]. |
|
5056 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5057 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5058 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5059 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5060 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5061 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5062 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 5063 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5064 |
] ifFalse:[ |
1344 | 5065 |
(aCharacterOrString == Character tab) ifTrue:[ |
5066 |
code := #Tab |
|
5067 |
] ifFalse:[ |
|
5068 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
5069 |
code := #Escape |
|
5070 |
] |
|
5071 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5072 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5073 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5074 |
control ifTrue:[ |
1344 | 5075 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5076 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5077 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5078 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5079 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5080 |
"/ (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
|
5081 |
"/ 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
|
5082 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5083 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5084 |
code isNumber ifTrue:[ |
1344 | 5085 |
code >= $A asciiValue ifTrue:[ |
5086 |
code <= $Z asciiValue ifTrue:[ |
|
5087 |
state := self shiftMask |
|
5088 |
] |
|
5089 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5090 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5091 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5092 |
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
|
5093 |
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
|
5094 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5095 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5096 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5097 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5098 |
|point id| |
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 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5101 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5102 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5103 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5104 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5105 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5106 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5107 |
|
295 | 5108 |
!XWorkstation methodsFor:'font stuff'! |
5109 |
||
1344 | 5110 |
createFontFor:aFontName |
295 | 5111 |
"a basic method for X-font allocation; this method allows |
5112 |
any font to be aquired (even those not conforming to |
|
5113 |
standard naming conventions, such as cursor, fixed or k14)" |
|
5114 |
||
5115 |
%{ /* UNLIMITEDSTACK */ |
|
5116 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
5117 |
||
5118 |
XFontStruct *newFont; |
|
5119 |
||
5120 |
if (ISCONNECTED) { |
|
1344 | 5121 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
5122 |
BEGIN_INTERRUPTSBLOCKED |
|
5123 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5124 |
#ifdef COUNT_RESOURCES |
1344 | 5125 |
if (newFont) |
5126 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5127 |
#endif |
1344 | 5128 |
END_INTERRUPTSBLOCKED |
5129 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
5130 |
} |
|
295 | 5131 |
} |
5132 |
%}. |
|
5133 |
^ nil |
|
5134 |
! |
|
5135 |
||
1344 | 5136 |
decomposeXFontName:aString into:aBlock |
295 | 5137 |
"extract family, face, style and size from an |
5138 |
X-font name |
|
5139 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
5140 |
evaluate aBlock with these" |
|
5141 |
||
5142 |
|origin family face style moreStyle skip fheight size |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5143 |
resX resY x1 x2 registry encoding coding start end | |
295 | 5144 |
|
5145 |
aString isNil ifTrue:[^ false]. |
|
5146 |
(aString startsWith:'-') ifFalse:[ |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5147 |
" |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5148 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5149 |
" |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5150 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5151 |
end := aString indexOf:$- startingAt:1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5152 |
family := aString copyFrom:1 to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5153 |
start := end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5154 |
end := aString indexOf:$- startingAt:start. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5155 |
style := aString copyFrom:start to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5156 |
start := end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5157 |
size := aString copyFrom:start. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5158 |
size := (Number readFromString:size onError:[^false]). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5159 |
aBlock value:family value:nil value:style value:size value:nil. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5160 |
^ true. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5161 |
]. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5162 |
('*-[0-9]*' match:aString) ifTrue:[ |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5163 |
" |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5164 |
something like lucidasans-24 |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5165 |
" |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5166 |
end := aString indexOf:$- startingAt:1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5167 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5168 |
family := aString copyFrom:1 to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5169 |
start := end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5170 |
size := aString copyFrom:start. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5171 |
size := (Number readFromString:size onError:[^false]). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5172 |
aBlock value:family value:nil value:nil value:size value:nil. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5173 |
^ true. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5174 |
]. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5175 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5176 |
^ true. |
295 | 5177 |
]. |
5178 |
||
5179 |
end := aString indexOf:$- startingAt:2. |
|
5180 |
(end == 0) ifTrue:[^ false]. |
|
5181 |
origin := aString copyFrom:2 to:(end - 1). |
|
5182 |
||
5183 |
start := end + 1. |
|
5184 |
end := aString indexOf:$- startingAt:start. |
|
5185 |
(end == 0) ifTrue:[^ false]. |
|
5186 |
family := aString copyFrom:start to:(end - 1). |
|
5187 |
||
5188 |
start := end + 1. |
|
5189 |
end := aString indexOf:$- startingAt:start. |
|
5190 |
(end == 0) ifTrue:[^ false]. |
|
5191 |
face := aString copyFrom:start to:(end - 1). |
|
5192 |
||
5193 |
start := end + 1. |
|
5194 |
end := aString indexOf:$- startingAt:start. |
|
5195 |
(end == 0) ifTrue:[^ false]. |
|
5196 |
style := aString copyFrom:start to:(end - 1). |
|
5197 |
(style = 'o') ifTrue:[ |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5198 |
style := 'oblique' |
295 | 5199 |
] ifFalse:[ |
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5200 |
(style = 'i') ifTrue:[ |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5201 |
style := 'italic' |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5202 |
] ifFalse:[ |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5203 |
(style = 'r') ifTrue:[ |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5204 |
style := 'roman' |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5205 |
] |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5206 |
] |
295 | 5207 |
]. |
5208 |
||
5209 |
start := end + 1. |
|
5210 |
end := aString indexOf:$- startingAt:start. |
|
5211 |
(end == 0) ifTrue:[^ false]. |
|
5212 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
5213 |
||
5214 |
start := end + 1. |
|
5215 |
end := aString indexOf:$- startingAt:start. |
|
5216 |
(end == 0) ifTrue:[^ false]. |
|
5217 |
skip := aString copyFrom:start to:(end - 1). |
|
5218 |
||
5219 |
start := end + 1. |
|
5220 |
end := aString indexOf:$- startingAt:start. |
|
5221 |
(end == 0) ifTrue:[^ false]. |
|
5222 |
fheight := aString copyFrom:start to:(end - 1). |
|
5223 |
||
5224 |
start := end + 1. |
|
5225 |
end := aString indexOf:$- startingAt:start. |
|
5226 |
(end == 0) ifTrue:[^ false]. |
|
5227 |
size := aString copyFrom:start to:(end - 1). |
|
5228 |
size := (Number readFromString:size) / 10. |
|
5229 |
||
5230 |
start := end + 1. |
|
5231 |
end := aString indexOf:$- startingAt:start. |
|
5232 |
(end == 0) ifTrue:[^ false]. |
|
5233 |
resX := aString copyFrom:start to:(end - 1). |
|
5234 |
||
5235 |
start := end + 1. |
|
5236 |
end := aString indexOf:$- startingAt:start. |
|
5237 |
(end == 0) ifTrue:[^ false]. |
|
5238 |
resY := aString copyFrom:start to:(end - 1). |
|
5239 |
||
5240 |
start := end + 1. |
|
5241 |
end := aString indexOf:$- startingAt:start. |
|
5242 |
(end == 0) ifTrue:[^ false]. |
|
5243 |
x1 := aString copyFrom:start to:(end - 1). |
|
5244 |
||
5245 |
start := end + 1. |
|
5246 |
end := aString indexOf:$- startingAt:start. |
|
5247 |
(end == 0) ifTrue:[^ false]. |
|
5248 |
x2 := aString copyFrom:start to:(end - 1). |
|
5249 |
||
5250 |
start := end + 1. |
|
5251 |
end := aString indexOf:$- startingAt:start. |
|
5252 |
(end == 0) ifTrue:[^ false]. |
|
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5253 |
registry := aString copyFrom:start to:(end - 1). |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5254 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5255 |
encoding := aString copyFrom:end + 1. |
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5256 |
|
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5257 |
coding := registry , '-' , encoding. |
295 | 5258 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5259 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5260 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5261 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5262 |
|
295 | 5263 |
aBlock value:family value:face value:style value:size value:coding. |
5264 |
^ true |
|
5265 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5266 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
1566
d6280c6d470a
care for registry PLUS encoding
Claus Gittinger <cg@exept.de>
parents:
1563
diff
changeset
|
5267 |
"Modified: 10.4.1997 / 09:45:36 / cg" |
295 | 5268 |
! |
5269 |
||
1344 | 5270 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5271 |
"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
|
5272 |
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
|
5273 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5274 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5275 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5276 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5277 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5278 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5279 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5280 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5281 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5282 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5283 |
if (ISCONNECTED) { |
1344 | 5284 |
Display *dpy = myDpy; |
5285 |
||
5286 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
5287 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
5288 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
5289 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5290 |
||
5291 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5292 |
|
1344 | 5293 |
f = _FontVal(aFontId); |
5294 |
if (f) { |
|
5295 |
n = f->n_properties; |
|
5296 |
prop = f->properties; |
|
5297 |
if (prop) { |
|
5298 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5299 |
#ifdef SUPERDEBUG |
1344 | 5300 |
cp = XGetAtomName(dpy, prop->name); |
5301 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5302 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5303 |
#endif |
1344 | 5304 |
if (prop->name == XA_FULL_NAME) { |
5305 |
cp = XGetAtomName(dpy, prop->card32); |
|
5306 |
if (cp) { |
|
5307 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5308 |
#ifdef SUPERDEBUG |
1344 | 5309 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5310 |
#endif |
1344 | 5311 |
XFree(cp); |
5312 |
} |
|
5313 |
} else if (prop->name == fontAtom) { |
|
5314 |
cp = XGetAtomName(dpy, prop->card32); |
|
5315 |
if (cp) { |
|
5316 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5317 |
#ifdef SUPERDEBUG |
1344 | 5318 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5319 |
#endif |
1344 | 5320 |
XFree(cp); |
5321 |
} |
|
5322 |
} else if (prop->name == encodingAtom) { |
|
5323 |
cp = XGetAtomName(dpy, prop->card32); |
|
5324 |
if (cp) { |
|
5325 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5326 |
#ifdef SUPERDEBUG |
1344 | 5327 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5328 |
#endif |
1344 | 5329 |
XFree(cp); |
5330 |
} |
|
5331 |
} else if (prop->name == registryAtom) { |
|
5332 |
cp = XGetAtomName(dpy, prop->card32); |
|
5333 |
if (cp) { |
|
5334 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5335 |
#ifdef SUPERDEBUG |
1344 | 5336 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5337 |
#endif |
1344 | 5338 |
XFree(cp); |
5339 |
} |
|
5340 |
} else if (prop->name == charSetCollAtom) { |
|
5341 |
cp = XGetAtomName(dpy, prop->card32); |
|
5342 |
if (cp) { |
|
5343 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5344 |
#ifdef SUPERDEBUG |
1344 | 5345 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5346 |
#endif |
1344 | 5347 |
XFree(cp); |
5348 |
} |
|
5349 |
} |
|
5350 |
prop++; |
|
5351 |
} |
|
5352 |
} |
|
5353 |
} |
|
5354 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5355 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5356 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5357 |
^ self |
1344 | 5358 |
extractEncodingFromRegistry:registry |
5359 |
encoding:encoding |
|
5360 |
charSetCollections:charSetCollections |
|
5361 |
! |
|
5362 |
||
5363 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5364 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5365 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5366 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5367 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5368 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 5369 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5370 |
] ifFalse:[ |
1344 | 5371 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
5372 |
enc := encoding asLowercase asSymbol |
|
5373 |
] ifFalse:[ |
|
5374 |
charSets := charSetCollections. |
|
5375 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
5376 |
charSets := charSets asUppercase asCollectionOfWords. |
|
5377 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
5378 |
enc := #iso8859 |
|
5379 |
] ifFalse:[ |
|
5380 |
(charSets includes:'ISO8859') ifTrue:[ |
|
5381 |
enc := #iso8859 |
|
5382 |
] ifFalse:[ |
|
5383 |
(charSets includes:'ASCII') ifTrue:[ |
|
5384 |
enc := #ascii |
|
5385 |
] ifFalse:[ |
|
5386 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
5387 |
enc := #iso8859 |
|
5388 |
] |
|
5389 |
] |
|
5390 |
] |
|
5391 |
] |
|
5392 |
] |
|
5393 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5394 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5395 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5396 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5397 |
"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
|
5398 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5399 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5400 |
|
1344 | 5401 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5402 |
"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
|
5403 |
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
|
5404 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5405 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5406 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5407 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5408 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5409 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5410 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5411 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5412 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5413 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5414 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5415 |
|
1344 | 5416 |
fontMetricsOf:fontId into:aBlock |
991 | 5417 |
"evaluate aBlock, passing a fonts metrics as arguments" |
5418 |
||
5419 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5420 |
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
|
5421 |
res resX resY| |
991 | 5422 |
|
994 | 5423 |
%{ |
991 | 5424 |
XFontStruct *f; |
5425 |
int len; |
|
5426 |
||
5427 |
if (ISCONNECTED) { |
|
1344 | 5428 |
if (__isExternalAddress(fontId)) { |
5429 |
f = _FontVal(fontId); |
|
5430 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5431 |
#ifdef NOTDEF |
1344 | 5432 |
char *cp; |
5433 |
XFontProp *prop; |
|
5434 |
||
5435 |
n = f->n_properties; |
|
5436 |
prop = f->properties; |
|
5437 |
||
5438 |
if (prop) { |
|
5439 |
while (n--) { |
|
5440 |
if (prop->name == RESOLUTION_X) { |
|
5441 |
resX = __MKSMALLINT(prop->card32); |
|
5442 |
} else if (prop->name == RESOLUTION_Y) { |
|
5443 |
resY = __MKSMALLINT(prop->card32); |
|
5444 |
} else if (prop->name == RESOLUTION) { |
|
5445 |
res = __MKSMALLINT(prop->card32); |
|
5446 |
} |
|
5447 |
prop++; |
|
5448 |
} |
|
5449 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5450 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5451 |
|
1344 | 5452 |
avgAscent = __MKSMALLINT(f->ascent); |
5453 |
avgDescent = __MKSMALLINT(f->descent); |
|
5454 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
5455 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
5456 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
5457 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
5458 |
BEGIN_INTERRUPTSBLOCKED |
|
5459 |
len = XTextWidth(f, " ", 1); |
|
5460 |
END_INTERRUPTSBLOCKED |
|
5461 |
avgWidth = __MKSMALLINT( len ); |
|
5462 |
} |
|
5463 |
} |
|
991 | 5464 |
} |
5465 |
%}. |
|
5466 |
encoding := self encodingOf:fontId. |
|
5467 |
aBlock value:encoding |
|
1344 | 5468 |
value:avgAscent |
5469 |
value:avgDescent |
|
5470 |
value:maxAscent |
|
5471 |
value:maxDescent |
|
5472 |
value:minWidth |
|
5473 |
value:maxWidth |
|
5474 |
value:avgWidth |
|
5475 |
! |
|
5476 |
||
5477 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5478 |
"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
|
5479 |
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
|
5480 |
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
|
5481 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5482 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5483 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5484 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5485 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5486 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5487 |
if (ISCONNECTED) { |
1344 | 5488 |
Display *dpy = myDpy; |
5489 |
||
5490 |
if (__isExternalAddress(fontId)) { |
|
5491 |
f = _FontVal(fontId); |
|
5492 |
if (f) { |
|
5493 |
char *cp; |
|
5494 |
XFontProp *prop; |
|
5495 |
Atom resolutionXAtom, resolutionYAtom; |
|
5496 |
int n; |
|
5497 |
||
5498 |
n = f->n_properties; |
|
5499 |
prop = f->properties; |
|
5500 |
||
5501 |
if (prop) { |
|
5502 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
5503 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
5504 |
||
5505 |
while (n--) { |
|
5506 |
if (prop->name == resolutionXAtom) { |
|
5507 |
resX = __MKSMALLINT(prop->card32); |
|
5508 |
} else if (prop->name == resolutionYAtom) { |
|
5509 |
resY = __MKSMALLINT(prop->card32); |
|
5510 |
} else if (prop->name == XA_RESOLUTION) { |
|
5511 |
res = __MKSMALLINT(prop->card32); |
|
5512 |
} |
|
5513 |
prop++; |
|
5514 |
} |
|
5515 |
} |
|
5516 |
} |
|
5517 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5518 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5519 |
%}. |
1046 | 5520 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 5521 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5522 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5523 |
res notNil ifTrue:[ |
1344 | 5524 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5525 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5526 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5527 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5528 |
|
1344 | 5529 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5530 |
"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
|
5531 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5532 |
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
|
5533 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5534 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5535 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5536 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5537 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5538 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5539 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5540 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5541 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5542 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5543 |
if (ISCONNECTED) { |
1344 | 5544 |
Display *dpy = myDpy; |
5545 |
||
5546 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5547 |
||
5548 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5549 |
|
1344 | 5550 |
f = _FontVal(aFontId); |
5551 |
if (f) { |
|
5552 |
n = f->n_properties; |
|
5553 |
prop = f->properties; |
|
5554 |
if (prop) { |
|
5555 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5556 |
#ifdef SUPERDEBUG |
1344 | 5557 |
cp = XGetAtomName(dpy, prop->name); |
5558 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5559 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5560 |
#endif |
1344 | 5561 |
if (prop->name == XA_FULL_NAME) { |
5562 |
cp = XGetAtomName(dpy, prop->card32); |
|
5563 |
if (cp) { |
|
5564 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5565 |
#ifdef SUPERDEBUG |
1344 | 5566 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5567 |
#endif |
1344 | 5568 |
XFree(cp); |
5569 |
} |
|
5570 |
} |
|
5571 |
if (prop->name == fontAtom) { |
|
5572 |
cp = XGetAtomName(dpy, prop->card32); |
|
5573 |
if (cp) { |
|
5574 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5575 |
#ifdef SUPERDEBUG |
1344 | 5576 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5577 |
#endif |
1344 | 5578 |
XFree(cp); |
5579 |
} |
|
5580 |
} |
|
5581 |
prop++; |
|
5582 |
} |
|
5583 |
} |
|
5584 |
} |
|
5585 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5586 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5587 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5588 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 5589 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5590 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5591 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5592 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5593 |
|
1344 | 5594 |
getAvailableFontsMatching:pattern |
295 | 5595 |
"return an Array filled with font names matching aPattern" |
5596 |
||
5597 |
%{ /* UNLIMITEDSTACK */ |
|
5598 |
||
5599 |
int nnames = 1500; |
|
5600 |
int available = nnames + 1; |
|
5601 |
char **fonts; |
|
5602 |
OBJ arr, str; |
|
5603 |
int i; |
|
5604 |
||
5605 |
if (ISCONNECTED) { |
|
1344 | 5606 |
if (__isString(pattern)) { |
5607 |
for (;;) { |
|
5608 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
5609 |
if ((fonts == NULL) || (available < nnames)) break; |
|
5610 |
XFreeFontNames(fonts); |
|
5611 |
nnames = available * 2; |
|
5612 |
} |
|
5613 |
if (fonts == NULL) { |
|
5614 |
RETURN ( nil ); |
|
5615 |
} |
|
5616 |
/* |
|
5617 |
* now, that we know the number of font names, |
|
5618 |
* create the array ... |
|
5619 |
*/ |
|
5620 |
arr = __ARRAY_NEW_INT(available); |
|
5621 |
if (! arr) { |
|
5622 |
RETURN (nil); |
|
5623 |
} |
|
5624 |
/* |
|
5625 |
* ... and fill it |
|
5626 |
*/ |
|
5627 |
for (i=0; i<available; i++) { |
|
5628 |
__PROTECT__(arr); |
|
5629 |
str = __MKSTRING(fonts[i]); |
|
5630 |
__UNPROTECT__(arr); |
|
5631 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
5632 |
} |
|
5633 |
RETURN (arr); |
|
5634 |
} |
|
295 | 5635 |
} |
5636 |
%}. |
|
5637 |
^ nil |
|
5638 |
! |
|
5639 |
||
1344 | 5640 |
getDefaultFont |
295 | 5641 |
"return a default font id - used when class Font cannot |
5642 |
find anything usable" |
|
5643 |
||
5644 |
^ self createFontFor:'fixed' |
|
5645 |
! |
|
5646 |
||
1344 | 5647 |
getFontWithFamily:familyString face:faceString |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5648 |
style:styleArgString size:sizeArg encoding:encoding |
295 | 5649 |
|
5650 |
"try to get the specified font, if not available, try next smaller |
|
5651 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
5652 |
as family and the other parameters as nil. For example, the cursor font |
|
5653 |
can be aquired that way." |
|
5654 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5655 |
|styleString theName theId xlatedStyle |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5656 |
id spacing encodingMatch registryMatch idx| |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5657 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5658 |
styleString := styleArgString. |
295 | 5659 |
|
5660 |
"special: if face is nil, allow access to X-fonts" |
|
5661 |
faceString isNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5662 |
sizeArg notNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5663 |
theName := familyString , '-' , sizeArg printString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5664 |
] ifFalse:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5665 |
theName := familyString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5666 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5667 |
theName isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5668 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5669 |
mhmh - fall back to the default font |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5670 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5671 |
theName := 'fixed' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5672 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5673 |
theId := self createFontFor:theName. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5674 |
theId isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5675 |
theId := self getDefaultFont |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5676 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5677 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5678 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5679 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5680 |
"/ 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
|
5681 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5682 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5683 |
(styleString notNil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5684 |
and:[(styleString endsWith:'-narrow') |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5685 |
or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5686 |
|i| |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5687 |
i := styleString lastIndexOf:$-. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5688 |
spacing := styleString copyFrom:(i+1). |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5689 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5690 |
] ifFalse:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5691 |
spacing := 'normal'. |
295 | 5692 |
]. |
5693 |
||
5694 |
xlatedStyle := styleString. |
|
5695 |
xlatedStyle notNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5696 |
xlatedStyle := xlatedStyle first asString |
295 | 5697 |
]. |
5698 |
||
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5699 |
encodingMatch := encoding. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5700 |
registryMatch := '*'. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5701 |
encoding isNil ifTrue:[ |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5702 |
encodingMatch := '*'. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5703 |
] ifFalse:[ |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5704 |
idx := encoding indexOf:$-. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5705 |
idx ~~ 0 ifTrue:[ |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5706 |
encodingMatch := encoding copyTo:idx - 1. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5707 |
registryMatch := encoding copyFrom:idx + 1 |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5708 |
]. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5709 |
]. |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5710 |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5711 |
id := self |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5712 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5713 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5714 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5715 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5716 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5717 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5718 |
size:sizeArg |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5719 |
registry:encodingMatch |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5720 |
encoding:registryMatch. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5721 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5722 |
id isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5723 |
(encodingMatch notNil and:[encodingMatch ~= '*']) ifTrue:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5724 |
"/ too stupid: encodings come in both cases |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5725 |
"/ and X does not ignore case |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5726 |
"/ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5727 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5728 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5729 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5730 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5731 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5732 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5733 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5734 |
size:sizeArg |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5735 |
registry:encodingMatch asUppercase |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5736 |
encoding:registryMatch. |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5737 |
id isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5738 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5739 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5740 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5741 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5742 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5743 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5744 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5745 |
size:sizeArg |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5746 |
registry:encodingMatch asLowercase |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5747 |
encoding:registryMatch. |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5748 |
] |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5749 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5750 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5751 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5752 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5753 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5754 |
"Modified: 10.4.1997 / 19:20:06 / cg" |
295 | 5755 |
! |
5756 |
||
1344 | 5757 |
getFontWithFoundry:foundry family:family weight:weight |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5758 |
slant:slant spacing:spc pixelSize:pSize size:size |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5759 |
registry:registry encoding:encoding |
295 | 5760 |
|
5761 |
"get the specified font, if not available, return nil. |
|
5762 |
This is the new font creation method - all others will be changed to |
|
5763 |
use this entry. |
|
5764 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
5765 |
||
5766 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
5767 |
family: 'helvetica' 'courier' 'times' ... |
|
5768 |
weight: 'bold' 'medium' 'demi' ... |
|
5769 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
5770 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
5771 |
pixelSize: 16,18 ... usually left empty |
|
5772 |
size: size in point (1/72th of an inch) |
|
5773 |
registry: iso8859, sgi ... '*' |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5774 |
encoding: registry specific encoding (usually '*') |
295 | 5775 |
" |
5776 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5777 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5778 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 5779 |
pSizeMatch registryMatch encodingMatch| |
295 | 5780 |
|
5781 |
"this works only on 'Release >= 3' - X-servers" |
|
5782 |
"name is: |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5783 |
-foundry-family -weight -slant- |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5784 |
sony helvetica bold r |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5785 |
adobe courier medium i |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5786 |
msic fixed o |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5787 |
... ... |
295 | 5788 |
" |
5789 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5790 |
size isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5791 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5792 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5793 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5794 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5795 |
foundry isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5796 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5797 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5798 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5799 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5800 |
family isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5801 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5802 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5803 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5804 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5805 |
weight isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5806 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5807 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5808 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5809 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5810 |
slant isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5811 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5812 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5813 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5814 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5815 |
spc isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5816 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5817 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5818 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5819 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5820 |
pSize isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5821 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5822 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5823 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5824 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5825 |
registry isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5826 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5827 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5828 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5829 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5830 |
encoding isNil ifTrue:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5831 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5832 |
] ifFalse:[ |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5833 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5834 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5835 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5836 |
theName := ('-' , foundryMatch, |
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5837 |
'-' , familyMatch, |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5838 |
'-' , weightMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5839 |
'-' , slantMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5840 |
'-' , spcMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5841 |
'-*' , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5842 |
'-' , pSizeMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5843 |
'-' , sizeMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5844 |
'-*-*-*-*' , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5845 |
'-' , registryMatch , |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5846 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5847 |
|
697 | 5848 |
"/ Transcript showCR:theName; endEntry. |
295 | 5849 |
|
5850 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5851 |
|
295 | 5852 |
|
5853 |
" |
|
5854 |
Display getFontWithFoundry:'*' |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5855 |
family:'courier' |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5856 |
weight:'medium' |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5857 |
slant:'r' |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5858 |
spacing:nil |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5859 |
pixelSize:nil |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5860 |
size:13 |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5861 |
registry:'iso8859' |
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5862 |
encoding:'*' |
295 | 5863 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5864 |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
5865 |
"Modified: 10.4.1997 / 19:15:44 / cg" |
295 | 5866 |
! |
5867 |
||
1344 | 5868 |
listOfAvailableFonts |
295 | 5869 |
"return a list with all available fonts on this display. |
5870 |
Since this takes a long time, keep the result of the query for the |
|
5871 |
next time. The elements of the returned collection are instances of |
|
5872 |
FontDescription." |
|
5873 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
5874 |
|"stream aName fntDescr" names| |
295 | 5875 |
|
5876 |
listOfXFonts isNil ifTrue:[ |
|
5877 |
"/ |
|
5878 |
"/ old code; using a pipe to xlsfonts |
|
5879 |
"/ |
|
5880 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
5881 |
"/ stream isNil ifTrue:[^ nil]. |
|
5882 |
"/ listOfXFonts := OrderedCollection new. |
|
5883 |
"/ [stream atEnd] whileFalse:[ |
|
5884 |
"/ aName := stream nextLine. |
|
5885 |
"/ aName notNil ifTrue:[ |
|
5886 |
"/ self decomposeXFontName:aName into: |
|
5887 |
"/ [:family :face :style :size :coding | |
|
5888 |
"/ family notNil ifTrue:[ |
|
5889 |
"/ fntDescr := FontDescription |
|
5890 |
"/ family:family |
|
5891 |
"/ face:face |
|
5892 |
"/ style:style |
|
5893 |
"/ size:size |
|
5894 |
"/ encoding:coding. |
|
5895 |
"/ listOfXFonts add:fntDescr |
|
5896 |
"/ ] |
|
5897 |
"/ ] |
|
5898 |
"/ ] |
|
5899 |
"/ ]. |
|
5900 |
"/ stream close. |
|
5901 |
"/ "if xlsfont is broken ... (hey sco)" |
|
5902 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
5903 |
"/ listOfXFonts := nil |
|
5904 |
"/ ] ifFalse:[ |
|
5905 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
5906 |
"/ ]. |
|
5907 |
||
1344 | 5908 |
"/ |
5909 |
"/ new code: |
|
5910 |
"/ use new primitive to get font names; |
|
5911 |
"/ this is much faster, and also works on systems where |
|
5912 |
"/ a) xlsfonts is broken (sco) |
|
5913 |
"/ b) xlsfonts is not available (aix) |
|
5914 |
"/ |
|
5915 |
names := self getAvailableFontsMatching:'*'. |
|
5916 |
names isNil ifTrue:[ |
|
5917 |
"no names returned ..." |
|
5918 |
^ nil |
|
5919 |
]. |
|
5920 |
listOfXFonts := names collect:[:aName | |
|
5921 |
|fntDescr| |
|
5922 |
||
5923 |
(self decomposeXFontName:aName into: |
|
5924 |
[:family :face :style :size :coding | |
|
5925 |
family notNil ifTrue:[ |
|
5926 |
fntDescr := FontDescription |
|
5927 |
family:family |
|
5928 |
face:face |
|
5929 |
style:style |
|
5930 |
size:size |
|
5931 |
encoding:coding. |
|
5932 |
] ifFalse:[ |
|
5933 |
fntDescr := FontDescription |
|
5934 |
name:aName |
|
5935 |
] |
|
5936 |
] |
|
5937 |
) ifFalse:[ |
|
5938 |
fntDescr := FontDescription name:aName. |
|
5939 |
]. |
|
5940 |
fntDescr |
|
5941 |
]. |
|
295 | 5942 |
|
5943 |
]. |
|
5944 |
^ listOfXFonts |
|
5945 |
||
5946 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5947 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5948 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5949 |
Display getAvailableFontsMatching:'*'. |
295 | 5950 |
" |
5951 |
||
5952 |
"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
|
5953 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5954 |
! |
5955 |
||
1344 | 5956 |
releaseFont:aFontId |
295 | 5957 |
|
5958 |
%{ /* NOCONTEXT */ |
|
5959 |
||
5960 |
XFontStruct *f; |
|
5961 |
||
1212 | 5962 |
if (! ISCONNECTED) { |
1344 | 5963 |
RETURN ( self ); |
1212 | 5964 |
} |
5965 |
||
5966 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 5967 |
f = _FontVal(aFontId); |
5968 |
if (f) { |
|
5969 |
BEGIN_INTERRUPTSBLOCKED |
|
5970 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5971 |
#ifdef COUNT_RESOURCES |
1344 | 5972 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5973 |
#endif |
1344 | 5974 |
END_INTERRUPTSBLOCKED |
5975 |
RETURN ( self ); |
|
5976 |
} |
|
295 | 5977 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5978 |
%}. |
295 | 5979 |
self primitiveFailed |
5980 |
! |
|
5981 |
||
1344 | 5982 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5983 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5984 |
on this display. |
|
5985 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5986 |
||
5987 |
|sizes| |
|
5988 |
||
466 | 5989 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5990 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 5991 |
"special: in X11R5 and above, size 0 means: |
5992 |
there are scaled versions in all sizes available" |
|
5993 |
||
5994 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 5995 |
]. |
5996 |
^ sizes |
|
5997 |
||
5998 |
" |
|
5999 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
6000 |
" |
|
466 | 6001 |
|
6002 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 6003 |
! |
6004 |
||
1344 | 6005 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 6006 |
|
6007 |
%{ /* NOCONTEXT */ |
|
6008 |
||
6009 |
XFontStruct *f; |
|
6010 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6011 |
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
|
6012 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6013 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6014 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6015 |
int nInstBytes; |
295 | 6016 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6017 |
if (ISCONNECTED) { |
1344 | 6018 |
if (__bothSmallInteger(index1, index2) |
6019 |
&& __isExternalAddress(aFontId) |
|
6020 |
&& __isNonNilObject(aString)) { |
|
6021 |
f = _FontVal(aFontId); |
|
6022 |
if (! f) goto fail; |
|
6023 |
||
6024 |
i1 = __intVal(index1) - 1; |
|
6025 |
cls = __qClass(aString); |
|
6026 |
||
6027 |
if (i1 >= 0) { |
|
6028 |
i2 = __intVal(index2) - 1; |
|
6029 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6030 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 6031 |
} |
6032 |
||
6033 |
cp = (char *) _stringVal(aString); |
|
6034 |
l = i2 - i1 + 1; |
|
6035 |
||
6036 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6037 |
n = _stringSize(aString); |
|
6038 |
if (i2 < n) { |
|
6039 |
cp += i1; |
|
6040 |
BEGIN_INTERRUPTSBLOCKED |
|
6041 |
len = XTextWidth(f, cp, l); |
|
6042 |
END_INTERRUPTSBLOCKED |
|
6043 |
RETURN ( __MKSMALLINT(len) ); |
|
6044 |
} |
|
6045 |
} |
|
6046 |
||
6047 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6048 |
cp += nInstBytes; |
|
6049 |
||
6050 |
if (__isBytes(aString)) { |
|
6051 |
n = __byteArraySize(aString) - nInstBytes; |
|
6052 |
if (i2 < n) { |
|
6053 |
cp += i1; |
|
6054 |
BEGIN_INTERRUPTSBLOCKED |
|
6055 |
len = XTextWidth(f, cp, l); |
|
6056 |
END_INTERRUPTSBLOCKED |
|
6057 |
RETURN ( __MKSMALLINT(len) ); |
|
6058 |
} |
|
6059 |
} |
|
6060 |
||
6061 |
/* TWOBYTESTRINGS */ |
|
6062 |
if (__isWords(aString)) { |
|
6063 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6064 |
||
6065 |
if (i2 < n) { |
|
6066 |
union { |
|
6067 |
char b[2]; |
|
6068 |
unsigned short s; |
|
6069 |
} u; |
|
6070 |
int i; |
|
6071 |
XChar2b *cp2 = (XChar2b *)0; |
|
6072 |
int mustFree = 0; |
|
6073 |
||
6074 |
cp += (i1 * 2); |
|
6075 |
if (l > 1000) l = 1000; |
|
6076 |
||
6077 |
/* |
|
6078 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6079 |
* X expects them MSB first |
|
6080 |
* convert as required |
|
6081 |
*/ |
|
6082 |
||
6083 |
u.s = 0x1234; |
|
6084 |
if (u.b[0] != 0x12) { |
|
6085 |
if (l <= NLOCALBUFFER) { |
|
6086 |
cp2 = xlatebuffer; |
|
6087 |
} else { |
|
6088 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
6089 |
mustFree = 1; |
|
6090 |
} |
|
6091 |
for (i=0; i<l; i++) { |
|
6092 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6093 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6094 |
} |
|
6095 |
cp = (char *) cp2; |
|
6096 |
} |
|
6097 |
BEGIN_INTERRUPTSBLOCKED |
|
6098 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
6099 |
END_INTERRUPTSBLOCKED |
|
6100 |
||
6101 |
if (mustFree) { |
|
6102 |
free(cp2); |
|
6103 |
} |
|
6104 |
||
6105 |
RETURN ( __MKSMALLINT(len) ); |
|
6106 |
} |
|
6107 |
} |
|
6108 |
} |
|
6109 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6110 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6111 |
#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
|
6112 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6113 |
%}. |
295 | 6114 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6115 |
^ 0 |
295 | 6116 |
! |
6117 |
||
1344 | 6118 |
widthOf:aString inFont:aFontId |
295 | 6119 |
|
6120 |
%{ /* NOCONTEXT */ |
|
6121 |
||
6122 |
XFontStruct *f; |
|
6123 |
char *cp; |
|
6124 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
6125 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6126 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6127 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6128 |
int nInstBytes; |
295 | 6129 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6130 |
if (ISCONNECTED) { |
1344 | 6131 |
if (__isExternalAddress(aFontId) |
6132 |
&& __isNonNilObject(aString)) { |
|
6133 |
f = _FontVal(aFontId); |
|
6134 |
if (! f) goto fail; |
|
6135 |
||
6136 |
cls = __qClass(aString); |
|
6137 |
||
6138 |
cp = (char *)_stringVal(aString); |
|
6139 |
||
6140 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6141 |
n = _stringSize(aString); |
|
6142 |
BEGIN_INTERRUPTSBLOCKED |
|
6143 |
len = XTextWidth(f, cp, n); |
|
6144 |
END_INTERRUPTSBLOCKED |
|
6145 |
RETURN ( __MKSMALLINT(len) ); |
|
6146 |
} |
|
6147 |
||
6148 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6149 |
cp += nInstBytes; |
|
6150 |
||
6151 |
if (__isBytes(aString)) { |
|
6152 |
n = __byteArraySize(aString) - nInstBytes; |
|
6153 |
||
6154 |
BEGIN_INTERRUPTSBLOCKED |
|
6155 |
len = XTextWidth(f, cp, n); |
|
6156 |
END_INTERRUPTSBLOCKED |
|
6157 |
RETURN ( __MKSMALLINT(len) ); |
|
6158 |
} |
|
6159 |
||
6160 |
/* TWOBYTESTRINGS */ |
|
6161 |
if (__isWords(aString)) { |
|
6162 |
union { |
|
6163 |
char b[2]; |
|
6164 |
unsigned short s; |
|
6165 |
} u; |
|
6166 |
int i; |
|
6167 |
XChar2b *cp2; |
|
6168 |
int mustFree = 0; |
|
6169 |
||
6170 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6171 |
if (n > 1000) n = 1000; |
|
6172 |
||
6173 |
/* |
|
6174 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6175 |
* X expects them MSB first |
|
6176 |
* convert as required |
|
6177 |
*/ |
|
6178 |
||
6179 |
u.s = 0x1234; |
|
6180 |
if (u.b[0] != 0x12) { |
|
6181 |
if (n <= NLOCALBUFFER) { |
|
6182 |
cp2 = xlatebuffer; |
|
6183 |
} else { |
|
6184 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
6185 |
mustFree = 1; |
|
6186 |
} |
|
6187 |
||
6188 |
for (i=0; i<n; i++) { |
|
6189 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6190 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6191 |
} |
|
6192 |
cp = (char *) cp2; |
|
6193 |
} |
|
6194 |
||
6195 |
BEGIN_INTERRUPTSBLOCKED |
|
6196 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
6197 |
END_INTERRUPTSBLOCKED |
|
6198 |
||
6199 |
if (mustFree) { |
|
6200 |
free(cp2); |
|
6201 |
} |
|
6202 |
||
6203 |
RETURN ( __MKSMALLINT(len) ); |
|
6204 |
} |
|
6205 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6206 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6207 |
#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
|
6208 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6209 |
%}. |
295 | 6210 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6211 |
^ 0 |
295 | 6212 |
! ! |
6213 |
||
6214 |
!XWorkstation methodsFor:'grabbing '! |
|
6215 |
||
1344 | 6216 |
allowEvents:mode |
295 | 6217 |
%{ /* NOCONTEXT */ |
6218 |
||
6219 |
int _mode, ok = 1; |
|
6220 |
||
6221 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 6222 |
_mode = AsyncPointer; |
295 | 6223 |
else if (mode == @symbol(syncPointer)) |
1344 | 6224 |
_mode = SyncPointer; |
295 | 6225 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 6226 |
_mode = AsyncKeyboard; |
295 | 6227 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 6228 |
_mode = SyncKeyboard; |
295 | 6229 |
else if (mode == @symbol(syncBoth)) |
1344 | 6230 |
_mode = SyncBoth; |
295 | 6231 |
else if (mode == @symbol(asyncBoth)) |
1344 | 6232 |
_mode = AsyncBoth; |
295 | 6233 |
else if (mode == @symbol(replayPointer)) |
1344 | 6234 |
_mode = ReplayPointer; |
295 | 6235 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 6236 |
_mode = ReplayKeyboard; |
295 | 6237 |
else |
1344 | 6238 |
ok = 0; |
295 | 6239 |
|
6240 |
if (ok) { |
|
1344 | 6241 |
if (ISCONNECTED) { |
6242 |
BEGIN_INTERRUPTSBLOCKED |
|
6243 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
6244 |
END_INTERRUPTSBLOCKED |
|
6245 |
RETURN (self); |
|
6246 |
} |
|
295 | 6247 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6248 |
%}. |
295 | 6249 |
self primitiveFailed |
6250 |
! |
|
6251 |
||
1344 | 6252 |
grabKeyboardIn:aWindowId |
295 | 6253 |
"grab the keyboard" |
6254 |
||
6255 |
%{ /* NOCONTEXT */ |
|
6256 |
int result, ok; |
|
6257 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6258 |
if (ISCONNECTED) { |
1344 | 6259 |
if (__isExternalAddress(aWindowId)) { |
6260 |
BEGIN_INTERRUPTSBLOCKED |
|
6261 |
result = XGrabKeyboard(myDpy, |
|
6262 |
_WindowVal(aWindowId), |
|
6263 |
True /* False */, |
|
6264 |
GrabModeAsync, |
|
6265 |
GrabModeAsync, |
|
6266 |
CurrentTime); |
|
6267 |
END_INTERRUPTSBLOCKED |
|
6268 |
ok = 0; |
|
6269 |
switch(result) { |
|
6270 |
case AlreadyGrabbed: |
|
6271 |
if (@global(ErrorPrinting) == true) { |
|
6272 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
6273 |
} |
|
6274 |
break; |
|
6275 |
case GrabNotViewable: |
|
6276 |
if (@global(ErrorPrinting) == true) { |
|
6277 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
6278 |
} |
|
6279 |
break; |
|
6280 |
case GrabInvalidTime: |
|
6281 |
if (@global(ErrorPrinting) == true) { |
|
6282 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
6283 |
} |
|
6284 |
break; |
|
6285 |
case GrabFrozen: |
|
6286 |
if (@global(ErrorPrinting) == true) { |
|
6287 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
6288 |
} |
|
6289 |
break; |
|
6290 |
default: |
|
6291 |
ok = 1; |
|
6292 |
break; |
|
6293 |
} |
|
6294 |
if (! ok) { |
|
6295 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6296 |
RETURN (false); |
|
6297 |
} |
|
6298 |
||
6299 |
RETURN ( true ); |
|
6300 |
} |
|
295 | 6301 |
} |
1183 | 6302 |
%}. |
295 | 6303 |
self primitiveFailed |
6304 |
! |
|
6305 |
||
1344 | 6306 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 6307 |
"grap the pointer - return true if ok" |
6308 |
||
6309 |
%{ /* NOCONTEXT */ |
|
6310 |
||
6311 |
int result, ok; |
|
6312 |
Window confineWin; |
|
6313 |
Cursor curs; |
|
6314 |
int pointer_mode, keyboard_mode; |
|
6315 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6316 |
if (ISCONNECTED) { |
1344 | 6317 |
if (__isExternalAddress(aWindowId)) { |
6318 |
if (__isExternalAddress(confineId)) |
|
6319 |
confineWin = _WindowVal(confineId); |
|
6320 |
else |
|
6321 |
confineWin = (Window) None; |
|
6322 |
||
6323 |
if (__isExternalAddress(aCursorId)) |
|
6324 |
curs = _CursorVal(aCursorId); |
|
6325 |
else |
|
6326 |
curs = (Cursor) None; |
|
6327 |
||
6328 |
if (pMode == @symbol(sync)) |
|
6329 |
pointer_mode = GrabModeSync; |
|
6330 |
else |
|
6331 |
pointer_mode = GrabModeAsync; |
|
6332 |
||
6333 |
if (kMode == @symbol(sync)) |
|
6334 |
keyboard_mode = GrabModeSync; |
|
6335 |
else |
|
6336 |
keyboard_mode = GrabModeAsync; |
|
6337 |
||
6338 |
BEGIN_INTERRUPTSBLOCKED |
|
6339 |
result = XGrabPointer(myDpy, |
|
6340 |
_WindowVal(aWindowId), |
|
6341 |
False, |
|
6342 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
6343 |
pointer_mode, keyboard_mode, |
|
6344 |
confineWin, |
|
6345 |
curs, |
|
6346 |
CurrentTime); |
|
6347 |
END_INTERRUPTSBLOCKED |
|
6348 |
||
6349 |
ok = 0; |
|
6350 |
switch (result) { |
|
6351 |
case AlreadyGrabbed: |
|
6352 |
if (@global(ErrorPrinting) == true) { |
|
6353 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
6354 |
} |
|
6355 |
break; |
|
6356 |
case GrabNotViewable: |
|
6357 |
if (@global(ErrorPrinting) == true) { |
|
6358 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
6359 |
} |
|
6360 |
break; |
|
6361 |
case GrabInvalidTime: |
|
6362 |
if (@global(ErrorPrinting) == true) { |
|
6363 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
6364 |
} |
|
6365 |
break; |
|
6366 |
case GrabFrozen: |
|
6367 |
if (@global(ErrorPrinting) == true) { |
|
6368 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
6369 |
} |
|
6370 |
break; |
|
6371 |
default: |
|
6372 |
ok = 1; |
|
6373 |
break; |
|
6374 |
} |
|
6375 |
||
6376 |
if (! ok) { |
|
6377 |
XUngrabPointer(myDpy, CurrentTime); |
|
6378 |
RETURN (false); |
|
6379 |
} |
|
6380 |
RETURN ( true ); |
|
6381 |
} |
|
295 | 6382 |
} |
1183 | 6383 |
%}. |
295 | 6384 |
self primitiveFailed |
6385 |
! |
|
6386 |
||
1344 | 6387 |
ungrabKeyboard |
295 | 6388 |
"release the keyboard" |
6389 |
||
6390 |
%{ /* NOCONTEXT */ |
|
6391 |
||
6392 |
if (ISCONNECTED) { |
|
1344 | 6393 |
BEGIN_INTERRUPTSBLOCKED |
6394 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6395 |
XSync(myDpy, 0); |
|
6396 |
END_INTERRUPTSBLOCKED |
|
295 | 6397 |
} |
6398 |
%}. |
|
6399 |
activeKeyboardGrab := nil |
|
6400 |
! |
|
6401 |
||
1344 | 6402 |
ungrabPointer |
295 | 6403 |
"release the pointer" |
6404 |
||
6405 |
%{ /* NOCONTEXT */ |
|
6406 |
||
6407 |
if (ISCONNECTED) { |
|
1344 | 6408 |
BEGIN_INTERRUPTSBLOCKED |
6409 |
XUngrabPointer(myDpy, CurrentTime); |
|
6410 |
XSync(myDpy, 0); |
|
6411 |
END_INTERRUPTSBLOCKED |
|
295 | 6412 |
} |
6413 |
%}. |
|
6414 |
activePointerGrab := nil |
|
6415 |
! ! |
|
6416 |
||
6417 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
6418 |
||
1344 | 6419 |
noClipIn:aGCId |
295 | 6420 |
"disable clipping rectangle" |
6421 |
||
6422 |
%{ /* NOCONTEXT */ |
|
6423 |
||
6424 |
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
|
6425 |
GC gc; |
295 | 6426 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6427 |
if (ISCONNECTED) { |
1344 | 6428 |
if (__isExternalAddress(aGCId)) { |
6429 |
gc = _GCVal(aGCId); |
|
6430 |
gcv.clip_mask = None; |
|
6431 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
6432 |
RETURN ( self ); |
|
6433 |
} |
|
295 | 6434 |
} |
6435 |
%}. |
|
6436 |
self primitiveFailed |
|
6437 |
! |
|
6438 |
||
1344 | 6439 |
setBackground:bgColorIndex in:aGCId |
295 | 6440 |
"set background color to be drawn with" |
6441 |
||
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 |
if (ISCONNECTED) { |
1344 | 6445 |
if (__isExternalAddress(aGCId) |
6446 |
&& __isSmallInteger(bgColorIndex)) { |
|
6447 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
|
6448 |
RETURN ( self ); |
|
6449 |
} |
|
295 | 6450 |
} |
6451 |
%}. |
|
6452 |
self primitiveFailed |
|
6453 |
! |
|
6454 |
||
1344 | 6455 |
setBitmapMask:aBitmapId in:aGCId |
295 | 6456 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
6457 |
||
6458 |
%{ /* NOCONTEXT */ |
|
6459 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6460 |
GC gc; |
295 | 6461 |
Pixmap bitmap; |
6462 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6463 |
if (ISCONNECTED) { |
1344 | 6464 |
Display *dpy = myDpy; |
6465 |
||
6466 |
if (__isExternalAddress(aGCId)) { |
|
6467 |
gc = _GCVal(aGCId); |
|
6468 |
if (__isExternalAddress(aBitmapId)) { |
|
6469 |
bitmap = _PixmapVal(aBitmapId); |
|
6470 |
XSetStipple(dpy, gc, bitmap); |
|
6471 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
6472 |
RETURN ( self ); |
|
6473 |
} |
|
6474 |
if (aBitmapId == nil) { |
|
6475 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6476 |
RETURN ( self ); |
|
6477 |
} |
|
6478 |
} |
|
295 | 6479 |
} |
6480 |
%}. |
|
6481 |
self primitiveFailed |
|
6482 |
! |
|
6483 |
||
1344 | 6484 |
setClipByChildren:aBool in:aGCId |
295 | 6485 |
"enable/disable drawing into child views" |
6486 |
||
6487 |
%{ /* NOCONTEXT */ |
|
6488 |
||
6489 |
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
|
6490 |
GC gc; |
295 | 6491 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6492 |
if (ISCONNECTED) { |
1344 | 6493 |
if (__isExternalAddress(aGCId)) { |
6494 |
gc = _GCVal(aGCId); |
|
6495 |
if (aBool == true) |
|
6496 |
gcv.subwindow_mode = ClipByChildren; |
|
6497 |
else |
|
6498 |
gcv.subwindow_mode = IncludeInferiors; |
|
6499 |
||
6500 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
6501 |
RETURN ( self ); |
|
6502 |
} |
|
295 | 6503 |
} |
6504 |
%}. |
|
6505 |
self primitiveFailed |
|
6506 |
! |
|
6507 |
||
1344 | 6508 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
295 | 6509 |
"clip to a rectangle" |
6510 |
||
6511 |
%{ /* NOCONTEXT */ |
|
6512 |
||
6513 |
XRectangle r; |
|
6514 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6515 |
if (ISCONNECTED) { |
1344 | 6516 |
if (__isExternalAddress(aGCId) |
6517 |
&& __bothSmallInteger(clipX, clipY) |
|
6518 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
6519 |
r.x = __intVal(clipX); |
|
6520 |
r.y = __intVal(clipY); |
|
6521 |
r.width = __intVal(clipWidth); |
|
6522 |
r.height = __intVal(clipHeight); |
|
6523 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
6524 |
RETURN ( self ); |
|
6525 |
} |
|
295 | 6526 |
} |
6527 |
%}. |
|
6528 |
self primitiveFailed |
|
6529 |
! |
|
6530 |
||
1344 | 6531 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 6532 |
"set line attributes" |
6533 |
||
6534 |
%{ /* NOCONTEXT */ |
|
6535 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6536 |
if (ISCONNECTED) { |
1344 | 6537 |
if (__isExternalAddress(aGCId) |
6538 |
&& __isSmallInteger(offset) |
|
6539 |
&& __isByteArray(dashList)) { |
|
6540 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
6541 |
__intVal(offset), |
|
6542 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
6543 |
__byteArraySize(dashList)); |
|
6544 |
RETURN ( self ); |
|
6545 |
} |
|
788 | 6546 |
} |
6547 |
bad: ; |
|
6548 |
%}. |
|
6549 |
" |
|
6550 |
either aGCId is invalid, |
|
6551 |
and/or dashList is not a byteArray |
|
6552 |
and/or offset is not a smallInteger |
|
6553 |
" |
|
6554 |
self primitiveFailed |
|
6555 |
! |
|
6556 |
||
1344 | 6557 |
setFont:aFontId in:aGCId |
295 | 6558 |
"set font to be drawn in" |
6559 |
||
6560 |
%{ /* NOCONTEXT */ |
|
6561 |
||
6562 |
XFontStruct *f; |
|
6563 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6564 |
if (ISCONNECTED) { |
1344 | 6565 |
if (__isExternalAddress(aFontId) |
6566 |
&& __isExternalAddress(aGCId)) { |
|
6567 |
f = (XFontStruct *) _FontVal(aFontId); |
|
6568 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
6569 |
RETURN ( self ); |
|
6570 |
} |
|
295 | 6571 |
} |
6572 |
%}. |
|
6573 |
" |
|
6574 |
aGCId and/or aFontId are invalid |
|
6575 |
" |
|
6576 |
self primitiveFailed |
|
6577 |
! |
|
6578 |
||
1344 | 6579 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 6580 |
"set foreground and background colors to be drawn with" |
6581 |
||
6582 |
%{ /* NOCONTEXT */ |
|
6583 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6584 |
GC gc; |
295 | 6585 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6586 |
if (ISCONNECTED) { |
1344 | 6587 |
Display *dpy = myDpy; |
6588 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
6589 |
&& __isExternalAddress(aGCId)) { |
|
6590 |
gc = _GCVal(aGCId); |
|
6591 |
||
6592 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
|
6593 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
6594 |
RETURN ( self ); |
|
6595 |
} |
|
295 | 6596 |
} |
6597 |
%}. |
|
6598 |
self primitiveFailed |
|
6599 |
! |
|
6600 |
||
1344 | 6601 |
setForeground:fgColorIndex in:aGCId |
295 | 6602 |
"set foreground color to be drawn with" |
6603 |
||
6604 |
%{ /* NOCONTEXT */ |
|
6605 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6606 |
if (ISCONNECTED) { |
1344 | 6607 |
if (__isExternalAddress(aGCId) |
6608 |
&& __isSmallInteger(fgColorIndex)) { |
|
6609 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
|
6610 |
RETURN ( self ); |
|
6611 |
} |
|
295 | 6612 |
} |
6613 |
%}. |
|
6614 |
self primitiveFailed |
|
6615 |
! |
|
6616 |
||
1344 | 6617 |
setFunction:aFunctionSymbol in:aGCId |
295 | 6618 |
"set alu function to be drawn with" |
6619 |
||
6620 |
%{ /* NOCONTEXT */ |
|
6621 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6622 |
GC gc; |
295 | 6623 |
int fun = -1; |
6624 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6625 |
if (ISCONNECTED) { |
1344 | 6626 |
if (__isExternalAddress(aGCId)) { |
6627 |
gc = _GCVal(aGCId); |
|
6628 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
6629 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
6630 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
6631 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
6632 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
6633 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
6634 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
6635 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
6636 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
6637 |
if (fun != -1) { |
|
6638 |
XSetFunction(myDpy, gc, fun); |
|
6639 |
RETURN ( self ); |
|
6640 |
} |
|
6641 |
} |
|
295 | 6642 |
} |
6643 |
%}. |
|
6644 |
" |
|
6645 |
either aGCId is not an integer, or an invalid symbol |
|
6646 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
6647 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
6648 |
" |
|
6649 |
self primitiveFailed |
|
6650 |
! |
|
6651 |
||
1344 | 6652 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 6653 |
"set or clear the graphics exposures flag" |
6654 |
||
6655 |
%{ /* NOCONTEXT */ |
|
6656 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6657 |
if (ISCONNECTED) { |
1344 | 6658 |
if (__isExternalAddress(aGCId)) { |
6659 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
6660 |
RETURN ( self ); |
|
6661 |
} |
|
295 | 6662 |
} |
6663 |
%} |
|
6664 |
. |
|
6665 |
self primitiveFailed |
|
6666 |
! |
|
6667 |
||
1344 | 6668 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
1455 | 6669 |
"set line attributes; |
6670 |
lineStyle must be one of #solid, #dashed or #doubleDashed; |
|
6671 |
capStyle one of: #notLast, #butt, #round or #projecting; |
|
6672 |
joinStyle one of: #miter, #bevel or #round." |
|
295 | 6673 |
|
6674 |
%{ /* NOCONTEXT */ |
|
6675 |
||
6676 |
int x_style, x_cap, x_join; |
|
6677 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6678 |
if (ISCONNECTED) { |
1455 | 6679 |
if (__isExternalAddress(aGCId) |
6680 |
&& __isSmallInteger(aNumber)) { |
|
6681 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
6682 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
6683 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
6684 |
else goto bad; |
|
6685 |
||
6686 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
6687 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
6688 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
6689 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
6690 |
else goto bad; |
|
6691 |
||
6692 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
6693 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
6694 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
6695 |
else goto bad; |
|
6696 |
||
6697 |
XSetLineAttributes(myDpy, |
|
6698 |
_GCVal(aGCId), __intVal(aNumber), |
|
6699 |
x_style, x_cap, x_join); |
|
6700 |
RETURN ( self ); |
|
6701 |
} |
|
295 | 6702 |
} |
6703 |
bad: ; |
|
6704 |
%}. |
|
6705 |
" |
|
6706 |
either aGCId is invalid, |
|
1455 | 6707 |
and/or lineWidth is not a smallInteger, |
295 | 6708 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
6709 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
6710 |
and/or joinStyle is none of #miter, #bevel, #round |
|
6711 |
" |
|
6712 |
self primitiveFailed |
|
6713 |
! |
|
6714 |
||
1344 | 6715 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 6716 |
"set the mask origin" |
6717 |
||
6718 |
%{ /* NOCONTEXT */ |
|
6719 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6720 |
if (ISCONNECTED) { |
1344 | 6721 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
6722 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
|
6723 |
RETURN ( self ); |
|
6724 |
} |
|
295 | 6725 |
} |
6726 |
%}. |
|
6727 |
self primitiveFailed |
|
6728 |
! |
|
6729 |
||
1344 | 6730 |
setPixmapMask:aPixmapId in:aGCId |
295 | 6731 |
"set or clear the drawing mask - a pixmap mask providing full color" |
6732 |
||
6733 |
%{ /* NOCONTEXT */ |
|
6734 |
||
6735 |
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
|
6736 |
GC gc; |
295 | 6737 |
Pixmap pixmap; |
6738 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6739 |
if (ISCONNECTED) { |
1344 | 6740 |
if (__isExternalAddress(aGCId)) { |
6741 |
gc = _GCVal(aGCId); |
|
6742 |
if (__isExternalAddress(aPixmapId)) { |
|
6743 |
pixmap = _PixmapVal(aPixmapId); |
|
6744 |
XSetTile(dpy, gc, pixmap); |
|
6745 |
XSetFillStyle(dpy, gc, FillTiled); |
|
6746 |
RETURN ( self ); |
|
6747 |
} |
|
6748 |
if (aPixmapId == nil) { |
|
6749 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6750 |
RETURN ( self ); |
|
6751 |
} |
|
6752 |
} |
|
295 | 6753 |
} |
6754 |
%}. |
|
6755 |
self primitiveFailed |
|
6756 |
! ! |
|
6757 |
||
6758 |
!XWorkstation methodsFor:'initialize / release'! |
|
6759 |
||
1344 | 6760 |
closeConnection |
295 | 6761 |
"close down the connection to the X-server" |
6762 |
||
6763 |
%{ /* NOCONTEXT */ |
|
6764 |
||
6765 |
if (ISCONNECTED) { |
|
1344 | 6766 |
Display *dpy = myDpy; |
6767 |
||
6768 |
BEGIN_INTERRUPTSBLOCKED |
|
6769 |
__INST(displayId) = nil; |
|
6770 |
XCloseDisplay(dpy); |
|
6771 |
END_INTERRUPTSBLOCKED |
|
295 | 6772 |
} |
6773 |
%} |
|
6774 |
! |
|
6775 |
||
1344 | 6776 |
initializeDefaultValues |
295 | 6777 |
buttonTranslation := ButtonTranslation. |
6778 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
6779 |
||
6780 |
self initializeModifierMappings |
|
6781 |
! |
|
6782 |
||
1344 | 6783 |
initializeEventBuffer |
295 | 6784 |
|sz| |
6785 |
||
6786 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6787 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 6788 |
%}. |
6789 |
eventBuffer isNil ifTrue:[ |
|
1344 | 6790 |
eventBuffer := ByteArray new:sz. |
295 | 6791 |
]. |
6792 |
! |
|
6793 |
||
1344 | 6794 |
initializeFor:aDisplayName |
295 | 6795 |
"initialize the receiver for a connection to an X-Server; |
6796 |
the argument, aDisplayName may be nil (for the default server from |
|
6797 |
DISPLAY-variable or command line argument) or the name of the server |
|
6798 |
as hostname:number" |
|
6799 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
6800 |
|dpyName index arguments| |
295 | 6801 |
|
6802 |
dpyName := aDisplayName. |
|
6803 |
dpyName isNil ifTrue:[ |
|
1344 | 6804 |
"look for a '-display xxx' argument" |
6805 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
6806 |
index := arguments indexOf:'-display'. |
|
6807 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
6808 |
dpyName := arguments at:index+1 |
|
6809 |
] |
|
6810 |
] |
|
295 | 6811 |
]. |
6812 |
%{ |
|
6813 |
int scr; |
|
6814 |
Display *dpy; |
|
6815 |
Visual *visual; |
|
6816 |
XVisualInfo viproto; |
|
6817 |
XVisualInfo *vip; /* retured info */ |
|
6818 |
int maxRGBDepth; |
|
6819 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6820 |
int rgbVisualID; |
|
6821 |
int nvi, i; |
|
6822 |
char *type, *nm; |
|
6823 |
int dummy; |
|
6824 |
OBJ dpyID; |
|
6825 |
||
555 | 6826 |
if (__INST(displayId) != nil) { |
1344 | 6827 |
/* |
6828 |
* already connected - you bad guy try to |
|
6829 |
* trick me manually ? |
|
6830 |
*/ |
|
6831 |
RETURN ( self ); |
|
295 | 6832 |
} |
6833 |
||
6834 |
BEGIN_INTERRUPTSBLOCKED |
|
6835 |
||
6836 |
if (__isString(dpyName)) |
|
1344 | 6837 |
nm = (char *)_stringVal(dpyName); |
295 | 6838 |
else { |
1344 | 6839 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
6840 |
nm = NULL; |
|
295 | 6841 |
} |
6842 |
dpy = XOpenDisplay(nm); |
|
6843 |
||
6844 |
if (dpy) { |
|
1344 | 6845 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 6846 |
|
6847 |
#ifdef SUPERDEBUG |
|
1344 | 6848 |
XSynchronize(dpy, 1); |
295 | 6849 |
#endif |
6850 |
||
1344 | 6851 |
XSetErrorHandler(__XErrorHandler__); |
295 | 6852 |
} |
6853 |
||
6854 |
END_INTERRUPTSBLOCKED |
|
6855 |
%}. |
|
6856 |
displayId isNil ifTrue:[ |
|
1344 | 6857 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
6858 |
^ nil |
|
295 | 6859 |
]. |
6860 |
||
6861 |
dispatching := false. |
|
6862 |
dispatchingExpose := false. |
|
6863 |
isSlow := false. |
|
6864 |
shiftDown := false. |
|
6865 |
ctrlDown := false. |
|
6866 |
metaDown := false. |
|
6867 |
altDown := false. |
|
6868 |
motionEventCompression := true. |
|
6869 |
buttonsPressed := 0. |
|
6870 |
displayName := dpyName. |
|
6871 |
||
6872 |
protocolsAtom := nil. |
|
6873 |
deleteWindowAtom := nil. |
|
6874 |
saveYourselfAtom := nil. |
|
6875 |
quitAppAtom := nil. |
|
6876 |
||
6877 |
self initializeScreenProperties. |
|
1366 | 6878 |
self initializeDeviceResourceTables. |
295 | 6879 |
|
6880 |
self initializeDefaultValues. |
|
6881 |
self initializeEventBuffer. |
|
6882 |
self initializeSpecialFlags. |
|
6883 |
self initializeKeyboardMap. |
|
6884 |
||
6885 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
6886 |
! |
|
6887 |
||
1344 | 6888 |
initializeModifierMappings |
295 | 6889 |
|map mod| |
6890 |
||
6891 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6892 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6893 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6894 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6895 |
||
6896 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6897 |
altModifierMask := metaModifierMask := nil. |
|
6898 |
||
6899 |
map := self modifierMapping. |
|
342 | 6900 |
map isNil ifTrue:[ |
1344 | 6901 |
"/ |
6902 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6903 |
"/ setup some reasonable default. If that is not sufficient, |
|
6904 |
"/ you have to change things from your display.rc file. |
|
6905 |
"/ |
|
6906 |
altModifierMask := self modifier1Mask. |
|
6907 |
metaModifierMask := self modifier2Mask. |
|
6908 |
||
6909 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6910 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6911 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6912 |
altModifiers := #(Alt_R Alt). |
|
342 | 6913 |
] ifFalse:[ |
1344 | 6914 |
altModifierMask := 0. |
6915 |
metaModifierMask := 0. |
|
6916 |
||
6917 |
mod := map at:1. |
|
6918 |
mod notNil ifTrue:[ |
|
6919 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6920 |
]. |
|
6921 |
mod := map at:3. |
|
6922 |
mod notNil ifTrue:[ |
|
6923 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6924 |
]. |
|
6925 |
mod := map at:4. |
|
6926 |
mod notNil ifTrue:[ |
|
6927 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6928 |
metaModifierMask := 1 bitShift:(4-1). |
|
6929 |
]. |
|
6930 |
mod := map at:5. |
|
6931 |
mod notNil ifTrue:[ |
|
6932 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6933 |
altModifierMask := 1 bitShift:(5-1). |
|
6934 |
] |
|
295 | 6935 |
]. |
6936 |
||
6937 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6938 |
! |
|
6939 |
||
1344 | 6940 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6941 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6942 |
|
295 | 6943 |
%{ /* NOCONTEXT */ |
6944 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6945 |
Display *dpy; |
295 | 6946 |
int scr; |
6947 |
Visual *visual; |
|
6948 |
XVisualInfo viproto; |
|
6949 |
XVisualInfo *vip; /* retured info */ |
|
6950 |
int maxRGBDepth; |
|
6951 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6952 |
int rgbVisualID; |
|
6953 |
int nvi, i; |
|
6954 |
int shapeEventBase, shapeErrorBase; |
|
6955 |
int shmEventBase, shmErrorBase; |
|
6956 |
char *type, *nm; |
|
6957 |
int dummy; |
|
6958 |
int mask, shift, nBits; |
|
6959 |
||
6960 |
if (ISCONNECTED) { |
|
1344 | 6961 |
dpy = myDpy; |
6962 |
||
6963 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
6964 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6965 |
||
6966 |
BEGIN_INTERRUPTSBLOCKED |
|
6967 |
||
6968 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6969 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6970 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6971 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6972 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6973 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6974 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6975 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6976 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6977 |
|
6978 |
#ifdef SHAPE |
|
1344 | 6979 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
6980 |
__INST(hasShapeExtension) = true; |
|
6981 |
else |
|
295 | 6982 |
#endif |
1344 | 6983 |
__INST(hasShapeExtension) = false; |
295 | 6984 |
|
6985 |
#ifdef SHM |
|
1344 | 6986 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
6987 |
__INST(hasShmExtension) = true; |
|
6988 |
else |
|
295 | 6989 |
#endif |
1344 | 6990 |
__INST(hasShmExtension) = false; |
295 | 6991 |
|
6992 |
#ifdef DPS |
|
1344 | 6993 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6994 |
__INST(hasDPSExtension) = true; |
|
6995 |
else |
|
295 | 6996 |
#endif |
1344 | 6997 |
__INST(hasDPSExtension) = false; |
295 | 6998 |
|
6999 |
#ifdef XVIDEO |
|
1344 | 7000 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
7001 |
__INST(hasXVideoExtension) = true; |
|
7002 |
else |
|
295 | 7003 |
#endif |
1344 | 7004 |
__INST(hasXVideoExtension) = false; |
295 | 7005 |
|
7006 |
#ifdef MBUF |
|
1344 | 7007 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
7008 |
__INST(hasMbufExtension) = true; |
|
7009 |
else |
|
295 | 7010 |
#endif |
1344 | 7011 |
__INST(hasMbufExtension) = false; |
295 | 7012 |
|
7013 |
#ifdef PEX5 |
|
1344 | 7014 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
7015 |
__INST(hasPEXExtension) = true; |
|
7016 |
else |
|
295 | 7017 |
#endif |
1344 | 7018 |
__INST(hasPEXExtension) = false; |
295 | 7019 |
|
7020 |
#ifdef XIE |
|
1344 | 7021 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
7022 |
__INST(hasImageExtension) = true; |
|
7023 |
else |
|
295 | 7024 |
#endif |
1344 | 7025 |
__INST(hasImageExtension) = false; |
295 | 7026 |
|
7027 |
#ifdef XI |
|
1344 | 7028 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
7029 |
__INST(hasInputExtension) = true; |
|
7030 |
else |
|
295 | 7031 |
#endif |
1344 | 7032 |
__INST(hasInputExtension) = false; |
7033 |
||
7034 |
/* |
|
7035 |
* look for RGB visual |
|
7036 |
*/ |
|
7037 |
nvi = 0; |
|
7038 |
viproto.screen = scr; |
|
7039 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
7040 |
maxRGBDepth = 0; |
|
7041 |
for (i = 0; i < nvi; i++) { |
|
7042 |
switch (vip[i].class) { |
|
7043 |
case TrueColor: |
|
7044 |
if (vip[i].depth > maxRGBDepth) { |
|
7045 |
maxRGBDepth = vip[i].depth; |
|
7046 |
rgbRedMask = vip[i].red_mask; |
|
7047 |
rgbGreenMask = vip[i].green_mask; |
|
7048 |
rgbBlueMask = vip[i].blue_mask; |
|
7049 |
rgbVisualID = vip[i].visualid; |
|
7050 |
} |
|
7051 |
break; |
|
7052 |
} |
|
7053 |
} |
|
7054 |
if (vip) XFree ((char *) vip); |
|
7055 |
||
7056 |
if (maxRGBDepth) { |
|
7057 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
7058 |
} |
|
7059 |
||
7060 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
7061 |
__INST(monitorType) = @symbol(unknown); |
|
7062 |
__INST(hasColors) = true; |
|
7063 |
__INST(hasGreyscales) = true; |
|
7064 |
switch (visual->class) { |
|
7065 |
case StaticGray: |
|
7066 |
__INST(visualType) = @symbol(StaticGray); |
|
7067 |
__INST(hasColors) = false; |
|
7068 |
__INST(monitorType) = @symbol(monochrome); |
|
7069 |
break; |
|
7070 |
case GrayScale: |
|
7071 |
__INST(visualType) = @symbol(GrayScale); |
|
7072 |
__INST(hasColors) = false; |
|
7073 |
__INST(monitorType) = @symbol(monochrome); |
|
7074 |
break; |
|
7075 |
case StaticColor: |
|
7076 |
__INST(visualType) = @symbol(StaticColor); |
|
7077 |
break; |
|
7078 |
case PseudoColor: |
|
7079 |
__INST(visualType) = @symbol(PseudoColor); |
|
7080 |
break; |
|
7081 |
case TrueColor: |
|
7082 |
__INST(visualType) = @symbol(TrueColor); |
|
7083 |
break; |
|
7084 |
case DirectColor: |
|
7085 |
__INST(visualType) = @symbol(DirectColor); |
|
7086 |
break; |
|
7087 |
} |
|
7088 |
if (DisplayCells(dpy, scr) == 2) { |
|
7089 |
__INST(hasColors) = false; |
|
7090 |
__INST(hasGreyscales) = false; |
|
7091 |
__INST(monitorType) = @symbol(monochrome); |
|
7092 |
} |
|
7093 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
7094 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
7095 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
7096 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
7097 |
switch (visual->class) { |
|
7098 |
case TrueColor: |
|
7099 |
/* extract number of bits and shift counts */ |
|
7100 |
mask = visual->red_mask; |
|
7101 |
shift = 0; |
|
7102 |
while (mask && ((mask & 1) == 0)) { |
|
7103 |
mask >>= 1; |
|
7104 |
shift++; |
|
7105 |
} |
|
7106 |
__INST(redShift) = __MKSMALLINT(shift); |
|
7107 |
nBits = 0; |
|
7108 |
while (mask) { |
|
7109 |
mask >>= 1; |
|
7110 |
nBits++; |
|
7111 |
} |
|
7112 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
7113 |
||
7114 |
mask = visual->green_mask; |
|
7115 |
shift = 0; |
|
7116 |
while (mask && ((mask & 1) == 0)) { |
|
7117 |
mask >>= 1; |
|
7118 |
shift++; |
|
7119 |
} |
|
7120 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
7121 |
nBits = 0; |
|
7122 |
while (mask) { |
|
7123 |
mask >>= 1; |
|
7124 |
nBits++; |
|
7125 |
} |
|
7126 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
7127 |
||
7128 |
mask = visual->blue_mask; |
|
7129 |
shift = 0; |
|
7130 |
while (mask && ((mask & 1) == 0)) { |
|
7131 |
mask >>= 1; |
|
7132 |
shift++; |
|
7133 |
} |
|
7134 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
7135 |
nBits = 0; |
|
7136 |
while (mask) { |
|
7137 |
mask >>= 1; |
|
7138 |
nBits++; |
|
7139 |
} |
|
7140 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
7141 |
break; |
|
7142 |
} |
|
295 | 7143 |
|
7144 |
#ifndef XA_PRIMARY |
|
1344 | 7145 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 7146 |
#else |
1344 | 7147 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 7148 |
#endif |
7149 |
#ifndef XA_SECONDARY |
|
1344 | 7150 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 7151 |
#else |
1344 | 7152 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 7153 |
#endif |
7154 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 7155 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 7156 |
#else |
1344 | 7157 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 7158 |
#endif |
7159 |
#ifndef XA_STRING |
|
1344 | 7160 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 7161 |
#else |
1344 | 7162 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 7163 |
#endif |
7164 |
#ifndef XA_LENGTH |
|
1344 | 7165 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 7166 |
#else |
1344 | 7167 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 7168 |
#endif |
1533 | 7169 |
#ifndef WM_STATE |
7170 |
__INST(wmStateAtom) = __MKATOMOBJ( XInternAtom(dpy, "WM_STATE", True) ); |
|
7171 |
#else |
|
7172 |
__INST(wmStateAtom) = __MKATOMOBJ( WM_STATE ); |
|
7173 |
#endif |
|
295 | 7174 |
|
1344 | 7175 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7176 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7177 |
%}. |
295 | 7178 |
! |
7179 |
||
1344 | 7180 |
initializeSpecialFlags |
295 | 7181 |
"perform additional special server implementation flags" |
7182 |
||
7183 |
"/ |
|
7184 |
"/ assume we have it ... (should check) |
|
7185 |
"/ |
|
7186 |
hasSaveUnder := true. |
|
7187 |
ignoreBackingStore := false. |
|
7188 |
||
7189 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 7190 |
"/ |
7191 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
7192 |
"/ which does not correctly handle saveUnder |
|
7193 |
"/ |
|
7194 |
hasSaveUnder := false. |
|
295 | 7195 |
]. |
7196 |
! |
|
7197 |
||
1344 | 7198 |
reinitialize |
295 | 7199 |
virtualRootId := rootId := nil. |
7200 |
super reinitialize. |
|
7201 |
dispatchingExpose := nil |
|
7202 |
! ! |
|
7203 |
||
7204 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
7205 |
||
1344 | 7206 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7207 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7208 |
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
|
7209 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7210 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7211 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7212 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7213 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7214 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7215 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7216 |
|
1344 | 7217 |
altModifierMask:aSmallInteger |
341 | 7218 |
"define which key takes the role of an alt-key. |
7219 |
By default, this is X's modifier1, which is the ALT key on |
|
7220 |
most keyboards. However, there may be exceptions to this, |
|
7221 |
and the setting can be changed with: |
|
1344 | 7222 |
Display altModifierMask:(Display modifier2Mask) |
341 | 7223 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
7224 |
" |
|
7225 |
||
7226 |
altModifierMask := aSmallInteger |
|
7227 |
! |
|
7228 |
||
1344 | 7229 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7230 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7231 |
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
|
7232 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7233 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7234 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7235 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7236 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7237 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7238 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7239 |
|
1344 | 7240 |
metaModifierMask:aSmallInteger |
341 | 7241 |
"define which key takes the role of a meta key. |
7242 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
7243 |
most keyboards (if present at all). |
|
7244 |
However, there may be exceptions to this, and the setting can |
|
7245 |
be changed with: |
|
1344 | 7246 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 7247 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
7248 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
7249 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
7250 |
all the time. On those, you should disable the meta key by setting |
|
7251 |
the mask to 0. |
|
7252 |
" |
|
7253 |
||
7254 |
metaModifierMask := aSmallInteger |
|
7255 |
! |
|
7256 |
||
1344 | 7257 |
modifier1Mask |
341 | 7258 |
"return the Xlib mask bit for the 1st modifier key. |
7259 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7260 |
this could be used." |
|
7261 |
||
7262 |
%{ /* NOCONTEXT */ |
|
7263 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
7264 |
%} |
|
7265 |
! |
|
7266 |
||
1344 | 7267 |
modifier2Mask |
341 | 7268 |
"return the Xlib mask bit for the 2nd modifier key. |
7269 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7270 |
this could be used." |
|
7271 |
||
7272 |
%{ /* NOCONTEXT */ |
|
7273 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
7274 |
%} |
|
7275 |
! |
|
7276 |
||
1344 | 7277 |
modifierMapping |
341 | 7278 |
"Get the Modifier Mapping. |
7279 |
We return an array of arrays of keycodes" |
|
7280 |
||
7281 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
7282 |
||
7283 |
%{ |
|
7284 |
XModifierKeymap *modmap; |
|
7285 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
7286 |
||
7287 |
if (ISCONNECTED) { |
|
1344 | 7288 |
Display *dpy = myDpy; |
7289 |
||
7290 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
7291 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7292 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
7293 |
if (modifierKeyMap != nil) { |
|
7294 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7295 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
7296 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
7297 |
} |
|
7298 |
XFreeModifiermap(modmap); |
|
7299 |
} |
|
341 | 7300 |
} |
7301 |
%}. |
|
7302 |
||
7303 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
7304 |
||
7305 |
ret := Array new:8. |
|
7306 |
nextKey := 1. |
|
7307 |
1 to:8 do:[ :i | |
|
1344 | 7308 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
7309 |
|mod| |
|
7310 |
||
7311 |
mod := OrderedCollection new:maxKeyPerMod. |
|
7312 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
7313 |
key ~= 0 ifTrue:[ |
|
7314 |
mod add:key |
|
7315 |
]. |
|
7316 |
]. |
|
7317 |
ret at:i put:mod. |
|
7318 |
]. |
|
7319 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 7320 |
]. |
7321 |
||
7322 |
^ ret |
|
7323 |
||
7324 |
" |
|
1344 | 7325 |
Display modifierMapping |
341 | 7326 |
" |
7327 |
! |
|
7328 |
||
1344 | 7329 |
stringFromKeycode:code |
341 | 7330 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
7331 |
||
7332 |
|str| |
|
7333 |
||
7334 |
%{ |
|
7335 |
KeySym keysym; |
|
7336 |
char *keystring; |
|
7337 |
||
7338 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 7339 |
Display *dpy = myDpy; |
7340 |
||
7341 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
7342 |
(keystring = XKeysymToString(keysym)) != 0) |
|
7343 |
str = __MKSTRING(keystring); |
|
341 | 7344 |
} |
7345 |
%}. |
|
7346 |
^ str |
|
7347 |
||
7348 |
" |
|
1344 | 7349 |
Display stringFromKeycode:28 |
341 | 7350 |
" |
7351 |
! |
|
7352 |
||
1344 | 7353 |
translateKey:untranslatedKey |
295 | 7354 |
"Return the key translated via the translation table. |
7355 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
7356 |
which gets further processed in the superclasses translation method." |
|
7357 |
||
7358 |
|key| |
|
7359 |
||
7360 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 7361 |
key := RawKeysymTranslation at:key ifAbsent:key. |
7362 |
key := key asSymbol. |
|
295 | 7363 |
]. |
7364 |
^ super translateKey:key |
|
7365 |
! ! |
|
7366 |
||
7367 |
!XWorkstation methodsFor:'misc'! |
|
7368 |
||
1344 | 7369 |
beep |
295 | 7370 |
"output an audible beep or bell" |
7371 |
||
7372 |
self beep:50 |
|
7373 |
! |
|
7374 |
||
1344 | 7375 |
beep:volumeInPercent |
295 | 7376 |
"output an audible beep" |
7377 |
%{ |
|
7378 |
int volume; |
|
7379 |
||
7380 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 7381 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
7382 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
7383 |
if (volume < -100) volume = -100; |
|
7384 |
else if (volume > 100) volume = 100; |
|
7385 |
BEGIN_INTERRUPTSBLOCKED |
|
7386 |
XBell(myDpy, volume); |
|
7387 |
END_INTERRUPTSBLOCKED |
|
295 | 7388 |
} |
7389 |
%} |
|
7390 |
! |
|
7391 |
||
1344 | 7392 |
buffered |
295 | 7393 |
"buffer drawing - do not send it immediately to the display. |
374 | 7394 |
This is the default anyway. |
7395 |
See #unBuffered for additional info." |
|
295 | 7396 |
|
7397 |
%{ /* NOCONTEXT */ |
|
7398 |
||
7399 |
if (ISCONNECTED) { |
|
1344 | 7400 |
BEGIN_INTERRUPTSBLOCKED |
7401 |
XSynchronize(myDpy, 0); |
|
7402 |
END_INTERRUPTSBLOCKED |
|
295 | 7403 |
} |
7404 |
%} |
|
374 | 7405 |
" |
7406 |
Display buffered |
|
7407 |
" |
|
295 | 7408 |
! |
7409 |
||
1344 | 7410 |
flush |
295 | 7411 |
"send all buffered drawing to the display. |
7412 |
This may be required to make certain, that all previous operations |
|
7413 |
are really sent to the display before continuing. For example, |
|
7414 |
after a cursor-change with a followup long computation. |
|
374 | 7415 |
(otherwise, the cursor change request may still be in the output buffer) |
7416 |
See also #sync, which even waits until the request has been processed." |
|
295 | 7417 |
|
7418 |
%{ /* NOCONTEXT */ |
|
7419 |
||
7420 |
if (ISCONNECTED) { |
|
1344 | 7421 |
BEGIN_INTERRUPTSBLOCKED |
7422 |
XFlush(myDpy); |
|
7423 |
END_INTERRUPTSBLOCKED |
|
310 | 7424 |
} |
7425 |
%} |
|
7426 |
! |
|
7427 |
||
1344 | 7428 |
flushDpsContext:aDPSContext |
295 | 7429 |
|
7430 |
%{ /* NOCONTEXT */ |
|
7431 |
#ifdef DPS |
|
7432 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 7433 |
BEGIN_INTERRUPTSBLOCKED |
7434 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
7435 |
END_INTERRUPTSBLOCKED |
|
7436 |
RETURN ( self ); |
|
295 | 7437 |
} |
7438 |
#endif |
|
374 | 7439 |
%}. |
295 | 7440 |
self primitiveFailed |
7441 |
! |
|
7442 |
||
1344 | 7443 |
refreshKeyboardMapping:eB |
295 | 7444 |
%{ |
7445 |
XMappingEvent *ev; |
|
7446 |
||
7447 |
if (__isByteArray(eB)) { |
|
1344 | 7448 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
7449 |
XRefreshKeyboardMapping(ev); |
|
295 | 7450 |
} |
7451 |
%} |
|
7452 |
! |
|
7453 |
||
1344 | 7454 |
setInputFocusTo:aWindowId |
295 | 7455 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
7456 |
self setInputFocusTo:aWindowId revertTo:#root |
|
7457 |
! |
|
7458 |
||
1344 | 7459 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 7460 |
"set the focus to the view as defined by aWindowId. |
7461 |
Passing nil set the focus to no window and lets the display discard all |
|
7462 |
input until a new focus is set. |
|
7463 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
7464 |
passing one of #parent, #root or nil specifies that the focus should be |
|
7465 |
given to the parent view, the root view or no view." |
|
7466 |
||
7467 |
%{ /* NOCONTEXT */ |
|
7468 |
int arg; |
|
7469 |
Window focusWindow; |
|
7470 |
||
7471 |
if (ISCONNECTED) { |
|
1344 | 7472 |
if (__isExternalAddress(aWindowId)) { |
7473 |
focusWindow = _WindowVal(aWindowId); |
|
7474 |
} else { |
|
7475 |
focusWindow = None; |
|
7476 |
} |
|
7477 |
if (revertSymbol == @symbol(parent)) |
|
7478 |
arg = RevertToParent; |
|
7479 |
else if (revertSymbol == @symbol(root)) |
|
7480 |
arg = RevertToPointerRoot; |
|
7481 |
else |
|
7482 |
arg = RevertToNone; |
|
7483 |
||
7484 |
BEGIN_INTERRUPTSBLOCKED |
|
7485 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
7486 |
END_INTERRUPTSBLOCKED |
|
7487 |
RETURN ( self ); |
|
295 | 7488 |
} |
7489 |
%}. |
|
7490 |
self primitiveFailed |
|
7491 |
! |
|
7492 |
||
1344 | 7493 |
sync |
341 | 7494 |
"send all buffered drawing to the display AND wait until the display |
7495 |
has finished drawing it. |
|
7496 |
This is almost never needed, except if you are about to read previously |
|
374 | 7497 |
drawn pixels back from the display screen, or you want to wait for a beep |
7498 |
to be finished. See also #flush." |
|
341 | 7499 |
|
7500 |
%{ /* NOCONTEXT */ |
|
7501 |
||
7502 |
if (ISCONNECTED) { |
|
1344 | 7503 |
BEGIN_INTERRUPTSBLOCKED |
7504 |
XSync(myDpy, 0); |
|
7505 |
END_INTERRUPTSBLOCKED |
|
341 | 7506 |
} |
7507 |
%} |
|
7508 |
! |
|
7509 |
||
1344 | 7510 |
unBuffered |
374 | 7511 |
"make all drawing be sent immediately to the display. |
7512 |
This makes all graphics synchronous and turns off any buffering |
|
7513 |
(i.e. each individual draw-request is sent immediately without |
|
7514 |
packing multiple requests into a larger message buffer). |
|
7515 |
Be prepared, that this slows down graphics considerably. |
|
7516 |
However, it allows display errors to be handled immediately and |
|
7517 |
may be useful if you get Xdisplay errors and want to find the request |
|
7518 |
which was responsiblefor it. See also #buffered." |
|
295 | 7519 |
|
7520 |
%{ /* NOCONTEXT */ |
|
7521 |
||
7522 |
if (ISCONNECTED) { |
|
1344 | 7523 |
BEGIN_INTERRUPTSBLOCKED |
7524 |
XSynchronize(myDpy, 1); |
|
7525 |
END_INTERRUPTSBLOCKED |
|
295 | 7526 |
} |
7527 |
%} |
|
7528 |
"Display unbuffered" |
|
7529 |
! ! |
|
7530 |
||
7531 |
!XWorkstation methodsFor:'pointer queries '! |
|
7532 |
||
1344 | 7533 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7534 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7535 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7536 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7537 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7538 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7539 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7540 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7541 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7542 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7543 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7544 |
|
1344 | 7545 |
buttonStates |
295 | 7546 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7547 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7548 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7549 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 7550 |
|
7551 |
%{ /* NOCONTEXT*/ |
|
7552 |
Window w; |
|
555 | 7553 |
int screen = __intVal(__INST(screen)); |
295 | 7554 |
Window rootRet, childRet; |
7555 |
int rootX, rootY, winX, winY; |
|
7556 |
unsigned int mask; |
|
7557 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7558 |
if (ISCONNECTED) { |
1344 | 7559 |
Display *dpy = myDpy; |
7560 |
||
7561 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7562 |
#ifdef VIRTUAL_ROOT |
1344 | 7563 |
w = getRootWindow(myDpy, screen); |
295 | 7564 |
#else |
1344 | 7565 |
w = RootWindow(dpy, screen); |
295 | 7566 |
#endif |
1344 | 7567 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7568 |
&rootX, &rootY, |
|
7569 |
&winX, &winY, |
|
7570 |
&mask); |
|
7571 |
END_INTERRUPTSBLOCKED |
|
7572 |
RETURN (__MKSMALLINT(mask)); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7573 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7574 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7575 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7576 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7577 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7578 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7579 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7580 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7581 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7582 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7583 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7584 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7585 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7586 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7587 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7588 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7589 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7590 |
" |
295 | 7591 |
! |
7592 |
||
1344 | 7593 |
leftButtonStateMask |
295 | 7594 |
"return an integer for masking out the left button from a |
7595 |
buttonStates value" |
|
7596 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7597 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7598 |
|
295 | 7599 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7600 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7601 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 7602 |
! |
7603 |
||
1344 | 7604 |
middleButtonStateMask |
295 | 7605 |
"return an integer for masking out the middle button from a |
7606 |
buttonStates value" |
|
7607 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7608 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7609 |
|
295 | 7610 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7611 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7612 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 7613 |
! |
7614 |
||
1344 | 7615 |
pointerPosition |
295 | 7616 |
"return the current pointer position in root-window coordinates" |
7617 |
||
7618 |
|xpos ypos| |
|
7619 |
||
7620 |
%{ |
|
7621 |
Window w; |
|
555 | 7622 |
int screen = __intVal(__INST(screen)); |
295 | 7623 |
Window rootRet, childRet; |
7624 |
int rootX, rootY, winX, winY; |
|
7625 |
unsigned int mask; |
|
7626 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7627 |
if (ISCONNECTED) { |
1344 | 7628 |
Display *dpy = myDpy; |
7629 |
||
7630 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7631 |
#ifdef VIRTUAL_ROOT |
1344 | 7632 |
w = getRootWindow(myDpy, screen); |
295 | 7633 |
#else |
1344 | 7634 |
w = RootWindow(dpy, screen); |
295 | 7635 |
#endif |
1344 | 7636 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7637 |
&rootX, &rootY, |
|
7638 |
&winX, &winY, |
|
7639 |
&mask); |
|
7640 |
xpos = __MKSMALLINT(rootX); |
|
7641 |
ypos = __MKSMALLINT(rootY); |
|
7642 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7643 |
} |
295 | 7644 |
%} |
7645 |
. |
|
7646 |
^ xpos @ ypos |
|
7647 |
! |
|
7648 |
||
1344 | 7649 |
rightButtonStateMask |
295 | 7650 |
"return an integer for masking out the right button from a |
7651 |
buttonStates value" |
|
7652 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7653 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7654 |
|
295 | 7655 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7656 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7657 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 7658 |
! |
7659 |
||
1344 | 7660 |
rootPositionOfLastEvent |
295 | 7661 |
"return the position in root-window coordinates |
7662 |
of the last button, key or pointer event" |
|
7663 |
||
7664 |
^ eventRootX @ eventRootY |
|
7665 |
! ! |
|
7666 |
||
1556 | 7667 |
!XWorkstation methodsFor:'properties'! |
7668 |
||
7669 |
getObjectProperty:propertyID from:aWindowID |
|
7670 |
"get an object property from the server; return object or nil" |
|
7671 |
||
7672 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7673 |
type == stringAtom ifTrue:[ |
|
7674 |
^ value |
|
7675 |
]. |
|
7676 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7677 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7678 |
] |
|
7679 |
]. |
|
7680 |
^ nil |
|
7681 |
||
7682 |
"Modified: 6.4.1997 / 13:27:07 / cg" |
|
7683 |
! |
|
7684 |
||
7685 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7686 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7687 |
||
7688 |
|val typeID cls| |
|
7689 |
||
7690 |
cls := ByteArray. |
|
7691 |
%{ |
|
7692 |
Window window; |
|
7693 |
Atom property; |
|
7694 |
char *cp, *cp2; |
|
7695 |
Atom actual_type; |
|
7696 |
int actual_format,i; |
|
7697 |
unsigned long nitems, bytes_after, nread; |
|
7698 |
unsigned char *data; |
|
7699 |
int ok = 1; |
|
7700 |
# define PROP_SIZE 2048 |
|
7701 |
||
7702 |
if (ISCONNECTED) { |
|
7703 |
Display *dpy = myDpy; |
|
7704 |
||
7705 |
if (__isAtomID(propertyID)) { |
|
7706 |
property = _AtomVal(propertyID); |
|
7707 |
if (__isExternalAddress(aWindowID)) { |
|
7708 |
window = _WindowVal(aWindowID); |
|
7709 |
} else { |
|
7710 |
window = DefaultRootWindow(dpy); |
|
7711 |
} |
|
7712 |
||
7713 |
nread = 0; |
|
7714 |
cp = 0; |
|
7715 |
/* |
|
7716 |
fprintf(stderr, "getProperty: "); |
|
7717 |
*/ |
|
7718 |
do { |
|
7719 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7720 |
AnyPropertyType,&actual_type,&actual_format, |
|
7721 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7722 |
!= Success) { |
|
7723 |
ok = 0; |
|
7724 |
break; |
|
7725 |
} |
|
7726 |
typeID = __MKATOMOBJ(actual_type); |
|
7727 |
if (! cp) { |
|
7728 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7729 |
} else { |
|
7730 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7731 |
cp2 = cp + nread; |
|
7732 |
} |
|
7733 |
if (! cp) { |
|
7734 |
XFree(data); |
|
7735 |
goto fail; |
|
7736 |
} |
|
7737 |
||
7738 |
nread += nitems; |
|
7739 |
bcopy(data, cp2, nitems); |
|
7740 |
XFree(data); |
|
7741 |
/* |
|
7742 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7743 |
*/ |
|
7744 |
} while (bytes_after > 0); |
|
7745 |
/* |
|
7746 |
fprintf(stderr, "\n"); |
|
7747 |
*/ |
|
7748 |
||
7749 |
if (ok) { |
|
7750 |
if (actual_type == XA_STRING) { |
|
7751 |
cp[nread] = '\0'; |
|
7752 |
val = __MKSTRING_L(cp, nread); |
|
7753 |
} else { |
|
7754 |
val = __new(nread + OHDR_SIZE); |
|
7755 |
val->o_class = cls; |
|
7756 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
7757 |
} |
|
7758 |
} |
|
7759 |
if (cp) |
|
7760 |
free(cp); |
|
7761 |
} |
|
7762 |
} |
|
7763 |
fail: ; |
|
7764 |
%}. |
|
7765 |
typeID isNil ifTrue:[ |
|
7766 |
^ false |
|
7767 |
]. |
|
7768 |
aTwoArgBlock value:typeID value:val. |
|
7769 |
^ true |
|
7770 |
! |
|
7771 |
||
7772 |
getTextProperty:propertyID from:aWindowID |
|
7773 |
"get a text property; return string or nil" |
|
7774 |
||
7775 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7776 |
type == stringAtom ifTrue:[ |
|
7777 |
^ value |
|
7778 |
] |
|
7779 |
]. |
|
7780 |
^ nil |
|
7781 |
! |
|
7782 |
||
7783 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7784 |
"set a size property" |
|
7785 |
||
7786 |
^ self |
|
7787 |
setProperty:propertyID |
|
7788 |
type:(self atomIDOfLENGTH) |
|
7789 |
value:aNumber |
|
7790 |
for:aWindowID |
|
7791 |
||
7792 |
"Modified: 6.4.1997 / 13:27:26 / cg" |
|
7793 |
! |
|
7794 |
||
7795 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7796 |
"set a property to a smalltalk object in the XServer. |
|
7797 |
Can only be retrieved by another ST/X smalltalk" |
|
7798 |
||
7799 |
|s| |
|
7800 |
||
7801 |
(anObject isMemberOf:String) ifTrue:[ |
|
7802 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7803 |
]. |
|
7804 |
s := WriteStream on:(ByteArray new:200). |
|
7805 |
anObject storeBinaryOn:s. |
|
7806 |
^ self |
|
7807 |
setProperty:propertyID |
|
7808 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7809 |
value:(s contents) |
|
7810 |
for:aWindowID |
|
7811 |
||
7812 |
"Modified: 6.4.1997 / 13:27:57 / cg" |
|
7813 |
! |
|
7814 |
||
7815 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7816 |
"set a property in the XServer" |
|
7817 |
||
7818 |
%{ /* UNLIMITEDSTACK */ |
|
7819 |
||
7820 |
Atom prop, type; |
|
7821 |
Window window; |
|
7822 |
unsigned int value; |
|
7823 |
||
7824 |
if (__isAtomID(propertyID) |
|
7825 |
&& __isAtomID(typeID) |
|
7826 |
&& ISCONNECTED |
|
7827 |
&& (__isString(anObject) |
|
7828 |
|| __isSmallInteger(anObject) |
|
7829 |
|| __isSymbol(anObject) |
|
7830 |
|| __isByteArray(anObject) |
|
7831 |
|| __isWords(anObject))) { |
|
7832 |
||
7833 |
Display *dpy = myDpy; |
|
7834 |
||
7835 |
prop = _AtomVal(propertyID); |
|
7836 |
type = _AtomVal(typeID); |
|
7837 |
||
7838 |
if (__isExternalAddress(aWindowID)) { |
|
7839 |
window = _WindowVal(aWindowID); |
|
7840 |
} else { |
|
7841 |
window = DefaultRootWindow(dpy); |
|
7842 |
} |
|
7843 |
if (__isSmallInteger(anObject)) { |
|
7844 |
value = __intVal(anObject); |
|
7845 |
XChangeProperty(dpy, window, prop, type, 32, |
|
7846 |
PropModeReplace, |
|
7847 |
(unsigned char *)(&value), sizeof(unsigned int)); |
|
7848 |
} else { |
|
7849 |
if (__isByteArray(anObject)) { |
|
7850 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7851 |
PropModeReplace, |
|
7852 |
__ByteArrayInstPtr(anObject)->ba_element, |
|
7853 |
__byteArraySize(anObject)); |
|
7854 |
} else { |
|
7855 |
/* string or symbol or wordArray-like (16bit-string) object */ |
|
7856 |
type = _AtomVal(typeID); |
|
7857 |
if (__isWords(__qClass(anObject))) { |
|
7858 |
XChangeProperty(dpy, window, prop, type, 16, |
|
7859 |
PropModeReplace, |
|
7860 |
__stringVal(anObject), |
|
7861 |
__wordArraySize(anObject)); |
|
7862 |
} else { |
|
7863 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7864 |
PropModeReplace, |
|
7865 |
__stringVal(anObject), |
|
1557
c37fd33dc7d8
don use strlen when setting a string prop;
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
7866 |
__stringSize(anObject)); |
1556 | 7867 |
} |
7868 |
} |
|
7869 |
} |
|
7870 |
RETURN (true); |
|
7871 |
} |
|
7872 |
%}. |
|
7873 |
^ false |
|
7874 |
! |
|
7875 |
||
7876 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7877 |
"set a property to a stringValue in the XServer" |
|
7878 |
||
7879 |
^ self |
|
7880 |
setProperty:propertyID |
|
7881 |
type:(self atomIDOfSTRING) |
|
7882 |
value:aString |
|
7883 |
for:aWindowID |
|
7884 |
||
7885 |
"Modified: 6.4.1997 / 13:26:32 / cg" |
|
7886 |
! ! |
|
7887 |
||
295 | 7888 |
!XWorkstation methodsFor:'resources'! |
7889 |
||
1344 | 7890 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7891 |
"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
|
7892 |
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
|
7893 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7894 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7895 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7896 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7897 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7898 |
Display atomIDOf:'FULL_NAME' |
1535 | 7899 |
Display atomIDOf:'DndProtocol' |
7900 |
Display atomIDOf:'DndSelection' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7901 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7902 |
|
1535 | 7903 |
"Modified: 4.4.1997 / 13:38:48 / cg" |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7904 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7905 |
|
1344 | 7906 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7907 |
"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
|
7908 |
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
|
7909 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7910 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7911 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7912 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7913 |
if (ISCONNECTED) { |
1344 | 7914 |
if (__isString(aStringOrSymbol) |
7915 |
|| __isSymbol(aStringOrSymbol)) { |
|
7916 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
7917 |
(create == true) ? False : True); |
|
7918 |
if (prop == None) { |
|
7919 |
RETURN (nil); |
|
7920 |
} |
|
7921 |
RETURN ( __MKATOMOBJ(prop) ); |
|
7922 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7923 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7924 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7925 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7926 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7927 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7928 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7929 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7930 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7931 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7932 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7933 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7934 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7935 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7936 |
|
1344 | 7937 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7938 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7939 |
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
|
7940 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7941 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7942 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7943 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7944 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7945 |
|
1344 | 7946 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7947 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7948 |
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
|
7949 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7950 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7951 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7952 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7953 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7954 |
|
1344 | 7955 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7956 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7957 |
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
|
7958 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7959 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7960 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7961 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7962 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7963 |
|
1344 | 7964 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7965 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7966 |
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
|
7967 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7968 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7969 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7970 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7971 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7972 |
|
1344 | 7973 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7974 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7975 |
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
|
7976 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7977 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7978 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7979 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7980 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7981 |
|
1344 | 7982 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7983 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7984 |
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
|
7985 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7986 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7987 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7988 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7989 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7990 |
if (ISCONNECTED) { |
1344 | 7991 |
if (__isAtomID(anAtomID)) { |
7992 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
7993 |
if (name == 0) { |
|
7994 |
RETURN (nil); |
|
7995 |
} |
|
7996 |
str = __MKSTRING(name); |
|
7997 |
XFree(name); |
|
7998 |
RETURN ( str ); |
|
7999 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8000 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8001 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8002 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8003 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8004 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8005 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8006 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8007 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8008 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8009 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8010 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8011 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8012 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8013 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8014 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8015 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8016 |
|
1344 | 8017 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8018 |
"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
|
8019 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8020 |
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
|
8021 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8022 |
Notice: |
1344 | 8023 |
we do not plan to use X's resources for ST/X's defaults, |
8024 |
styles or resources. This would make porting of applications |
|
8025 |
to different platforms much more difficult (Windows has no resource |
|
8026 |
database). If you stay within ST/X's resource files, these can be |
|
8027 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8028 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8029 |
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
|
8030 |
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
|
8031 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8032 |
|
295 | 8033 |
%{ |
8034 |
char *rslt; |
|
8035 |
||
8036 |
if ((__isString(name) || __isSymbol(name)) |
|
8037 |
&& (__isString(cls) || __isSymbol(cls)) |
|
8038 |
&& ISCONNECTED) { |
|
1344 | 8039 |
BEGIN_INTERRUPTSBLOCKED |
8040 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
8041 |
(char *)_stringVal(name)); |
|
8042 |
END_INTERRUPTSBLOCKED |
|
8043 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8044 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8045 |
%}. |
295 | 8046 |
self primitiveFailed. |
8047 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8048 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8049 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 8050 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8051 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8052 |
|
1344 | 8053 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8054 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8055 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 8056 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8057 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8058 |
|
1344 | 8059 |
Display getResource:'beNiceToColormap' class:'any' |
8060 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
8061 |
" |
295 | 8062 |
! ! |
8063 |
||
8064 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
8065 |
||
1462
f8b2909deb3c
renamed getBitsFrom to getBitsFromId
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
8066 |
getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 8067 |
"get bits from a drawable into the imageBits. The storage for the bits |
8068 |
must be big enough for the data to fit. If ok, returns an array with some |
|
8069 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
8070 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
8071 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
8072 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8073 |
|rawInfo info| |
295 | 8074 |
|
8075 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 8076 |
self primitiveFailed. |
8077 |
^ nil |
|
295 | 8078 |
]. |
8079 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8080 |
rawInfo := Array new:8. |
1344 | 8081 |
"1 -> bit order" |
8082 |
"2 -> depth" |
|
8083 |
"3 -> bytes_per_line" |
|
8084 |
"4 -> byte_order" |
|
8085 |
"5 -> format" |
|
8086 |
"6 -> bitmap_unit" |
|
8087 |
"7 -> bitmap_pad" |
|
8088 |
"8 -> bits_per_pixel" |
|
295 | 8089 |
|
8090 |
"/ had to extract the getPixel call into a separate method, to specify |
|
8091 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
8092 |
"/ of temporary stack space |
|
8093 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8094 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 8095 |
info := IdentityDictionary new. |
8096 |
info at:#bitOrder put:(rawInfo at:1). |
|
8097 |
info at:#depth put:(rawInfo at:2). |
|
8098 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
8099 |
info at:#byteOrder put:(rawInfo at:4). |
|
8100 |
info at:#format put:(rawInfo at:5). |
|
8101 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
8102 |
info at:#bitmapPad put:(rawInfo at:7). |
|
8103 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
8104 |
^ info |
|
295 | 8105 |
]. |
8106 |
" |
|
8107 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
8108 |
or is too small to hold the bits |
|
8109 |
" |
|
8110 |
^ self primitiveFailed |
|
8111 |
! |
|
8112 |
||
1344 | 8113 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
8114 |
"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
|
8115 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 8116 |
|
8117 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
8118 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8119 |
Window win; |
295 | 8120 |
XImage *img; |
8121 |
int ret; |
|
8122 |
int xpos, ypos; |
|
8123 |
||
1209 | 8124 |
if (ISCONNECTED |
8125 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 8126 |
win = _WindowVal(aDrawableId); |
8127 |
xpos = __intVal(x); |
|
8128 |
ypos = __intVal(y); |
|
8129 |
if ((xpos < 0) || (ypos < 0)) { |
|
8130 |
RETURN ( __MKSMALLINT(0) ); |
|
8131 |
} |
|
8132 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
8133 |
if (img != 0) { |
|
8134 |
ret = XGetPixel(img, 0, 0); |
|
8135 |
XDestroyImage(img); |
|
8136 |
RETURN ( __MKSMALLINT(ret) ); |
|
8137 |
} |
|
295 | 8138 |
} |
8139 |
%}. |
|
8140 |
^ nil |
|
8141 |
! |
|
8142 |
||
1344 | 8143 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 8144 |
"since XGetImage may allocate huge amount of stack space |
8145 |
(some implementations use alloca), this must run with unlimited stack." |
|
8146 |
||
8147 |
%{ /* UNLIMITEDSTACK */ |
|
8148 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8149 |
Window win; |
295 | 8150 |
XImage *image = (XImage *)0; |
8151 |
int pad, bytes_per_line, numBytes; |
|
8152 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8153 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8154 |
&& __isExternalAddress(aDrawableId) |
295 | 8155 |
&& __bothSmallInteger(srcx, srcy) |
8156 |
&& __bothSmallInteger(w, h) |
|
8157 |
&& __isArray(info) |
|
8158 |
&& __isByteArray(imageBits)) { |
|
1344 | 8159 |
Display *dpy = myDpy; |
8160 |
||
8161 |
win = _WindowVal(aDrawableId); |
|
8162 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
|
8163 |
__intVal(w), __intVal(h), |
|
8164 |
(unsigned)AllPlanes, ZPixmap); |
|
8165 |
||
8166 |
if (! image) { |
|
8167 |
RETURN ( false ); |
|
8168 |
} |
|
8169 |
||
8170 |
pad = image->bitmap_pad; |
|
295 | 8171 |
#ifdef SUPERDEBUG |
1344 | 8172 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 8173 |
#endif |
1344 | 8174 |
switch (image->depth) { |
8175 |
case 1: |
|
8176 |
case 2: |
|
8177 |
case 4: |
|
8178 |
case 8: |
|
8179 |
case 16: |
|
8180 |
case 24: |
|
8181 |
case 32: |
|
8182 |
numBytes = image->bytes_per_line * image->height; |
|
8183 |
break; |
|
8184 |
default: |
|
8185 |
/* unsupported depth ? */ |
|
8186 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
8187 |
numBytes = image->bytes_per_line * image->height; |
|
8188 |
break; |
|
8189 |
} |
|
295 | 8190 |
|
8191 |
#ifdef SUPERDEBUG |
|
1344 | 8192 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 8193 |
#endif |
8194 |
||
1344 | 8195 |
if (numBytes > __byteArraySize(imageBits)) { |
8196 |
/* imageBits too small */ |
|
8197 |
printf("provided byteArray too small\n"); |
|
8198 |
goto fail; |
|
8199 |
} |
|
8200 |
if (image->bitmap_bit_order == MSBFirst) |
|
8201 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
8202 |
else |
|
8203 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
8204 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
8205 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
8206 |
if (image->byte_order == MSBFirst) |
|
8207 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
8208 |
else |
|
8209 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
8210 |
if (image->format == XYBitmap) |
|
8211 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
8212 |
else if (image->format == XYPixmap) |
|
8213 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
8214 |
else if (image->format == ZPixmap) |
|
8215 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
8216 |
|
1344 | 8217 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
8218 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
8219 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
8220 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
8221 |
XDestroyImage(image); |
|
8222 |
RETURN ( true ); |
|
295 | 8223 |
} |
8224 |
fail: |
|
8225 |
if (image) { |
|
1344 | 8226 |
XDestroyImage(image); |
295 | 8227 |
} |
8228 |
%}. |
|
8229 |
^ false |
|
8230 |
! ! |
|
8231 |
||
8232 |
!XWorkstation methodsFor:'selections'! |
|
8233 |
||
1344 | 8234 |
getSelectionFor:drawableId |
295 | 8235 |
"get the object selection - either immediate, or asynchronous. |
8236 |
Returns nil, if async request is on its way" |
|
8237 |
||
8238 |
|selProp sel| |
|
8239 |
||
8240 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8241 |
"no primary selection - use cut buffer" |
8242 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
8243 |
^ sel |
|
295 | 8244 |
]. |
8245 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
8246 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
8247 |
^ nil |
|
8248 |
! |
|
8249 |
||
1344 | 8250 |
getSelectionOwnerOf:selectionAtomID |
295 | 8251 |
"get the owner of a selection" |
8252 |
||
8253 |
%{ /* NOCONTEXT */ |
|
8254 |
Atom selection; |
|
8255 |
Window window; |
|
8256 |
||
8257 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 8258 |
Display *dpy = myDpy; |
8259 |
||
8260 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
8261 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
295 | 8262 |
} |
8263 |
%}. |
|
8264 |
self primitiveFailed. |
|
8265 |
^ nil |
|
8266 |
! |
|
8267 |
||
1344 | 8268 |
getTextSelectionFor:drawableId |
295 | 8269 |
"get the text selection - either immediate, or asynchronous. |
8270 |
Returns nil, if async request is on its way" |
|
8271 |
||
8272 |
|selProp sel| |
|
8273 |
||
8274 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8275 |
"no primary selection - use cut buffer" |
8276 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
8277 |
^ sel |
|
295 | 8278 |
]. |
8279 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
8280 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
8281 |
^ nil |
|
8282 |
! |
|
8283 |
||
1344 | 8284 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 8285 |
"ask the server to send us the selection - the view with ID aWindowID |
8286 |
will later receive a SelectionNotify event for it." |
|
8287 |
||
8288 |
^ self requestSelection:selectionID |
|
1344 | 8289 |
property:propertyID |
8290 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
8291 |
for:aWindowId |
|
8292 |
! |
|
8293 |
||
8294 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 8295 |
"ask the server to send us the selection - the view with id aWindowID |
8296 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
8297 |
with the selections value)." |
|
8298 |
||
8299 |
%{ /* NOCONTEXT */ |
|
8300 |
Atom sel_prop; |
|
8301 |
char *cp; |
|
8302 |
||
8303 |
if (__isExternalAddress(aWindowId) |
|
8304 |
&& ISCONNECTED |
|
8305 |
&& __isSmallInteger(typeID) |
|
8306 |
&& __isAtomID(selectionID)) { |
|
1344 | 8307 |
Display *dpy = myDpy; |
8308 |
||
8309 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
8310 |
/* |
|
8311 |
* no owner of primary selection |
|
8312 |
*/ |
|
8313 |
RETURN (false); |
|
8314 |
} |
|
8315 |
/* |
|
8316 |
* PRIMARY selection |
|
8317 |
*/ |
|
8318 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
8319 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
8320 |
RETURN (true); |
|
295 | 8321 |
} |
8322 |
%}. |
|
8323 |
self primitiveFailed. |
|
8324 |
^ false |
|
8325 |
||
8326 |
" |
|
8327 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 8328 |
property:(Display atomIDOf:'VT_SELECTION') |
8329 |
for:0 |
|
295 | 8330 |
" |
8331 |
! |
|
8332 |
||
1344 | 8333 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 8334 |
"ask the server to send us the selection - the view with ID aWindowID |
8335 |
will later receive a SelectionNotify event for it." |
|
8336 |
||
8337 |
^ self requestSelection:selectionID |
|
1344 | 8338 |
property:propertyID |
8339 |
type:stringAtom |
|
8340 |
for:aWindowId |
|
8341 |
! |
|
8342 |
||
8343 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8344 |
"send aString back from a SelectionRequest" |
8345 |
||
8346 |
self |
|
1344 | 8347 |
sendSelection:something |
8348 |
selection:primaryAtom |
|
8349 |
property:propertyID |
|
8350 |
target:targetID |
|
8351 |
from:windowID |
|
8352 |
to:requestorID |
|
8353 |
! |
|
8354 |
||
8355 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8356 |
"send aString back from a SelectionRequest" |
8357 |
||
8358 |
self |
|
1344 | 8359 |
setProperty:propertyID |
8360 |
type:targetID |
|
8361 |
value:something |
|
8362 |
for:requestorID. |
|
295 | 8363 |
self |
1344 | 8364 |
sendSelectionNotifySelection:selectionID |
8365 |
property:propertyID |
|
8366 |
target:targetID |
|
8367 |
from:requestorID |
|
8368 |
to:requestorID. |
|
8369 |
! |
|
8370 |
||
8371 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8372 |
"send a selectionNotify back from a SelectionRequest" |
8373 |
||
8374 |
%{ /* NOCONTEXT */ |
|
8375 |
||
8376 |
if (__isAtomID(propertyID) |
|
8377 |
&& __isExternalAddress(requestorID) |
|
8378 |
&& ISCONNECTED |
|
8379 |
&& __isAtomID(targetID) |
|
8380 |
&& __isAtomID(selectionID)) { |
|
1344 | 8381 |
Display *dpy = myDpy; |
8382 |
XEvent ev; |
|
8383 |
Window requestor = _WindowVal(requestorID); |
|
8384 |
Atom property = _AtomVal(propertyID); |
|
8385 |
Atom target = _AtomVal(targetID); |
|
8386 |
Atom selection = _AtomVal(selectionID); |
|
8387 |
Status result; |
|
8388 |
||
8389 |
ev.xselection.type = SelectionNotify; |
|
8390 |
ev.xselection.selection = selection; |
|
8391 |
ev.xselection.target = target; |
|
8392 |
if (__isExternalAddress(windowID)) |
|
8393 |
ev.xselection.requestor = _WindowVal(windowID); |
|
8394 |
else |
|
8395 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
8396 |
ev.xselection.time = CurrentTime; |
|
8397 |
if (property == None) |
|
8398 |
ev.xselection.property = target; |
|
8399 |
else |
|
8400 |
ev.xselection.property = property; |
|
8401 |
||
8402 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
8403 |
ev.xselection.selection, |
|
8404 |
ev.xselection.property, |
|
8405 |
ev.xselection.target, |
|
8406 |
ev.xselection.requestor, |
|
8407 |
requestor)); |
|
8408 |
||
8409 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
8410 |
if ((result == BadValue) || (result == BadWindow)) { |
|
8411 |
DPRINTF(("bad status\n")); |
|
8412 |
RETURN (false); |
|
8413 |
} |
|
8414 |
RETURN (true) |
|
382 | 8415 |
} |
8416 |
%}. |
|
8417 |
self primitiveFailed. |
|
8418 |
^ false |
|
295 | 8419 |
! |
8420 |
||
1344 | 8421 |
setSelection:anObject owner:aWindowId |
295 | 8422 |
"set the object selection, and make aWindowId be the owner. |
8423 |
This can be used by other Smalltalk(X) applications only." |
|
8424 |
||
8425 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8426 |
^ false |
295 | 8427 |
]. |
8428 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
8429 |
^ true |
|
8430 |
! |
|
8431 |
||
1344 | 8432 |
setSelectionOwner:aWindowId of:selectionID |
295 | 8433 |
"set the owner of a selection; return false if failed" |
8434 |
||
8435 |
%{ /* NOCONTEXT */ |
|
8436 |
Window win; |
|
8437 |
||
8438 |
if (__isExternalAddress(aWindowId) |
|
8439 |
&& __isAtomID(selectionID) |
|
8440 |
&& ISCONNECTED) { |
|
1344 | 8441 |
Display *dpy = myDpy; |
8442 |
||
8443 |
win = _WindowVal(aWindowId); |
|
8444 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
8445 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
8446 |
RETURN (false); |
|
8447 |
} |
|
8448 |
RETURN (true); |
|
295 | 8449 |
} |
8450 |
%} |
|
8451 |
. |
|
8452 |
self primitiveFailed. |
|
8453 |
^ nil |
|
8454 |
! |
|
8455 |
||
1344 | 8456 |
setTextSelection:aString owner:aWindowId |
295 | 8457 |
"set the text selection, and make aWindowId be the owner. |
8458 |
This can be used by any other X application." |
|
8459 |
||
8460 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8461 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 8462 |
]. |
8463 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8464 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8465 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 8466 |
! ! |
8467 |
||
8468 |
!XWorkstation methodsFor:'window stuff'! |
|
8469 |
||
1344 | 8470 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 8471 |
"clear a rectangular area to viewbackground" |
8472 |
||
8473 |
%{ /* NOCONTEXT */ |
|
8474 |
||
8475 |
int w, h; |
|
8476 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8477 |
if (ISCONNECTED) { |
1344 | 8478 |
if (__isExternalAddress(aWindowId) |
8479 |
&& __bothSmallInteger(x, y) |
|
8480 |
&& __bothSmallInteger(width, height)) { |
|
8481 |
w = __intVal(width); |
|
8482 |
h = __intVal(height); |
|
8483 |
/* |
|
8484 |
* need this check here: some servers simply dump core with bad args |
|
8485 |
*/ |
|
8486 |
if ((w >= 0) && (h >= 0)) { |
|
8487 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
|
8488 |
} |
|
8489 |
RETURN ( self ); |
|
8490 |
} |
|
295 | 8491 |
} |
8492 |
%} |
|
8493 |
. |
|
8494 |
self primitiveFailed |
|
8495 |
! |
|
8496 |
||
1344 | 8497 |
clearWindow:aWindowId |
295 | 8498 |
"clear a window to viewbackground" |
8499 |
||
8500 |
%{ /* NOCONTEXT */ |
|
8501 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8502 |
if (ISCONNECTED) { |
1344 | 8503 |
if (__isExternalAddress(aWindowId)) { |
8504 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
8505 |
RETURN ( self ); |
|
8506 |
} |
|
295 | 8507 |
} |
8508 |
%} |
|
8509 |
. |
|
8510 |
self primitiveFailed |
|
8511 |
! |
|
8512 |
||
1344 | 8513 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 8514 |
"configure stacking operation of aWindowId w.r.t siblingId" |
8515 |
||
8516 |
%{ /* NOCONTEXT */ |
|
8517 |
||
8518 |
XWindowChanges chg; |
|
8519 |
int mask = CWSibling | CWStackMode; |
|
8520 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8521 |
if (ISCONNECTED) { |
1344 | 8522 |
if (__isExternalAddress(aWindowId) |
8523 |
&& __isExternalAddress(siblingId)) { |
|
8524 |
if (modeSymbol == @symbol(above)) { |
|
8525 |
chg.stack_mode = Above; |
|
8526 |
} else if (modeSymbol == @symbol(below)) { |
|
8527 |
chg.stack_mode = Below; |
|
8528 |
} else if (modeSymbol == @symbol(topIf)) { |
|
8529 |
chg.stack_mode = TopIf; |
|
8530 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
8531 |
chg.stack_mode = BottomIf; |
|
8532 |
} else if (modeSymbol == @symbol(opposite)) { |
|
8533 |
chg.stack_mode = Opposite; |
|
8534 |
} else { |
|
8535 |
mask = CWSibling; |
|
8536 |
} |
|
8537 |
||
8538 |
chg.sibling = _WindowVal(siblingId); |
|
8539 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
8540 |
mask, &chg); |
|
8541 |
RETURN ( self ); |
|
8542 |
} |
|
295 | 8543 |
} |
8544 |
bad: ; |
|
8545 |
%} |
|
8546 |
. |
|
8547 |
self primitiveFailed |
|
8548 |
! |
|
8549 |
||
1344 | 8550 |
lowerWindow:aWindowId |
295 | 8551 |
"bring a window to back" |
8552 |
||
8553 |
%{ /* NOCONTEXT */ |
|
8554 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8555 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8556 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8557 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
8558 |
RETURN ( self ); |
|
295 | 8559 |
} |
8560 |
%} |
|
8561 |
. |
|
8562 |
self primitiveFailed |
|
8563 |
! |
|
8564 |
||
1344 | 8565 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 8566 |
"make a window visible - either as icon or as a real view - needed for restart" |
8567 |
||
8568 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
8569 |
||
8570 |
aBoolean ifTrue:[ |
|
1344 | 8571 |
wicon := aView icon. |
8572 |
wicon notNil ifTrue:[ |
|
8573 |
wiconId := wicon id |
|
8574 |
]. |
|
8575 |
wiconView := aView iconView. |
|
8576 |
wiconView notNil ifTrue:[ |
|
8577 |
wiconViewId := wiconView id |
|
8578 |
]. |
|
8579 |
wlabel := aView label. |
|
295 | 8580 |
]. |
8581 |
%{ |
|
8582 |
||
8583 |
XWMHints wmhints; |
|
8584 |
XSizeHints szhints; |
|
8585 |
Window win; |
|
8586 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8587 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8588 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8589 |
Display *dpy = myDpy; |
8590 |
||
8591 |
win = _WindowVal(aWindowId); |
|
8592 |
||
8593 |
szhints.flags = 0; |
|
8594 |
if (__bothSmallInteger(xPos, yPos)) { |
|
8595 |
szhints.x = __intVal(xPos); |
|
8596 |
szhints.y = __intVal(yPos); |
|
8597 |
szhints.flags |= USPosition; |
|
8598 |
} |
|
8599 |
if (__bothSmallInteger(w, h)) { |
|
8600 |
szhints.width = __intVal(w); |
|
8601 |
szhints.height = __intVal(h); |
|
8602 |
szhints.flags |= USSize; |
|
8603 |
} |
|
8604 |
||
8605 |
if (aBoolean == true) { |
|
8606 |
char *windowName; |
|
8607 |
Pixmap iconBitmap = (Pixmap)0; |
|
8608 |
Window iconWindow; |
|
8609 |
||
8610 |
if (__isExternalAddress(wiconId)) |
|
8611 |
iconBitmap = _PixmapVal(wiconId); |
|
8612 |
else |
|
8613 |
iconBitmap = (Pixmap)0; |
|
8614 |
||
8615 |
if (__isExternalAddress(wiconViewId)) |
|
8616 |
iconWindow = _WindowVal(wiconViewId); |
|
8617 |
else |
|
8618 |
iconWindow = (Window)0; |
|
8619 |
||
8620 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
8621 |
windowName = (char *)_stringVal(wlabel); |
|
8622 |
else |
|
8623 |
windowName = ""; |
|
8624 |
||
8625 |
if (iconBitmap || windowName) { |
|
8626 |
XSetStandardProperties(dpy, win, |
|
8627 |
windowName, windowName, |
|
8628 |
iconBitmap, |
|
8629 |
0, 0, &szhints); |
|
8630 |
} |
|
8631 |
||
8632 |
wmhints.flags = 0; |
|
8633 |
if (iconBitmap) { |
|
8634 |
wmhints.flags |= IconPixmapHint; |
|
8635 |
wmhints.icon_pixmap = iconBitmap; |
|
8636 |
} |
|
8637 |
if (iconWindow) { |
|
8638 |
wmhints.flags |= IconWindowHint; |
|
8639 |
wmhints.icon_window = iconWindow; |
|
8640 |
} |
|
8641 |
||
8642 |
wmhints.initial_state = IconicState; |
|
8643 |
wmhints.flags |= StateHint; |
|
8644 |
XSetWMHints(dpy, win, &wmhints); |
|
8645 |
} |
|
8646 |
||
8647 |
if (szhints.flags) { |
|
8648 |
XSetNormalHints(dpy, win, &szhints); |
|
8649 |
} |
|
8650 |
||
8651 |
XMapWindow(dpy, win); |
|
8652 |
RETURN ( self ); |
|
295 | 8653 |
} |
8654 |
%} |
|
8655 |
. |
|
8656 |
self primitiveFailed |
|
8657 |
! |
|
8658 |
||
1344 | 8659 |
mapWindow:aWindowId |
295 | 8660 |
"make a window visible" |
8661 |
||
8662 |
%{ /* NOCONTEXT */ |
|
8663 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8664 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8665 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8666 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
8667 |
RETURN ( self ); |
|
295 | 8668 |
} |
8669 |
%} |
|
8670 |
. |
|
8671 |
self primitiveFailed |
|
8672 |
! |
|
8673 |
||
1344 | 8674 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 8675 |
"move and resize a window" |
8676 |
||
8677 |
%{ /* NOCONTEXT */ |
|
8678 |
||
8679 |
int newWidth, newHeight; |
|
8680 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8681 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8682 |
&& __isExternalAddress(aWindowId) |
295 | 8683 |
&& __bothSmallInteger(w, h) |
8684 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 8685 |
newWidth = __intVal(w); |
8686 |
newHeight = __intVal(h); |
|
8687 |
if (newWidth < 1) newWidth = 1; |
|
8688 |
if (newHeight < 1) newHeight = 1; |
|
8689 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
8690 |
__intVal(x), __intVal(y), |
|
8691 |
newWidth, newHeight); |
|
8692 |
RETURN ( self ); |
|
295 | 8693 |
} |
8694 |
%} |
|
8695 |
. |
|
8696 |
self primitiveFailed |
|
8697 |
! |
|
8698 |
||
1344 | 8699 |
moveWindow:aWindowId x:x y:y |
295 | 8700 |
"move a window" |
8701 |
||
8702 |
%{ /* NOCONTEXT */ |
|
8703 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8704 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8705 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1344 | 8706 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
8707 |
RETURN ( self ); |
|
295 | 8708 |
} |
8709 |
%} |
|
8710 |
. |
|
8711 |
self primitiveFailed |
|
8712 |
! |
|
8713 |
||
1344 | 8714 |
raiseWindow:aWindowId |
295 | 8715 |
"bring a window to front" |
8716 |
||
8717 |
%{ /* NOCONTEXT */ |
|
8718 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8719 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8720 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8721 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
8722 |
RETURN ( self ); |
|
295 | 8723 |
} |
8724 |
%} |
|
8725 |
. |
|
8726 |
self primitiveFailed |
|
8727 |
! |
|
8728 |
||
1344 | 8729 |
resizeWindow:aWindowId width:w height:h |
295 | 8730 |
"resize a window" |
8731 |
||
8732 |
%{ /* NOCONTEXT */ |
|
8733 |
||
8734 |
int newWidth, newHeight; |
|
8735 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8736 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8737 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 8738 |
newWidth = __intVal(w); |
8739 |
newHeight = __intVal(h); |
|
8740 |
if (newWidth < 1) newWidth = 1; |
|
8741 |
if (newHeight < 1) newHeight = 1; |
|
8742 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
8743 |
RETURN ( self ); |
|
295 | 8744 |
} |
8745 |
%} |
|
8746 |
. |
|
8747 |
self primitiveFailed |
|
8748 |
! |
|
8749 |
||
1344 | 8750 |
setBackingStore:how in:aWindowId |
295 | 8751 |
"turn on/off backing-store for a window" |
8752 |
||
8753 |
%{ /* NOCONTEXT */ |
|
8754 |
||
8755 |
XSetWindowAttributes wa; |
|
8756 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8757 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8758 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8759 |
if (__INST(ignoreBackingStore) != true) { |
8760 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
8761 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
8762 |
else if (how == true) wa.backing_store = Always; |
|
8763 |
else wa.backing_store = 0; |
|
8764 |
BEGIN_INTERRUPTSBLOCKED |
|
8765 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
8766 |
END_INTERRUPTSBLOCKED |
|
8767 |
} |
|
8768 |
RETURN ( self ); |
|
295 | 8769 |
} |
8770 |
%}. |
|
8771 |
self primitiveFailed |
|
8772 |
! |
|
8773 |
||
1344 | 8774 |
setBitGravity:how in:aWindowId |
295 | 8775 |
"set bit gravity for a window" |
8776 |
||
8777 |
%{ /* NOCONTEXT */ |
|
8778 |
||
8779 |
XSetWindowAttributes wa; |
|
8780 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8781 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8782 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8783 |
if (how == @symbol(NorthWest)) { |
8784 |
wa.bit_gravity = NorthWestGravity; |
|
8785 |
} else if (how == @symbol(NorthEast)) { |
|
8786 |
wa.bit_gravity = NorthEastGravity; |
|
8787 |
} else if (how == @symbol(SouthWest)) { |
|
8788 |
wa.bit_gravity = SouthWestGravity; |
|
8789 |
} else if (how == @symbol(SouthEast)) { |
|
8790 |
wa.bit_gravity = SouthEastGravity; |
|
8791 |
} else if (how == @symbol(Center)) { |
|
8792 |
wa.bit_gravity = CenterGravity; |
|
8793 |
} else if (how == @symbol(North)) { |
|
8794 |
wa.bit_gravity = NorthGravity; |
|
8795 |
} else if (how == @symbol(South)) { |
|
8796 |
wa.bit_gravity = SouthGravity; |
|
8797 |
} else if (how == @symbol(West)) { |
|
8798 |
wa.bit_gravity = WestGravity; |
|
8799 |
} else if (how == @symbol(East)) { |
|
8800 |
wa.bit_gravity = EastGravity; |
|
8801 |
} else { |
|
8802 |
wa.bit_gravity = NorthWestGravity; |
|
8803 |
} |
|
8804 |
||
8805 |
BEGIN_INTERRUPTSBLOCKED |
|
8806 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
8807 |
END_INTERRUPTSBLOCKED |
|
8808 |
RETURN ( self ); |
|
295 | 8809 |
} |
8810 |
%}. |
|
8811 |
self primitiveFailed |
|
8812 |
! |
|
8813 |
||
1344 | 8814 |
setCursor:aCursorId in:aWindowId |
295 | 8815 |
"define a windows cursor" |
8816 |
||
8817 |
%{ /* NOCONTEXT */ |
|
8818 |
||
8819 |
Display *dpy = myDpy; |
|
8820 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8821 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8822 |
&& __isExternalAddress(aWindowId) |
295 | 8823 |
&& __isExternalAddress(aCursorId)) { |
1344 | 8824 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
8825 |
RETURN ( self ); |
|
295 | 8826 |
} |
8827 |
%}. |
|
8828 |
self primitiveFailed |
|
8829 |
! |
|
8830 |
||
1344 | 8831 |
setIconName:aString in:aWindowId |
295 | 8832 |
"define a windows iconname" |
8833 |
||
8834 |
%{ /* NOCONTEXT */ |
|
8835 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8836 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8837 |
&& __isExternalAddress(aWindowId) |
295 | 8838 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8839 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8840 |
RETURN ( self ); |
|
295 | 8841 |
} |
8842 |
%}. |
|
8843 |
self primitiveFailed |
|
8844 |
! |
|
8845 |
||
1344 | 8846 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 8847 |
"turn on/off save-under for a window" |
8848 |
||
8849 |
%{ /* NOCONTEXT */ |
|
8850 |
||
8851 |
XSetWindowAttributes wa; |
|
8852 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8853 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8854 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8855 |
if (__INST(hasSaveUnder) == true) { |
8856 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
8857 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
8858 |
} |
|
8859 |
RETURN ( self ); |
|
295 | 8860 |
} |
8861 |
%}. |
|
8862 |
self primitiveFailed |
|
8863 |
! |
|
8864 |
||
1344 | 8865 |
setTransient:aWindowId for:aMainWindowId |
295 | 8866 |
"set aWindowId to be a transient of aMainWindow" |
8867 |
||
8868 |
%{ /* NOCONTEXT */ |
|
8869 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8870 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8871 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8872 |
Window w; |
8873 |
||
8874 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
8875 |
w = (Window) 0; |
|
8876 |
} else { |
|
8877 |
if (__isExternalAddress(aMainWindowId)) { |
|
8878 |
w = _WindowVal(aMainWindowId); |
|
8879 |
} else { |
|
8880 |
goto getOutOfHere; |
|
8881 |
} |
|
8882 |
} |
|
8883 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
|
8884 |
RETURN ( self ); |
|
295 | 8885 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
8886 |
getOutOfHere: ; |
295 | 8887 |
%}. |
8888 |
self primitiveFailed |
|
8889 |
! |
|
8890 |
||
1344 | 8891 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 8892 |
"set the windows background color. This is the color with which |
8893 |
the view is filled whenever exposed. Do not confuse this with |
|
8894 |
the background drawing color, which is used with opaque drawing." |
|
8895 |
||
8896 |
%{ /* NOCONTEXT */ |
|
8897 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8898 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8899 |
&& __isExternalAddress(aWindowId) |
295 | 8900 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8901 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8902 |
RETURN ( self ); |
|
295 | 8903 |
} |
8904 |
%}. |
|
8905 |
self primitiveFailed |
|
8906 |
! |
|
8907 |
||
1344 | 8908 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 8909 |
"set the windows background pattern to be a form. |
8910 |
This is the pattern with which the view is filled whenever exposed. |
|
8911 |
Do not confuse this with the background drawing color, which is used |
|
8912 |
with opaque drawing." |
|
8913 |
||
8914 |
%{ /* NOCONTEXT */ |
|
8915 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8916 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8917 |
&& __isExternalAddress(aWindowId) |
295 | 8918 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8919 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8920 |
RETURN ( self ); |
|
295 | 8921 |
} |
8922 |
%}. |
|
8923 |
self primitiveFailed |
|
8924 |
! |
|
8925 |
||
1344 | 8926 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 8927 |
"set the windows border color" |
8928 |
||
8929 |
%{ /* NOCONTEXT */ |
|
8930 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8931 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8932 |
&& __isExternalAddress(aWindowId) |
295 | 8933 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8934 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8935 |
RETURN ( self ); |
|
295 | 8936 |
} |
8937 |
%}. |
|
8938 |
self primitiveFailed |
|
8939 |
! |
|
8940 |
||
1344 | 8941 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 8942 |
"set the windows border pattern" |
8943 |
||
8944 |
%{ /* NOCONTEXT */ |
|
8945 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8946 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8947 |
&& __isExternalAddress(aWindowId) |
295 | 8948 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8949 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8950 |
RETURN ( self ); |
|
295 | 8951 |
} |
8952 |
%} |
|
8953 |
. |
|
8954 |
self primitiveFailed |
|
8955 |
! |
|
8956 |
||
1344 | 8957 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 8958 |
"set the windows border shape" |
8959 |
||
8960 |
hasShapeExtension ifFalse:[^ self]. |
|
8961 |
||
8962 |
%{ /* NOCONTEXT */ |
|
8963 |
||
8964 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8965 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8966 |
&& __isExternalAddress(aWindowId) |
295 | 8967 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8968 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
8969 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
8970 |
RETURN ( self ); |
|
295 | 8971 |
} |
8972 |
#endif |
|
8973 |
%}. |
|
8974 |
self primitiveFailed |
|
8975 |
! |
|
8976 |
||
1344 | 8977 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 8978 |
"set the windows border width" |
8979 |
||
8980 |
%{ /* NOCONTEXT */ |
|
8981 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8982 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8983 |
&& __isExternalAddress(aWindowId) |
295 | 8984 |
&& __isSmallInteger(aNumber)) { |
1344 | 8985 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
8986 |
RETURN ( self ); |
|
295 | 8987 |
} |
8988 |
%}. |
|
8989 |
self primitiveFailed |
|
8990 |
! |
|
8991 |
||
1344 | 8992 |
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
|
8993 |
"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
|
8994 |
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
|
8995 |
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
|
8996 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8997 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8998 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8999 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9000 |
XClassHint classhint; |
9001 |
||
9002 |
classhint.res_class = classhint.res_name = 0; |
|
9003 |
||
9004 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
9005 |
classhint.res_class = (char *)_stringVal(wClass); |
|
9006 |
} else if (wClass != nil) |
|
9007 |
goto error; |
|
9008 |
||
9009 |
if (__isString(wName) || __isSymbol(wName)) { |
|
9010 |
classhint.res_name = (char *)_stringVal(wName); |
|
9011 |
} else if (wName != nil) |
|
9012 |
goto error; |
|
9013 |
||
9014 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
|
9015 |
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
|
9016 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9017 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9018 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9019 |
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
|
9020 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
9021 |
|
1344 | 9022 |
setWindowGravity:how in:aWindowId |
295 | 9023 |
"set window gravity for a window" |
9024 |
||
9025 |
%{ /* NOCONTEXT */ |
|
9026 |
||
9027 |
XSetWindowAttributes wa; |
|
9028 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9029 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9030 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9031 |
if (how == @symbol(NorthWest)) { |
9032 |
wa.win_gravity = NorthWestGravity; |
|
9033 |
} else if (how == @symbol(NorthEast)) { |
|
9034 |
wa.win_gravity = NorthEastGravity; |
|
9035 |
} else if (how == @symbol(SouthWest)) { |
|
9036 |
wa.win_gravity = SouthWestGravity; |
|
9037 |
} else if (how == @symbol(SouthEast)) { |
|
9038 |
wa.win_gravity = SouthEastGravity; |
|
9039 |
} else if (how == @symbol(Center)) { |
|
9040 |
wa.win_gravity = CenterGravity; |
|
9041 |
} else if (how == @symbol(North)) { |
|
9042 |
wa.win_gravity = NorthGravity; |
|
9043 |
} else if (how == @symbol(South)) { |
|
9044 |
wa.win_gravity = SouthGravity; |
|
9045 |
} else if (how == @symbol(West)) { |
|
9046 |
wa.win_gravity = WestGravity; |
|
9047 |
} else if (how == @symbol(East)) { |
|
9048 |
wa.win_gravity = EastGravity; |
|
9049 |
} else { |
|
9050 |
wa.win_gravity = NorthWestGravity; |
|
9051 |
} |
|
9052 |
||
9053 |
BEGIN_INTERRUPTSBLOCKED |
|
9054 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
9055 |
END_INTERRUPTSBLOCKED |
|
9056 |
RETURN ( self ); |
|
295 | 9057 |
} |
9058 |
%}. |
|
9059 |
self primitiveFailed |
|
9060 |
! |
|
9061 |
||
1344 | 9062 |
setWindowIcon:aForm in:aWindowId |
295 | 9063 |
"define a bitmap to be used as icon" |
9064 |
||
9065 |
|iconId| |
|
9066 |
||
9067 |
aForm notNil ifTrue:[ |
|
1344 | 9068 |
iconId := aForm id |
295 | 9069 |
]. |
9070 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9071 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9072 |
&& __isExternalAddress(iconId) |
295 | 9073 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9074 |
XWMHints hints; |
9075 |
||
9076 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
9077 |
hints.flags = IconPixmapHint; |
|
9078 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
9079 |
RETURN ( self ); |
|
295 | 9080 |
} |
9081 |
%}. |
|
9082 |
self primitiveFailed |
|
9083 |
! |
|
9084 |
||
1376 | 9085 |
setWindowIcon:aForm mask:aMaskForm in:aWindowId |
1535 | 9086 |
"define a windows icon and (optional) iconMask." |
9087 |
||
9088 |
|iconId maskId| |
|
9089 |
||
9090 |
aForm notNil ifTrue:[ |
|
9091 |
iconId := aForm id |
|
9092 |
]. |
|
9093 |
aMaskForm notNil ifTrue:[ |
|
9094 |
maskId := aMaskForm id. |
|
9095 |
]. |
|
9096 |
%{ |
|
9097 |
if (ISCONNECTED |
|
9098 |
&& __isExternalAddress(iconId) |
|
9099 |
&& __isExternalAddress(aWindowId)) { |
|
9100 |
XWMHints hints; |
|
9101 |
||
9102 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
9103 |
hints.flags = IconPixmapHint; |
|
9104 |
if ((maskId != nil) |
|
9105 |
&& __isExternalAddress(maskId)) { |
|
9106 |
hints.icon_mask = _PixmapVal(maskId); |
|
9107 |
hints.flags |= IconMaskHint; |
|
9108 |
} |
|
9109 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
9110 |
RETURN ( self ); |
|
9111 |
} |
|
9112 |
%}. |
|
9113 |
self primitiveFailed |
|
9114 |
||
1376 | 9115 |
! |
9116 |
||
1344 | 9117 |
setWindowIconWindow:aView in:aWindowId |
295 | 9118 |
"define a window to be used as icon" |
9119 |
||
9120 |
|iconWindowId| |
|
9121 |
||
9122 |
aView notNil ifTrue:[ |
|
1344 | 9123 |
iconWindowId := aView id |
295 | 9124 |
]. |
9125 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9126 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9127 |
&& __isExternalAddress(iconWindowId) |
295 | 9128 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9129 |
XWMHints wmhints; |
9130 |
||
9131 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
9132 |
wmhints.flags = IconWindowHint; |
|
9133 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
9134 |
RETURN ( self ); |
|
295 | 9135 |
} |
9136 |
%}. |
|
9137 |
self primitiveFailed |
|
9138 |
! |
|
9139 |
||
1344 | 9140 |
setWindowName:aString in:aWindowId |
295 | 9141 |
"define a windows name" |
9142 |
||
9143 |
%{ /* NOCONTEXT */ |
|
9144 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9145 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9146 |
&& __isExternalAddress(aWindowId) |
295 | 9147 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 9148 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
9149 |
RETURN ( self ); |
|
295 | 9150 |
} |
9151 |
%}. |
|
9152 |
self primitiveFailed |
|
9153 |
! |
|
9154 |
||
1344 | 9155 |
setWindowShape:aPixmapId in:aWindowId |
295 | 9156 |
"set the windows shape" |
9157 |
||
9158 |
hasShapeExtension ifFalse:[^ self]. |
|
9159 |
||
9160 |
%{ /* NOCONTEXT */ |
|
9161 |
||
9162 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9163 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9164 |
&& __isExternalAddress(aWindowId) |
295 | 9165 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9166 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
9167 |
0, 0, |
|
9168 |
_PixmapVal(aPixmapId), ShapeSet); |
|
9169 |
RETURN ( self ); |
|
295 | 9170 |
} |
9171 |
#endif |
|
9172 |
%}. |
|
9173 |
self primitiveFailed |
|
9174 |
! |
|
9175 |
||
1344 | 9176 |
unmapWindow:aWindowId |
295 | 9177 |
"make a window invisible" |
9178 |
||
9179 |
%{ /* NOCONTEXT */ |
|
9180 |
||
1214 | 9181 |
if (!ISCONNECTED) { |
1344 | 9182 |
RETURN ( self ); |
1214 | 9183 |
} |
9184 |
||
9185 |
if (__isExternalAddress(aWindowId)) { |
|
1344 | 9186 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
9187 |
RETURN ( self ); |
|
9188 |
} |
|
9189 |
%}. |
|
295 | 9190 |
self primitiveFailed |
1535 | 9191 |
! |
9192 |
||
9193 |
windowIsIconified:aWindowId |
|
9194 |
"return true, if some window is iconified. |
|
9195 |
The passed windowID may be an alien windows id." |
|
9196 |
||
9197 |
%{ /* NOCONTEXT */ |
|
9198 |
||
9199 |
if (ISCONNECTED |
|
9200 |
&& __isExternalAddress(aWindowId)) { |
|
9201 |
Atom JunkAtom; |
|
9202 |
int JunkInt; |
|
9203 |
unsigned long WinState,JunkLong; |
|
9204 |
unsigned char *Property; |
|
9205 |
Atom WM_STATE_Atom; |
|
9206 |
||
9207 |
if (__INST(wmStateAtom) != nil) { |
|
9208 |
WM_STATE_Atom = _AtomVal(__INST(wmStateAtom)); |
|
9209 |
||
9210 |
XGetWindowProperty(myDpy, _WindowVal(aWindowId), |
|
9211 |
WM_STATE_Atom, |
|
9212 |
0L, 2L, False, AnyPropertyType, |
|
9213 |
&JunkAtom,&JunkInt,&WinState,&JunkLong, |
|
9214 |
&Property); |
|
9215 |
WinState=(unsigned long)(*((long*)Property)); |
|
9216 |
if (WinState==3) { |
|
9217 |
RETURN (true); |
|
9218 |
} |
|
9219 |
} |
|
9220 |
RETURN (false); |
|
9221 |
} |
|
9222 |
%}. |
|
9223 |
self primitiveFailed |
|
9224 |
||
9225 |
||
9226 |
||
295 | 9227 |
! ! |
9228 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9229 |
!XWorkstation class methodsFor:'documentation'! |
295 | 9230 |
|
9231 |
version |
|
1576
b75c64bb5849
care for encoding & registry
Claus Gittinger <cg@exept.de>
parents:
1567
diff
changeset
|
9232 |
^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.236 1997-04-10 17:36:06 cg Exp $' |
295 | 9233 |
! ! |
9234 |
XWorkstation initialize! |