author | Claus Gittinger <cg@exept.de> |
Sun, 06 Apr 1997 14:31:28 +0200 | |
changeset 1557 | c37fd33dc7d8 |
parent 1556 | cdc53ab8ceff |
child 1558 | e1eb73ed3360 |
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 |
||
2240 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2241 |
"change a cursors colors" |
|
2242 |
||
2243 |
|fgR fgG fgB bgR bgG bgB| |
|
2244 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2245 |
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
|
2246 |
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
|
2247 |
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
|
2248 |
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
|
2249 |
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
|
2250 |
bgB := bgColor scaledBlue. |
0 | 2251 |
%{ |
295 | 2252 |
XColor fgcolor, bgcolor; |
2253 |
||
1209 | 2254 |
if (ISCONNECTED |
2255 |
&& __isExternalAddress(aCursorId) |
|
295 | 2256 |
&& __bothSmallInteger(fgG, fgB) |
2257 |
&& __bothSmallInteger(bgR, bgG) |
|
2258 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2259 |
||
1344 | 2260 |
fgcolor.red = __intVal(fgR); |
2261 |
fgcolor.green= __intVal(fgG); |
|
2262 |
fgcolor.blue = __intVal(fgB); |
|
2263 |
bgcolor.red = __intVal(bgR); |
|
2264 |
bgcolor.green= __intVal(bgG); |
|
2265 |
bgcolor.blue = __intVal(bgB); |
|
2266 |
BEGIN_INTERRUPTSBLOCKED |
|
2267 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
2268 |
END_INTERRUPTSBLOCKED |
|
2269 |
RETURN ( self ); |
|
72 | 2270 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2271 |
%}. |
0 | 2272 |
self primitiveFailed |
70 | 2273 |
! |
2274 |
||
295 | 2275 |
createCursorShape:aShape |
974 | 2276 |
"create a cursor given a shape-symbol. This only works |
2277 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2278 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2279 |
|
2280 |
|number id| |
|
2281 |
||
2282 |
displayId isNil ifTrue:[ |
|
1344 | 2283 |
self primitiveFailed. |
2284 |
^ nil |
|
295 | 2285 |
]. |
2286 |
number := self shapeNumberFromSymbol:aShape. |
|
2287 |
%{ |
|
2288 |
Cursor newCursor; |
|
2289 |
||
1209 | 2290 |
if (ISCONNECTED |
2291 |
&& __isSmallInteger(number)) { |
|
1344 | 2292 |
BEGIN_INTERRUPTSBLOCKED |
2293 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2294 |
#ifdef COUNT_RESOURCES |
1344 | 2295 |
if (newCursor) |
2296 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2297 |
#endif |
1344 | 2298 |
END_INTERRUPTSBLOCKED |
2299 |
if (newCursor != (Cursor)0) { |
|
2300 |
id = __MKOBJ(newCursor); |
|
2301 |
} |
|
0 | 2302 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2303 |
%}. |
295 | 2304 |
^ id |
2305 |
! |
|
2306 |
||
974 | 2307 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2308 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2309 |
||
2310 |
|id sourceId maskId| |
|
2311 |
||
2312 |
displayId isNil ifTrue:[ |
|
1344 | 2313 |
self primitiveFailed. |
2314 |
^ nil |
|
295 | 2315 |
]. |
2316 |
sourceId := sourceForm id. |
|
2317 |
maskId := maskForm id. |
|
2318 |
%{ |
|
2319 |
Cursor newCursor; |
|
2320 |
XColor fgColor, bgColor; |
|
2321 |
||
1209 | 2322 |
if (ISCONNECTED |
2323 |
&& __isExternalAddress(sourceId) |
|
295 | 2324 |
&& __isExternalAddress(maskId) |
2325 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2326 |
fgColor.red = 0; /* fg is black */ |
2327 |
fgColor.green = 0; |
|
2328 |
fgColor.blue = 0; |
|
2329 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2330 |
bgColor.green = 0xFFFF; |
|
2331 |
bgColor.blue = 0xFFFF; |
|
2332 |
||
2333 |
BEGIN_INTERRUPTSBLOCKED |
|
2334 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2335 |
_PixmapVal(sourceId), |
|
2336 |
_PixmapVal(maskId), |
|
2337 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2338 |
#ifdef COUNT_RESOURCES |
1344 | 2339 |
if (newCursor) |
2340 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2341 |
#endif |
1344 | 2342 |
END_INTERRUPTSBLOCKED |
2343 |
if (newCursor != (Cursor)0) { |
|
2344 |
id = __MKOBJ(newCursor); |
|
2345 |
} |
|
0 | 2346 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2347 |
%}. |
295 | 2348 |
^ id |
2349 |
! |
|
2350 |
||
2351 |
destroyCursor:aCursorId |
|
974 | 2352 |
"release a cursor - frees any device resources" |
0 | 2353 |
|
2354 |
%{ /* NOCONTEXT */ |
|
2355 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2356 |
if (! ISCONNECTED) { |
1344 | 2357 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2358 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2359 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2360 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2361 |
Cursor curs = _CursorVal(aCursorId); |
2362 |
||
2363 |
if (curs) { |
|
2364 |
BEGIN_INTERRUPTSBLOCKED |
|
2365 |
XFreeCursor(myDpy, curs); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2366 |
#ifdef COUNT_RESOURCES |
1344 | 2367 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2368 |
#endif |
1344 | 2369 |
END_INTERRUPTSBLOCKED |
2370 |
} |
|
2371 |
RETURN ( self ); |
|
0 | 2372 |
} |
974 | 2373 |
%}. |
0 | 2374 |
self primitiveFailed |
295 | 2375 |
! |
2376 |
||
974 | 2377 |
needDeviceFormsForCursor |
2378 |
^ true |
|
2379 |
! |
|
2380 |
||
295 | 2381 |
shapeNumberFromSymbol:shape |
974 | 2382 |
"given a shape-symbol, return the corresponding cursor-number, |
2383 |
or nil if no such standard cursor exists." |
|
295 | 2384 |
|
2385 |
"this is pure X-knowlegde - but you may easily add more" |
|
2386 |
||
2387 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2388 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2389 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2390 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2391 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2392 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2393 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2394 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2395 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2396 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2397 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2398 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2399 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2400 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2401 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2402 |
((shape == #origin) |
|
2403 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2404 |
((shape == #corner) |
|
2405 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2406 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2407 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2408 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2409 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2410 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2411 |
|
2412 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2413 |
^ nil |
0 | 2414 |
! ! |
2415 |
||
1543 | 2416 |
!XWorkstation methodsFor:'drag & drop'! |
2417 |
||
1556 | 2418 |
dndDrop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
2419 |
"drop something in some alien view, using the DND protocol. |
|
2420 |
Returns false, if the drop could not be performed." |
|
2421 |
||
2422 |
|msgType dropColl anyFile anyDir anyText anyOther |
|
2423 |
dropType dropTypeCode strings sz idx val| |
|
2424 |
||
2425 |
(msgType := self atomIDOf:'DndProtocol') notNil ifTrue:[ |
|
2426 |
||
2427 |
"/ DND can drop files, file, dir, links, dirLink and text |
|
2428 |
"/ check for this. |
|
2429 |
||
2430 |
dropObjects isCollection ifFalse:[ |
|
2431 |
dropColl := Array with:dropObjects |
|
2432 |
] ifTrue:[ |
|
2433 |
dropColl := dropObjects |
|
2434 |
]. |
|
2435 |
anyFile := anyDir := anyText := anyOther := false. |
|
2436 |
dropColl do:[:aDropObject | |
|
2437 |
aDropObject isFileObject ifTrue:[ |
|
2438 |
aDropObject theObject isDirectory ifTrue:[ |
|
2439 |
anyDir := true |
|
2440 |
] ifFalse:[ |
|
2441 |
anyFile := true |
|
2442 |
] |
|
2443 |
] ifFalse:[ |
|
2444 |
aDropObject isTextObject ifTrue:[ |
|
2445 |
anyText := true |
|
2446 |
] ifFalse:[ |
|
2447 |
anyOther := true |
|
2448 |
] |
|
2449 |
] |
|
2450 |
]. |
|
2451 |
||
2452 |
anyOther ifTrue:[ |
|
2453 |
"/ DND does not support this ... |
|
2454 |
'XWorkstation [info]: DND can only drop files or text' infoPrintCR. |
|
2455 |
^ false |
|
2456 |
]. |
|
2457 |
anyText ifTrue:[ |
|
2458 |
(anyFile or:[anyDir]) ifTrue:[ |
|
2459 |
"/ DND does not support mixed types |
|
2460 |
'XWorkstation [info]: DND cannot drop both files and text' infoPrintCR. |
|
2461 |
^ false |
|
2462 |
] |
|
2463 |
]. |
|
2464 |
||
2465 |
anyFile ifTrue:[ |
|
2466 |
dropType := #DndFiles. |
|
2467 |
dropColl size == 1 ifTrue:[ |
|
2468 |
dropType := #DndFile |
|
2469 |
] |
|
2470 |
] ifFalse:[ |
|
2471 |
anyDir ifTrue:[ |
|
2472 |
dropType := #DndFiles. |
|
2473 |
dropColl size == 1 ifTrue:[ |
|
2474 |
dropType := #DndDir |
|
2475 |
] |
|
2476 |
] ifFalse:[ |
|
2477 |
anyText ifTrue:[ |
|
2478 |
dropColl size == 1 ifTrue:[ |
|
2479 |
dropType := #DndText |
|
2480 |
] ifFalse:[ |
|
2481 |
"/ can only drop a single text object |
|
2482 |
'XWorkstation [info]: DND can only drop a single text' infoPrintCR. |
|
2483 |
^ false |
|
2484 |
] |
|
2485 |
] ifFalse:[ |
|
2486 |
"/ mhmh ... |
|
2487 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
|
2488 |
^ false |
|
2489 |
] |
|
2490 |
] |
|
2491 |
]. |
|
2492 |
||
2493 |
dropTypeCode := self dndDropTypes indexOf:dropType. |
|
2494 |
dropTypeCode == 0 ifTrue:[ |
|
2495 |
'XWorkstation [info]: DND cannot drop this' infoPrintCR. |
|
2496 |
^ false |
|
2497 |
]. |
|
2498 |
dropTypeCode := dropTypeCode - 1. |
|
2499 |
||
2500 |
||
2501 |
"/ place the selection inTo the DndSelection property |
|
2502 |
"/ of the rootView ... |
|
2503 |
"/ ... need a single string, with 0-terminated parts. |
|
2504 |
||
2505 |
strings := OrderedCollection new. |
|
2506 |
sz := 0. |
|
2507 |
dropColl do:[:anObject | |
|
2508 |
|s| |
|
2509 |
||
2510 |
anObject isFileObject ifTrue:[ |
|
2511 |
s := anObject theObject pathName asString |
|
2512 |
] ifFalse:[ |
|
2513 |
s := anObject theObject asString |
|
2514 |
]. |
|
2515 |
strings add:s. |
|
2516 |
sz := sz + (s size) + 1. |
|
2517 |
]. |
|
2518 |
val := String new:sz. |
|
2519 |
idx := 1. |
|
2520 |
strings do:[:aString | |
|
2521 |
val replaceFrom:idx to:(idx + aString size - 1) with:aString startingAt:1. |
|
2522 |
idx := idx + aString size. |
|
2523 |
val at:idx put:(Character value:0). |
|
2524 |
idx := idx + 1 |
|
2525 |
]. |
|
2526 |
||
1557
c37fd33dc7d8
don use strlen when setting a string prop;
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2527 |
val size printCR. |
1556 | 2528 |
self |
2529 |
setProperty:(self atomIDOf:'DndSelection') |
|
2530 |
type:(stringAtom) |
|
2531 |
value:val |
|
2532 |
for:rootId. |
|
2533 |
||
2534 |
^ self |
|
2535 |
sendClientEvent:msgType |
|
2536 |
format:32 |
|
2537 |
to:destinationId |
|
2538 |
data1:dropTypeCode |
|
2539 |
data2:0 |
|
2540 |
data3:(destinationId) |
|
2541 |
data4:nil |
|
2542 |
data5:nil. |
|
2543 |
]. |
|
2544 |
||
2545 |
^ false |
|
2546 |
||
2547 |
"Created: 6.4.1997 / 13:39:37 / cg" |
|
1557
c37fd33dc7d8
don use strlen when setting a string prop;
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2548 |
"Modified: 6.4.1997 / 14:25:38 / cg" |
1556 | 2549 |
! |
2550 |
||
2551 |
dndDropTypes |
|
2552 |
"return the dropTypes as supported by DND" |
|
2553 |
||
2554 |
^ #( |
|
2555 |
DndUnknown "/ 0 |
|
2556 |
DndRawData "/ 1 |
|
2557 |
DndFile "/ 2 |
|
2558 |
DndFiles "/ 3 |
|
2559 |
DndText "/ 4 |
|
2560 |
DndDir "/ 5 |
|
2561 |
DndLink "/ 6 |
|
2562 |
DndExe "/ 7 |
|
2563 |
) |
|
2564 |
||
2565 |
"Created: 6.4.1997 / 12:57:56 / cg" |
|
2566 |
"Modified: 6.4.1997 / 13:38:52 / cg" |
|
2567 |
! |
|
2568 |
||
1543 | 2569 |
drop:dropObjects inWindowID:destinationId position:destinationPoint rootPosition:rootPoint |
1556 | 2570 |
"drop something in some alien view. |
2571 |
Returns false, if the drop could not be performed." |
|
2572 |
||
2573 |
"/ |
|
1543 | 2574 |
"/ see, if the display supports the DND protocol ... |
1556 | 2575 |
"/ |
1543 | 2576 |
(self atomIDOf:'DndProtocol') notNil ifTrue:[ |
1556 | 2577 |
^ self |
2578 |
dndDrop:dropObjects |
|
2579 |
inWindowID:destinationId |
|
2580 |
position:destinationPoint |
|
2581 |
rootPosition:rootPoint |
|
1543 | 2582 |
]. |
2583 |
||
1556 | 2584 |
"/ add more drag&drop protocols here. |
2585 |
||
2586 |
^ false |
|
2587 |
||
2588 |
"Modified: 6.4.1997 / 13:40:37 / cg" |
|
1543 | 2589 |
! ! |
2590 |
||
0 | 2591 |
!XWorkstation methodsFor:'drawing'! |
2592 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2593 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2594 |
"do a bit-blt; copy bits from the rectangle defined by |
2595 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2596 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2597 |
argument is not integer." |
|
0 | 2598 |
|
2599 |
%{ /* NOCONTEXT */ |
|
2600 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2601 |
GC gc; |
0 | 2602 |
Drawable source, dest; |
2603 |
||
1209 | 2604 |
if (ISCONNECTED |
2605 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2606 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2607 |
&& __isExternalAddress(destId) |
97 | 2608 |
&& __bothSmallInteger(w, h) |
2609 |
&& __bothSmallInteger(srcX, srcY) |
|
2610 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2611 |
gc = _GCVal(dstGCId); |
2612 |
source = (Drawable) _WindowVal(sourceId); |
|
2613 |
dest = (Drawable) _WindowVal(destId); |
|
2614 |
XCopyArea(myDpy, source, dest, gc, |
|
2615 |
__intVal(srcX), __intVal(srcY), |
|
2616 |
__intVal(w), __intVal(h), |
|
2617 |
__intVal(dstX), __intVal(dstY)); |
|
2618 |
RETURN ( self ); |
|
0 | 2619 |
} |
118 | 2620 |
%}. |
2621 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2622 |
or any non integer coordinate" |
|
2623 |
||
0 | 2624 |
self primitiveFailed |
2625 |
! |
|
2626 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2627 |
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
|
2628 |
"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
|
2629 |
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
|
2630 |
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
|
2631 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2632 |
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
|
2633 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2634 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2635 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2636 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2637 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2638 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2639 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2640 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2641 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2642 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2643 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2644 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2645 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2646 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2647 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2648 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2649 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2650 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2651 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2652 |
XCopyArea(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2653 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2654 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2655 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2656 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2657 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2658 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2659 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2660 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2661 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2662 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2663 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2664 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2665 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2666 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2667 |
"do a bit-blt, but only copy the low-bit plane; |
2668 |
copy bits from the rectangle defined by |
|
2669 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2670 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2671 |
argument is not integer." |
|
0 | 2672 |
|
2673 |
%{ /* NOCONTEXT */ |
|
2674 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2675 |
GC gc; |
0 | 2676 |
Drawable source, dest; |
2677 |
||
1209 | 2678 |
if (ISCONNECTED |
2679 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2680 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2681 |
&& __isExternalAddress(destId) |
97 | 2682 |
&& __bothSmallInteger(w, h) |
2683 |
&& __bothSmallInteger(srcX, srcY) |
|
2684 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2685 |
gc = _GCVal(dstGCId); |
2686 |
source = (Drawable) _WindowVal(sourceId); |
|
2687 |
dest = (Drawable) _WindowVal(destId); |
|
2688 |
XCopyPlane(myDpy, source, dest, gc, |
|
2689 |
__intVal(srcX), __intVal(srcY), |
|
2690 |
__intVal(w), __intVal(h), |
|
2691 |
__intVal(dstX), __intVal(dstY), 1); |
|
2692 |
RETURN ( self ); |
|
0 | 2693 |
} |
118 | 2694 |
%}. |
2695 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2696 |
or any non integer coordinate" |
|
2697 |
||
0 | 2698 |
self primitiveFailed |
2699 |
! |
|
2700 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2701 |
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
|
2702 |
"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
|
2703 |
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
|
2704 |
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
|
2705 |
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
|
2706 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2707 |
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
|
2708 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2709 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2710 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2711 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2712 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2713 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2714 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2715 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2716 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2717 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2718 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2719 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2720 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2721 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2722 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2723 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2724 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2725 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2726 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2727 |
XCopyPlane(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2728 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2729 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2730 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2731 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2732 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2733 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2734 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2735 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2736 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2737 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2738 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2739 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2740 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2741 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2742 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2743 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2744 |
|
2745 |
%{ /* NOCONTEXT */ |
|
2746 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2747 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2748 |
Window win; |
0 | 2749 |
int w, h, angle1, angle2; |
2750 |
double f; |
|
2751 |
||
97 | 2752 |
if (__isSmallInteger(startAngle)) |
1344 | 2753 |
angle1 = __intVal(startAngle) * 64; |
36 | 2754 |
else if (__isFloat(startAngle)) { |
1344 | 2755 |
f = __floatVal(startAngle); |
2756 |
angle1 = f * 64; |
|
0 | 2757 |
} |
97 | 2758 |
if (__isSmallInteger(angle)) |
1344 | 2759 |
angle2 = __intVal(angle) * 64; |
36 | 2760 |
else if (__isFloat(angle)) { |
1344 | 2761 |
f = __floatVal(angle); |
2762 |
angle2 = f * 64; |
|
0 | 2763 |
} |
1209 | 2764 |
if (ISCONNECTED |
2765 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2766 |
&& __isExternalAddress(aDrawableId) |
97 | 2767 |
&& __bothSmallInteger(x, y) |
2768 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2769 |
win = _WindowVal(aDrawableId); |
2770 |
gc = _GCVal(aGCId); |
|
2771 |
w = __intVal(width); |
|
2772 |
h = __intVal(height); |
|
2773 |
/* |
|
2774 |
* need this check here: some servers simply dump core with bad args |
|
2775 |
*/ |
|
2776 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2777 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2778 |
w, h, angle1, angle2); |
|
2779 |
} |
|
2780 |
RETURN ( self ); |
|
0 | 2781 |
} |
73 | 2782 |
%}. |
2783 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2784 |
self primitiveFailed |
2785 |
! |
|
2786 |
||
295 | 2787 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2788 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2789 |
||
2790 |
%{ /* NOCONTEXT */ |
|
2791 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2792 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2793 |
Window win; |
295 | 2794 |
|
1209 | 2795 |
if (ISCONNECTED |
2796 |
&& __isExternalAddress(aGCId) |
|
295 | 2797 |
&& __isExternalAddress(aDrawableId) |
2798 |
&& __bothSmallInteger(x0, y0) |
|
2799 |
&& __bothSmallInteger(x1, y1)) { |
|
1511
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2800 |
gc = _GCVal(aGCId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2801 |
win = _WindowVal(aDrawableId); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2802 |
|
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2803 |
if ((x0 == x1) && (y0 == y1)) { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2804 |
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
|
2805 |
} else { |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2806 |
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
|
2807 |
__intVal(x1), __intVal(y1)); |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2808 |
} |
978a3b73b657
in drawLine: if startPoint == endPoint, draw a single point
Claus Gittinger <cg@exept.de>
parents:
1491
diff
changeset
|
2809 |
RETURN ( self ); |
295 | 2810 |
} |
2811 |
%}. |
|
2812 |
"badGC, badDrawable or coordinates not integer" |
|
2813 |
self primitiveFailed |
|
2814 |
! |
|
2815 |
||
2816 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2817 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2818 |
||
2819 |
%{ /* NOCONTEXT */ |
|
2820 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2821 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2822 |
Window win; |
295 | 2823 |
|
1209 | 2824 |
if (ISCONNECTED |
2825 |
&& __isExternalAddress(aGCId) |
|
295 | 2826 |
&& __isExternalAddress(aDrawableId) |
2827 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2828 |
gc = _GCVal(aGCId); |
2829 |
win = _WindowVal(aDrawableId); |
|
2830 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
|
2831 |
RETURN ( self ); |
|
295 | 2832 |
} |
2833 |
%}. |
|
2834 |
"badGC, badDrawable or x/y not integer" |
|
2835 |
self primitiveFailed |
|
2836 |
! |
|
2837 |
||
2838 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2839 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2840 |
define the polygon. |
|
2841 |
If any coordinate is not integer, an error is triggered." |
|
2842 |
||
2843 |
|numberOfPoints newPoints| |
|
2844 |
||
2845 |
numberOfPoints := aPolygon size. |
|
2846 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2847 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2848 |
Window win; |
295 | 2849 |
OBJ point, x, y; |
2850 |
int i, num; |
|
2851 |
XPoint *points; |
|
2852 |
XPoint qPoints[100]; |
|
377 | 2853 |
int mustFree = 0; |
295 | 2854 |
|
1209 | 2855 |
if (ISCONNECTED |
2856 |
&& __isExternalAddress(aGCId) |
|
295 | 2857 |
&& __isExternalAddress(aDrawableId) |
2858 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 2859 |
gc = _GCVal(aGCId); |
2860 |
win = _WindowVal(aDrawableId); |
|
2861 |
num = __intVal(numberOfPoints); |
|
2862 |
/* |
|
2863 |
* avoid a (slow) malloc, if the number of points is small |
|
2864 |
*/ |
|
2865 |
if (num > 100) { |
|
2866 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2867 |
if (! points) goto fail; |
|
2868 |
mustFree = 1; |
|
2869 |
} else |
|
2870 |
points = qPoints; |
|
2871 |
||
2872 |
for (i=0; i<num; i++) { |
|
2873 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2874 |
if (! __isPoint(point)) goto fail; |
|
2875 |
x = _point_X(point); |
|
2876 |
y = _point_Y(point); |
|
2877 |
if (! __bothSmallInteger(x, y)) |
|
2878 |
goto fail; |
|
2879 |
points[i].x = __intVal(x); |
|
2880 |
points[i].y = __intVal(y); |
|
2881 |
} |
|
2882 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
2883 |
if (mustFree) |
|
2884 |
free(points); |
|
2885 |
RETURN ( self ); |
|
295 | 2886 |
} |
2887 |
fail: ; |
|
377 | 2888 |
if (mustFree) |
1344 | 2889 |
free(points); |
295 | 2890 |
%}. |
2891 |
"badGC, badDrawable or coordinates not integer" |
|
2892 |
self primitiveFailed |
|
2893 |
! |
|
2894 |
||
2895 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2896 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2897 |
||
2898 |
%{ /* NOCONTEXT */ |
|
2899 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2900 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2901 |
Window win; |
295 | 2902 |
int w, h; |
2903 |
||
1209 | 2904 |
if (ISCONNECTED |
2905 |
&& __isExternalAddress(aGCId) |
|
295 | 2906 |
&& __isExternalAddress(aDrawableId) |
2907 |
&& __bothSmallInteger(x, y) |
|
2908 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2909 |
gc = _GCVal(aGCId); |
2910 |
win = _WindowVal(aDrawableId); |
|
2911 |
w = __intVal(width); |
|
2912 |
h = __intVal(height); |
|
2913 |
/* |
|
2914 |
* need this check here: some servers simply dump core with bad args |
|
2915 |
*/ |
|
2916 |
if ((w >= 0) && (h >= 0)) { |
|
2917 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
|
2918 |
} |
|
2919 |
RETURN ( self ); |
|
295 | 2920 |
} |
2921 |
%}. |
|
2922 |
"badGC, badDrawable or coordinates not integer" |
|
2923 |
self primitiveFailed |
|
2924 |
! |
|
2925 |
||
2926 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2927 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2928 |
foreground and background characters. |
|
2929 |
If the coordinates are not integers, an error is triggered." |
|
2930 |
||
2931 |
%{ /* NOCONTEXT */ |
|
2932 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2933 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2934 |
Window win; |
295 | 2935 |
unsigned char *cp; |
2936 |
OBJ cls; |
|
2937 |
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
|
2938 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2939 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2940 |
int nInstBytes; |
295 | 2941 |
|
1209 | 2942 |
if (ISCONNECTED |
2943 |
&& __isExternalAddress(aGCId) |
|
295 | 2944 |
&& __isExternalAddress(aDrawableId) |
2945 |
&& __isNonNilObject(aString) |
|
2946 |
&& __bothSmallInteger(index1, index2) |
|
2947 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2948 |
gc = _GCVal(aGCId); |
2949 |
win = _WindowVal(aDrawableId); |
|
2950 |
cls = __qClass(aString); |
|
2951 |
||
2952 |
i1 = __intVal(index1) - 1; |
|
2953 |
if (i1 >= 0) { |
|
2954 |
i2 = __intVal(index2) - 1; |
|
2955 |
if (i2 < i1) { |
|
2956 |
RETURN (self); |
|
2957 |
} |
|
2958 |
||
2959 |
cp = _stringVal(aString); |
|
2960 |
l = i2 - i1 + 1; |
|
2961 |
||
2962 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2963 |
n = _stringSize(aString); |
|
2964 |
if (i2 < n) { |
|
2965 |
cp += i1; |
|
2966 |
if (l > 1000) l = 1000; |
|
2967 |
if (opaque == true) |
|
2968 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2969 |
else |
|
2970 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2971 |
RETURN ( self ); |
|
2972 |
} |
|
2973 |
} |
|
2974 |
||
2975 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2976 |
cp += nInstBytes; |
|
2977 |
||
2978 |
if (__isBytes(aString)) { |
|
2979 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2980 |
||
2981 |
if (i2 < n) { |
|
2982 |
cp += i1; |
|
2983 |
if (l > 1000) l = 1000; |
|
2984 |
if (opaque == true) |
|
2985 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2986 |
else |
|
2987 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2988 |
RETURN ( self ); |
|
2989 |
} |
|
2990 |
} |
|
2991 |
||
2992 |
/* TWOBYTESTRINGS */ |
|
2993 |
if (__isWords(aString)) { |
|
2994 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2995 |
||
2996 |
if (i2 < n) { |
|
2997 |
union { |
|
2998 |
char b[2]; |
|
2999 |
unsigned short s; |
|
3000 |
} u; |
|
3001 |
int i; |
|
3002 |
XChar2b *cp2 = (XChar2b *)0; |
|
3003 |
int mustFree = 0; |
|
3004 |
||
3005 |
cp += (i1 * 2); |
|
3006 |
if (l > 1000) l = 1000; |
|
3007 |
||
3008 |
/* |
|
3009 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3010 |
* X expects them MSB first |
|
3011 |
* convert as required |
|
3012 |
*/ |
|
3013 |
||
3014 |
u.s = 0x1234; |
|
3015 |
if (u.b[0] != 0x12) { |
|
3016 |
if (l <= NLOCALBUFFER) { |
|
3017 |
cp2 = xlatebuffer; |
|
3018 |
} else { |
|
3019 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
3020 |
mustFree = 1; |
|
3021 |
} |
|
3022 |
for (i=0; i<l; i++) { |
|
3023 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3024 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3025 |
} |
|
3026 |
cp = (char *) cp2; |
|
3027 |
} |
|
3028 |
||
3029 |
if (opaque == true) |
|
3030 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3031 |
else |
|
3032 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
3033 |
||
3034 |
if (mustFree) { |
|
3035 |
free(cp2); |
|
3036 |
} |
|
3037 |
||
3038 |
RETURN ( self ); |
|
3039 |
} |
|
3040 |
} |
|
3041 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3042 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3043 |
#undef NLOCALBUFFER |
295 | 3044 |
%}. |
3045 |
"x/y not integer, badGC or drawable, or not a string" |
|
3046 |
self primitiveFailed |
|
3047 |
! |
|
3048 |
||
3049 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
3050 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
3051 |
foreground and background characters. |
|
3052 |
If the coordinates are not integers, an error is triggered." |
|
3053 |
||
3054 |
%{ /* NOCONTEXT */ |
|
3055 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3056 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3057 |
Window win; |
295 | 3058 |
unsigned char *cp; |
3059 |
int n; |
|
3060 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3061 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3062 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3063 |
int nInstBytes; |
295 | 3064 |
|
1209 | 3065 |
if (ISCONNECTED |
3066 |
&& __isExternalAddress(aGCId) |
|
295 | 3067 |
&& __isExternalAddress(aDrawableId) |
3068 |
&& __isNonNilObject(aString) |
|
3069 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 3070 |
gc = _GCVal(aGCId); |
3071 |
win = _WindowVal(aDrawableId); |
|
3072 |
cls = __qClass(aString); |
|
3073 |
||
3074 |
cp = _stringVal(aString); |
|
3075 |
||
3076 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
3077 |
n = _stringSize(aString); |
|
3078 |
if (n > 1000) n = 1000; |
|
3079 |
if (opaque == true) |
|
3080 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3081 |
else |
|
3082 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3083 |
RETURN ( self ); |
|
3084 |
} |
|
3085 |
||
3086 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
3087 |
cp += nInstBytes; |
|
3088 |
||
3089 |
if (__isBytes(aString)) { |
|
3090 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
3091 |
||
3092 |
if (n > 1000) n = 1000; |
|
3093 |
if (opaque == true) |
|
3094 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3095 |
else |
|
3096 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
3097 |
RETURN ( self ); |
|
3098 |
} |
|
3099 |
||
3100 |
/* TWOBYTESTRINGS */ |
|
3101 |
if (__isWords(aString)) { |
|
3102 |
union { |
|
3103 |
char b[2]; |
|
3104 |
unsigned short s; |
|
3105 |
} u; |
|
3106 |
int i; |
|
3107 |
XChar2b *cp2; |
|
3108 |
int mustFree = 0; |
|
3109 |
||
3110 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
3111 |
if (n > 1000) n = 1000; |
|
3112 |
||
3113 |
/* |
|
3114 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
3115 |
* X expects them MSB first |
|
3116 |
* convert as required |
|
3117 |
*/ |
|
3118 |
||
3119 |
u.s = 0x1234; |
|
3120 |
if (u.b[0] != 0x12) { |
|
3121 |
if (n <= NLOCALBUFFER) { |
|
3122 |
cp2 = xlatebuffer; |
|
3123 |
} else { |
|
3124 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
3125 |
mustFree = 1; |
|
3126 |
} |
|
3127 |
||
3128 |
for (i=0; i<n; i++) { |
|
3129 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
3130 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
3131 |
} |
|
3132 |
cp = (char *) cp2; |
|
3133 |
} |
|
3134 |
||
3135 |
if (opaque == true) |
|
3136 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3137 |
else |
|
3138 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
3139 |
||
3140 |
||
3141 |
if (mustFree) { |
|
3142 |
free(cp2); |
|
3143 |
} |
|
3144 |
||
3145 |
RETURN ( self ); |
|
3146 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
3147 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
3148 |
#undef NLOCALBUFFER |
295 | 3149 |
%}. |
3150 |
"x/y not integer, badGC or drawable, or not a string" |
|
3151 |
self primitiveFailed |
|
3152 |
! |
|
3153 |
||
3154 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3155 |
width:imageWidth height:imageHeight |
3156 |
x:srcx y:srcy |
|
3157 |
into:aDrawableId |
|
3158 |
x:dstx y:dsty |
|
3159 |
width:w height:h |
|
3160 |
with:aGCId |
|
295 | 3161 |
|
3162 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3163 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3164 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3165 |
depth and pixel-units to be different. |
|
3166 |
It has to be checked elsewhere, that the server can do it with the given |
|
3167 |
depth - otherwise, primitive failure will be signalled. |
|
3168 |
Also it is assumed, that the colormap is setup correctly and the |
|
3169 |
colors are allocated - otherwise the colors may be wrong." |
|
3170 |
||
3171 |
" |
|
3172 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3173 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3174 |
" |
|
3175 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3176 |
width:imageWidth height:imageHeight |
3177 |
x:srcx y:srcy |
|
3178 |
into:aDrawableId |
|
3179 |
x:dstx y:dsty |
|
3180 |
width:w height:h |
|
3181 |
with:aGCId) |
|
295 | 3182 |
ifFalse:[ |
1344 | 3183 |
" |
3184 |
also happens, if a segmentation violation occurs in the |
|
3185 |
XPutImage ... |
|
3186 |
" |
|
3187 |
self primitiveFailed |
|
295 | 3188 |
]. |
3189 |
! |
|
3190 |
||
3191 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3192 |
width:imageWidth height:imageHeight |
3193 |
x:srcx y:srcy |
|
3194 |
into:aDrawableId |
|
3195 |
x:dstx y:dsty |
|
3196 |
width:w height:h |
|
3197 |
with:aGCId |
|
295 | 3198 |
|
3199 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3200 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3201 |
Individual source pixels must have imageDepth bits. |
|
3202 |
It has to be checked elsewhere, that the server can do it with the given |
|
3203 |
depth - otherwise, primitive failure will be signalled. |
|
3204 |
Also it is assumed, that the colormap is setup correctly and the |
|
3205 |
colors are allocated - otherwise the colors may be wrong." |
|
3206 |
||
3207 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3208 |
width:imageWidth height:imageHeight |
3209 |
x:srcx y:srcy |
|
3210 |
into:aDrawableId |
|
3211 |
x:dstx y:dsty |
|
3212 |
width:w height:h |
|
3213 |
with:aGCId |
|
295 | 3214 |
|
3215 |
! |
|
3216 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3217 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3218 |
in:aDrawableId with:aGCId |
90 | 3219 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3220 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3221 |
|
3222 |
%{ /* NOCONTEXT */ |
|
3223 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3224 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3225 |
Window win; |
0 | 3226 |
int w, h, angle1, angle2; |
3227 |
double f; |
|
3228 |
||
97 | 3229 |
if (__isSmallInteger(startAngle)) |
1344 | 3230 |
angle1 = __intVal(startAngle) * 64; |
36 | 3231 |
else if (__isFloat(startAngle)) { |
1344 | 3232 |
f = __floatVal(startAngle); |
3233 |
angle1 = f * 64; |
|
0 | 3234 |
} |
97 | 3235 |
if (__isSmallInteger(angle)) |
1344 | 3236 |
angle2 = __intVal(angle) * 64; |
36 | 3237 |
else if (__isFloat(angle)) { |
1344 | 3238 |
f = __floatVal(angle); |
3239 |
angle2 = f * 64; |
|
0 | 3240 |
} |
1209 | 3241 |
if (ISCONNECTED |
3242 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3243 |
&& __isExternalAddress(aDrawableId) |
97 | 3244 |
&& __bothSmallInteger(x, y) |
3245 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3246 |
gc = _GCVal(aGCId); |
3247 |
win = _WindowVal(aDrawableId); |
|
3248 |
w = __intVal(width); |
|
3249 |
h = __intVal(height); |
|
3250 |
/* |
|
3251 |
* need this check here: some servers simply dump core with bad args |
|
3252 |
*/ |
|
3253 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
3254 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
3255 |
w, h, angle1, angle2); |
|
3256 |
} |
|
3257 |
RETURN ( self ); |
|
0 | 3258 |
} |
73 | 3259 |
%}. |
3260 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3261 |
self primitiveFailed |
3262 |
! |
|
3263 |
||
3264 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3265 |
"fill a polygon given by its points. |
3266 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3267 |
|
3268 |
|numberOfPoints| |
|
0 | 3269 |
|
3270 |
numberOfPoints := aPolygon size. |
|
3271 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3272 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3273 |
Window win; |
73 | 3274 |
OBJ point, x, y; |
3275 |
int i, num; |
|
3276 |
XPoint *points; |
|
3277 |
XPoint qPoints[100]; |
|
377 | 3278 |
int mustFree = 0; |
73 | 3279 |
|
1209 | 3280 |
if (ISCONNECTED |
3281 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3282 |
&& __isExternalAddress(aDrawableId) |
97 | 3283 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3284 |
gc = _GCVal(aGCId); |
3285 |
win = _WindowVal(aDrawableId); |
|
3286 |
num = __intVal(numberOfPoints); |
|
3287 |
if (num < 3) { |
|
3288 |
RETURN ( self ); |
|
3289 |
} |
|
3290 |
/* |
|
3291 |
* avoid (slow) malloc, if not many points |
|
3292 |
*/ |
|
3293 |
if (num > 100) { |
|
3294 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3295 |
if (! points) goto fail; |
|
3296 |
mustFree = 1; |
|
3297 |
} else |
|
3298 |
points = qPoints; |
|
3299 |
for (i=0; i<num; i++) { |
|
3300 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3301 |
if (! __isPoint(point)) goto fail; |
|
3302 |
x = _point_X(point); |
|
3303 |
y = _point_Y(point); |
|
3304 |
if (! __bothSmallInteger(x, y)) |
|
3305 |
goto fail; |
|
3306 |
points[i].x = __intVal(x); |
|
3307 |
points[i].y = __intVal(y); |
|
3308 |
} |
|
3309 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
3310 |
if (mustFree) |
|
3311 |
free(points); |
|
3312 |
RETURN ( self ); |
|
377 | 3313 |
|
0 | 3314 |
fail: ; |
1344 | 3315 |
if (mustFree) |
3316 |
free(points); |
|
0 | 3317 |
} |
73 | 3318 |
%}. |
3319 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3320 |
self primitiveFailed |
3321 |
! |
|
3322 |
||
295 | 3323 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3324 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3325 |
||
3326 |
%{ /* NOCONTEXT */ |
|
3327 |
||
3328 |
int w, h; |
|
3329 |
||
1209 | 3330 |
if (ISCONNECTED |
3331 |
&& __isExternalAddress(aGCId) |
|
295 | 3332 |
&& __isExternalAddress(aDrawableId) |
3333 |
&& __bothSmallInteger(x, y) |
|
3334 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3335 |
w = __intVal(width); |
3336 |
h = __intVal(height); |
|
3337 |
/* |
|
3338 |
* need this check here: some servers simply dump core with bad args |
|
3339 |
*/ |
|
3340 |
if ((w >= 0) && (h >= 0)) { |
|
3341 |
XFillRectangle(myDpy, |
|
3342 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3343 |
__intVal(x), __intVal(y), w, h); |
|
3344 |
} |
|
3345 |
RETURN ( self ); |
|
295 | 3346 |
} |
3347 |
%}. |
|
3348 |
"badGC, badDrawable or coordinates not integer" |
|
3349 |
self primitiveFailed |
|
43 | 3350 |
! |
3351 |
||
3352 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 3353 |
width:imageWidth height:imageHeight |
3354 |
x:srcx y:srcy |
|
3355 |
into:aDrawableId |
|
3356 |
x:dstx y:dsty |
|
3357 |
width:w height:h |
|
3358 |
with:aGCId |
|
0 | 3359 |
|
132 | 3360 |
"since XPutImage may allocate huge amount of stack space |
3361 |
(some implementations use alloca), this must run with unlimited stack." |
|
3362 |
||
12 | 3363 |
%{ /* UNLIMITEDSTACK */ |
0 | 3364 |
|
43 | 3365 |
/* |
3366 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3367 |
* XPutImage |
|
3368 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3369 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3370 |
Window win; |
43 | 3371 |
XImage image; |
377 | 3372 |
int imgWdth; |
43 | 3373 |
|
1209 | 3374 |
if (ISCONNECTED |
3375 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3376 |
&& __isExternalAddress(aDrawableId) |
97 | 3377 |
&& __bothSmallInteger(srcx, srcy) |
3378 |
&& __bothSmallInteger(dstx, dsty) |
|
3379 |
&& __bothSmallInteger(w, h) |
|
3380 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3381 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3382 |
&& __isByteArray(imageBits)) { |
1344 | 3383 |
Display *dpy = myDpy; |
3384 |
||
3385 |
gc = _GCVal(aGCId); |
|
3386 |
win = _WindowVal(aDrawableId); |
|
3387 |
if (! gc || !win) |
|
3388 |
goto fail; |
|
46 | 3389 |
#ifdef ARGDEBUG |
1344 | 3390 |
printf("args ok\n"); |
46 | 3391 |
#endif |
1344 | 3392 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3393 |
image.width = imgWdth = __intVal(imageWidth); |
|
3394 |
image.height = __intVal(imageHeight); |
|
3395 |
image.xoffset = 0; |
|
3396 |
image.format = ZPixmap; |
|
3397 |
image.byte_order = MSBFirst; |
|
3398 |
image.bitmap_unit = 8; |
|
3399 |
image.bitmap_bit_order = MSBFirst; |
|
3400 |
image.bitmap_pad = 8; |
|
3401 |
image.depth = __intVal(imageDepth); |
|
3402 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3403 |
switch (image.bits_per_pixel) { |
|
3404 |
case 1: |
|
3405 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3406 |
break; |
|
3407 |
case 2: |
|
3408 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3409 |
break; |
|
3410 |
case 4: |
|
3411 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3412 |
break; |
|
3413 |
case 8: |
|
3414 |
image.bytes_per_line = imgWdth; |
|
3415 |
break; |
|
3416 |
case 16: |
|
3417 |
image.bytes_per_line = imgWdth*2; |
|
3418 |
break; |
|
3419 |
case 24: |
|
3420 |
image.bytes_per_line = imgWdth*3; |
|
3421 |
break; |
|
3422 |
case 32: |
|
3423 |
image.bytes_per_line = imgWdth*4; |
|
3424 |
break; |
|
3425 |
default: |
|
46 | 3426 |
#ifdef ARGDEBUG |
1344 | 3427 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3428 |
#endif |
1344 | 3429 |
goto fail; |
3430 |
} |
|
3431 |
image.red_mask = 0xFFFF; |
|
3432 |
image.green_mask = 0xFFFF; |
|
3433 |
image.blue_mask = 0xFFFF; |
|
3434 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
|
3435 |
__intVal(dstx), __intVal(dsty), |
|
3436 |
__intVal(w), __intVal(h)); |
|
3437 |
RETURN ( true ); |
|
43 | 3438 |
} |
46 | 3439 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3440 |
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
|
3441 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3442 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3443 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3444 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3445 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3446 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3447 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3448 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3449 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3450 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3451 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3452 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3453 |
#endif |
3454 |
||
0 | 3455 |
fail: ; |
3456 |
%} |
|
3457 |
. |
|
12 | 3458 |
^ false |
0 | 3459 |
! ! |
3460 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3461 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3462 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3463 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3464 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3465 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3466 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3467 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3468 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3469 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3470 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3471 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3472 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3473 |
|
1540 | 3474 |
clientMessage:event dataOffset:offs view:targetView |
3475 |
self halt. |
|
3476 |
||
3477 |
"Created: 4.4.1997 / 17:23:12 / cg" |
|
3478 |
! |
|
3479 |
||
1543 | 3480 |
clientMessage:event type:type format:format dataOffset:offs view:targetView |
3481 |
|sensor data| |
|
3482 |
||
3483 |
data := event copyFrom:offs + 1. |
|
3484 |
||
3485 |
"/ DND drag&drop protocol |
|
3486 |
type == (self atomIDOf:'DndProtocol') ifTrue:[ |
|
3487 |
format == 32 ifTrue:[ |
|
3488 |
self dndMessage:event data:data view:targetView. |
|
3489 |
^ self |
|
3490 |
] |
|
3491 |
]. |
|
3492 |
||
3493 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
3494 |
sensor clientMessage:type format:format eventData:data view:targetView |
|
3495 |
] ifFalse:[ |
|
3496 |
" |
|
3497 |
not posted, if there is no sensor ... |
|
3498 |
" |
|
3499 |
] |
|
3500 |
||
3501 |
"Created: 4.4.1997 / 17:49:26 / cg" |
|
3502 |
"Modified: 4.4.1997 / 18:00:18 / cg" |
|
3503 |
! |
|
3504 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3505 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3506 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3507 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3508 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3509 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3510 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3511 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3512 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3513 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3514 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3515 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3516 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3517 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3518 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3519 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3520 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3521 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3522 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3523 |
|
1543 | 3524 |
dndMessage:event data:data view:targetView |
3525 |
"handle a DND drag&drop protocol message" |
|
3526 |
||
1553 | 3527 |
|sensor dropType dropValue names i1 i2 t| |
1543 | 3528 |
|
3529 |
dropType := data doubleWordAt:1. |
|
3530 |
||
3531 |
"/ see def's in DragAndDropTypes.h |
|
1556 | 3532 |
dropType := (self dndDropTypes) at:dropType+1 ifAbsent:#DndNotDnd. |
1543 | 3533 |
|
3534 |
self |
|
3535 |
getProperty:(self atomIDOf:'DndSelection') |
|
3536 |
from:rootId |
|
3537 |
into:[:type :value | |
|
1552 | 3538 |
t := type. |
1543 | 3539 |
dropValue := value |
3540 |
]. |
|
3541 |
||
3542 |
dropType == #DndFiles ifTrue:[ |
|
3543 |
"/ actually, a list of fileNames |
|
1554 | 3544 |
t ~~ (self atomIDOfSTRING) ifTrue:[ |
3545 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3546 |
^ self |
|
3547 |
]. |
|
3548 |
||
1543 | 3549 |
names := OrderedCollection new. |
3550 |
i1 := 1. |
|
3551 |
[i1 ~~ 0] whileTrue:[ |
|
3552 |
i2 := dropValue indexOf:(Character value:0) startingAt:i1. |
|
3553 |
i2 ~~ 0 ifTrue:[ |
|
1552 | 3554 |
names add:(dropValue copyFrom:i1 to:(i2-1)). |
1543 | 3555 |
i1 := i2 + 1. |
3556 |
] ifFalse:[ |
|
3557 |
i1 := i2 |
|
3558 |
]. |
|
3559 |
]. |
|
3560 |
dropValue := names. |
|
1553 | 3561 |
dropValue := dropValue collect:[:nm | nm asFilename]. |
1554 | 3562 |
dropType := #files. |
1552 | 3563 |
] ifFalse:[ |
1554 | 3564 |
(dropType == #DndFile) ifTrue:[ |
3565 |
t ~~ (self atomIDOfSTRING) ifTrue:[ |
|
3566 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3567 |
^ self |
|
3568 |
]. |
|
3569 |
||
1553 | 3570 |
dropValue := dropValue asFilename. |
1554 | 3571 |
dropType := #file. |
3572 |
] ifFalse:[ |
|
3573 |
(dropType == #DndDir) ifTrue:[ |
|
3574 |
t ~~ (self atomIDOfSTRING) ifTrue:[ |
|
3575 |
'XWorkstation [info]: expected a string propertyValue in drop' infoPrintCR. |
|
3576 |
^ self |
|
3577 |
]. |
|
3578 |
||
3579 |
dropValue := dropValue asFilename. |
|
3580 |
dropType := #directory. |
|
3581 |
] ifFalse:[ |
|
3582 |
'XWorkstation [info]: unsupported dropType: ' infoPrint. |
|
3583 |
dropType infoPrintCR |
|
3584 |
] |
|
1552 | 3585 |
] |
1543 | 3586 |
]. |
3587 |
||
3588 |
(sensor := targetView sensor) notNil ifTrue:[ |
|
3589 |
sensor dropMessage:dropType data:dropValue view:targetView |
|
3590 |
] ifFalse:[ |
|
3591 |
" |
|
3592 |
not posted, if there is no sensor ... |
|
3593 |
" |
|
3594 |
] |
|
3595 |
||
3596 |
"Created: 4.4.1997 / 17:59:37 / cg" |
|
1556 | 3597 |
"Modified: 6.4.1997 / 12:58:20 / cg" |
1543 | 3598 |
! |
3599 |
||
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3600 |
gravityNotifyView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3601 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3602 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3603 |
"/ aView gravityNotify |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3604 |
! |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3605 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3606 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3607 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3608 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3609 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3610 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3611 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3612 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3613 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3614 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3615 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3616 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3617 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3618 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3619 |
reparentedView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3620 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3621 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3622 |
"/ aView reparented |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3623 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3624 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3625 |
resizeRequestView:aView |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3626 |
"ignored for now" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3627 |
|
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3628 |
"/ aView resizeRequest |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3629 |
! |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
3630 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3631 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3632 |
"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
|
3633 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3634 |
|
1344 | 3635 |
"/ |
3636 |
"/ workaround a bug in olvwm: it clears selections |
|
3637 |
"/ on window raise. |
|
3638 |
"/ In this case, keep my last own selection. |
|
3639 |
"/ |
|
3640 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3641 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3642 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3643 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3644 |
"/ noone is interrested in that ... |
1344 | 3645 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3646 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3647 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3648 |
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
|
3649 |
"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
|
3650 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3651 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3652 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3653 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3654 |
propertyID == 0 ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3655 |
"invalid olvwm behavior" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3656 |
s := self getLastCopyBuffer |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3657 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3658 |
targetID == self atomIDOfSTRING ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3659 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3660 |
a returned string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3661 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3662 |
s := self getTextProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3663 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3664 |
(s endsWith:Character cr) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3665 |
s := s asStringCollection copyWith:'' |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3666 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3667 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3668 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3669 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3670 |
a returned object |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3671 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3672 |
s := self getObjectProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3673 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3674 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3675 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3676 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3677 |
(sensor := aView sensor) notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3678 |
sensor pasteFromClipBoard:s view:aView |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3679 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3680 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3681 |
if there is no sensor ... |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3682 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3683 |
aView pasteFromClipBoard:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3684 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3685 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3686 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3687 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3688 |
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
|
3689 |
"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
|
3690 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3691 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3692 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3693 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3694 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3695 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3696 |
"/ 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
|
3697 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3698 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3699 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3700 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3701 |
setLengthProperty:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3702 |
value:s size |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3703 |
for:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3704 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3705 |
sendSelectionNotifySelection:selectionID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3706 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3707 |
target:targetID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3708 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3709 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3710 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3711 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3712 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3713 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3714 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3715 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3716 |
"/ the other view wants the selection as string |
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 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3719 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3720 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3721 |
sendSelection:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3722 |
property:propertyID |
1345 | 3723 |
target:targetID |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3724 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3725 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3726 |
^ self |
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 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3729 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3730 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3731 |
"/ (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
|
3732 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3733 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3734 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3735 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3736 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3737 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3738 |
sendSelection:(stream contents) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3739 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3740 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3741 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3742 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3743 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3744 |
|
86 | 3745 |
!XWorkstation methodsFor:'event handling'! |
0 | 3746 |
|
3747 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3748 |
"central event handling method: |
|
54 | 3749 |
get next event and send appropriate message to the sensor or view. |
0 | 3750 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3751 |
otherwise only events for the view with given id are processed. |
3752 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3753 |
handled." |
|
3754 |
||
54 | 3755 |
(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
|
3756 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3757 |
ex return |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3758 |
] do:[ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3759 |
self dispatchLastEvent. |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3760 |
] |
54 | 3761 |
]. |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3762 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3763 |
"Modified: 26.3.1997 / 19:00:41 / cg" |
12 | 3764 |
! |
3765 |
||
295 | 3766 |
dispatchExposeEventFor:aViewIdOrNil |
3767 |
"get next expose event and send appropriate message to the sensor or view. |
|
3768 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3769 |
otherwise only events for the view with given id are processed." |
|
3770 |
||
3771 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3772 |
! |
3773 |
||
3774 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3775 |
|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
|
3776 |
eventType| |
12 | 3777 |
|
3778 |
%{ /* STACK: 8000 */ |
|
3779 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3780 |
|
1209 | 3781 |
Display *dpy; |
135 | 3782 |
OBJ eB; |
3783 |
XEvent *ev; |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3784 |
int ev_x, ev_y; |
135 | 3785 |
|
3786 |
# define ae ((XAnyEvent *)ev) |
|
3787 |
# define ee ((XExposeEvent *)ev) |
|
3788 |
# define ke ((XKeyPressedEvent *)ev) |
|
3789 |
# define be ((XButtonPressedEvent *)ev) |
|
3790 |
# define ce ((XConfigureEvent *)ev) |
|
3791 |
# define me ((XMotionEvent *)ev) |
|
3792 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3793 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3794 |
# define de ((XDestroyWindowEvent *)ev) |
|
3795 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3796 |
# define mape ((XMappingEvent *)ev) |
135 | 3797 |
|
0 | 3798 |
KeySym keySym; |
3799 |
unsigned char buffer[10]; |
|
3800 |
int i, nchars; |
|
3801 |
char *keySymString; |
|
3802 |
char keySymStringBuffer[32]; |
|
3803 |
unsigned nextMultiClickTime; |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3804 |
OBJ upDown, t; |
115 | 3805 |
|
3806 |
struct inlineCache *ipS; |
|
0 | 3807 |
static struct inlineCache vid = _ILC1; |
12 | 3808 |
|
3809 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
3810 |
static struct inlineCache gexpS = _ILC6; |
12 | 3811 |
static struct inlineCache nexpS = _ILC1; |
3812 |
static struct inlineCache motS = _ILC4; |
|
3813 |
static struct inlineCache bpS = _ILC4; |
|
3814 |
static struct inlineCache bmpS = _ILC4; |
|
3815 |
static struct inlineCache bspS = _ILC4; |
|
3816 |
static struct inlineCache brS = _ILC4; |
|
3817 |
static struct inlineCache focInS = _ILC1; |
|
3818 |
static struct inlineCache focOutS = _ILC1; |
|
3819 |
static struct inlineCache peS = _ILC4; |
|
3820 |
static struct inlineCache plS = _ILC2; |
|
54 | 3821 |
static struct inlineCache termS = _ILC1; |
3822 |
static struct inlineCache savtermS = _ILC1; |
|
3823 |
static struct inlineCache destrS = _ILC1; |
|
3824 |
static struct inlineCache unmapS = _ILC1; |
|
3825 |
static struct inlineCache mapS = _ILC1; |
|
3826 |
static struct inlineCache confS = _ILC5; |
|
70 | 3827 |
static struct inlineCache coveredS = _ILC2; |
1543 | 3828 |
static struct inlineCache clientMsg = _ILC5; |
12 | 3829 |
|
3830 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3831 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3832 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3833 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3834 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3835 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3836 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3837 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3838 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3839 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3840 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3841 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3842 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3843 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3844 |
static struct inlineCache mapping = _ILC2; |
70 | 3845 |
static struct inlineCache vis = _ILC1; |
12 | 3846 |
|
3847 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3848 |
static struct inlineCache skrS = _ILC4; |
12 | 3849 |
|
1209 | 3850 |
if (! ISCONNECTED) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3851 |
RETURN (false); |
1209 | 3852 |
} |
3853 |
||
3854 |
dpy = myDpy; |
|
3855 |
||
1210 | 3856 |
eB = __INST(eventBuffer); |
3857 |
||
135 | 3858 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3859 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3860 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3861 |
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
|
3862 |
RETURN (false); |
135 | 3863 |
} |
3864 |
||
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3865 |
/* |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3866 |
* 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
|
3867 |
* avoid creation & lookup then. |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3868 |
*/ |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3869 |
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
|
3870 |
if (__isExternalAddress(t)) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3871 |
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
|
3872 |
theView = __INST(lastView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3873 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3874 |
} |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3875 |
} |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3876 |
|
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3877 |
if (theView == nil) { |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3878 |
windowID = __MKOBJ(ae->window); |
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3879 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
1540 | 3880 |
/* |
3881 |
* #viewFromId: could lead to a GC - refetch event ptr |
|
3882 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3883 |
eB = __INST(eventBuffer); |
1540 | 3884 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1486
638558d89c66
inlined lastId/lastView check into event handler;
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3885 |
} |
12 | 3886 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3887 |
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
|
3888 |
RETURN (nil); |
12 | 3889 |
} |
3890 |
||
3891 |
/* |
|
3892 |
* key, button and pointer events are sent to the sensor, |
|
3893 |
* or (if there is none) to the delegate. |
|
3894 |
* or (if there is none) to the view. |
|
26 | 3895 |
* |
3896 |
* expose events are sent to the sensor, |
|
3897 |
* or (if there is none) to the view |
|
3898 |
* |
|
12 | 3899 |
* sensor and delegate get view as additional argument |
115 | 3900 |
* all of this has been taken out of here to corresponding methods |
3901 |
* in DeviceWorkstation. |
|
12 | 3902 |
*/ |
90 | 3903 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3904 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3905 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3906 |
#endif |
135 | 3907 |
switch (ev->type) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3908 |
case KeyRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3909 |
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
|
3910 |
ipS = &skrS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3911 |
upDown = false; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3912 |
goto keyPressAndRelease; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3913 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3914 |
case KeyPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3915 |
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
|
3916 |
ipS = &skpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3917 |
upDown = true; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3918 |
/* FALL INTO */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3919 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3920 |
keyPressAndRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3921 |
__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
|
3922 |
__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
|
3923 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3924 |
__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
|
3925 |
__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
|
3926 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3927 |
__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
|
3928 |
__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
|
3929 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3930 |
__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
|
3931 |
__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
|
3932 |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3933 |
ev_x = ke->x; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3934 |
ev_y = ke->y; |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
3935 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3936 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3937 |
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
|
3938 |
if (nchars |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3939 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3940 |
|| (buffer[0] >= 0x80))) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3941 |
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
|
3942 |
keySymString = NULL; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3943 |
} else { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3944 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3945 |
switch (keySym) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3946 |
case XK_Control_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3947 |
case XK_Control_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3948 |
__INST(ctrlDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3949 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3950 |
case XK_Shift_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3951 |
case XK_Shift_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3952 |
__INST(shiftDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3953 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3954 |
case XK_Meta_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3955 |
case XK_Meta_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3956 |
__INST(metaDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3957 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3958 |
case XK_Alt_L: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3959 |
case XK_Alt_R: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3960 |
__INST(altDown) = upDown; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3961 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3962 |
} |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3963 |
#endif |
150 | 3964 |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3965 |
keySymString = XKeysymToString(keySym); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3966 |
if (keySymString) { |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3967 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3968 |
if (keySymString[0] == 'D') { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3969 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3970 |
* 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
|
3971 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3972 |
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
|
3973 |
keySymString = "DeleteLine"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3974 |
} 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
|
3975 |
keySymString = "DeleteWord"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3976 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3977 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3978 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3979 |
* make names compatible |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3980 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3981 |
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
|
3982 |
keySymString = "CursorDown"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3983 |
} 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
|
3984 |
keySymString = "CursorUp"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3985 |
} 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
|
3986 |
keySymString = "CursorLeft"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3987 |
} 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
|
3988 |
keySymString = "CursorRight"; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3989 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3990 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3991 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3992 |
arg = __MKSTRING(keySymString); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3993 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3994 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3995 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3996 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3997 |
if (arg == nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
3998 |
/* 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
|
3999 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4000 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4001 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4002 |
(*(*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
|
4003 |
arg, |
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4004 |
__MKSMALLINT(ev_x), |
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4005 |
__MKSMALLINT(ev_y), |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4006 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4007 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4008 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4009 |
case ButtonPress: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4010 |
__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
|
4011 |
__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
|
4012 |
__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
|
4013 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4014 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4015 |
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
|
4016 |
else |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4017 |
nextMultiClickTime = 0; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4018 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4019 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4020 |
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
|
4021 |
int _multiClickTime; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4022 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4023 |
_multiClickTime = __longIntVal(t); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4024 |
if (be->time < _multiClickTime) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4025 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1540 | 4026 |
/* |
4027 |
* MKUINT could lead to a GC - refetch event ptr |
|
4028 |
*/ |
|
4029 |
eB = __INST(eventBuffer); |
|
4030 |
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
|
4031 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4032 |
ipS = &bmpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4033 |
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
|
4034 |
goto sendButtonEvent; |
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 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4037 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4038 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
1540 | 4039 |
/* |
4040 |
* MKUINT could lead to a GC - refetch event ptr |
|
4041 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4042 |
eB = __INST(eventBuffer); |
1540 | 4043 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
4044 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4045 |
#ifdef NO_LONGER |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4046 |
if (be->state & ShiftMask) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4047 |
ipS = &bspS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4048 |
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
|
4049 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4050 |
} |
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
4051 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4052 |
ipS = &bpS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4053 |
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
|
4054 |
goto sendButtonEvent; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4055 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4056 |
/* NOT REACHED */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4057 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4058 |
case ButtonRelease: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4059 |
__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
|
4060 |
__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
|
4061 |
__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
|
4062 |
ipS = &brS; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4063 |
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
|
4064 |
/* fall into */ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4065 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4066 |
sendButtonEvent: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4067 |
butt = __MKSMALLINT(be->button); |
12 | 4068 |
#ifdef NOTDEF |
1489
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 |
* 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
|
4071 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4072 |
if (__INST(metaDown) == true) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4073 |
butt = __MKSMALLINT(2); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4074 |
else |
0 | 4075 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4076 |
butt = __AT_(__INST(buttonTranslation), butt); |
1540 | 4077 |
/* |
4078 |
* #at: could lead to a GC - refetch event ptr |
|
4079 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4080 |
eB = __INST(eventBuffer); |
1540 | 4081 |
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
|
4082 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4083 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4084 |
(*(*ipS).ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4085 |
symS, nil, ipS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4086 |
butt, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4087 |
__MKSMALLINT(ke->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4088 |
__MKSMALLINT(ke->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4089 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4090 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4091 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4092 |
case MotionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4093 |
if (__INST(motionEventCompression) != false) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4094 |
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
|
4095 |
} |
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 |
__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
|
4098 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
70 | 4099 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4100 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4101 |
__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
|
4102 |
__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
|
4103 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4104 |
__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
|
4105 |
__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
|
4106 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4107 |
__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
|
4108 |
__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
|
4109 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4110 |
(*motS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4111 |
@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
|
4112 |
__MKSMALLINT(me->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4113 |
__MKSMALLINT(me->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4114 |
__MKSMALLINT(me->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4115 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4116 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4117 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4118 |
case FocusIn: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4119 |
(*focInS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4120 |
@symbol(focusInView:), nil, &focInS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4121 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4122 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4123 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4124 |
case FocusOut: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4125 |
(*focOutS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4126 |
@symbol(focusOutView:), nil, &focOutS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4127 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4128 |
break; |
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 |
case EnterNotify: |
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
4131 |
#ifdef OLD |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4132 |
__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
|
4133 |
__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
|
4134 |
#else |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4135 |
__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
|
4136 |
__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
|
4137 |
#endif |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4138 |
__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
|
4139 |
__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
|
4140 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4141 |
(*peS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4142 |
@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
|
4143 |
__MKSMALLINT(ewe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4144 |
__MKSMALLINT(ewe->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4145 |
__MKSMALLINT(ewe->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4146 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4147 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4148 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4149 |
case LeaveNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4150 |
(*plS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4151 |
@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
|
4152 |
__MKSMALLINT(lwe->state), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4153 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4154 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4155 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4156 |
case GraphicsExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4157 |
(*gexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4158 |
@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
|
4159 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4160 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4161 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4162 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4163 |
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
|
4164 |
theView); |
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 |
if (ee->count != 0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4167 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4168 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4169 |
/* fall into */ |
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 |
case NoExpose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4172 |
(*nexpS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4173 |
@symbol(noExposeView:), nil, &nexpS, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4174 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4175 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4176 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4177 |
case Expose: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4178 |
(*expS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4179 |
@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
|
4180 |
__MKSMALLINT(ee->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4181 |
__MKSMALLINT(ee->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4182 |
__MKSMALLINT(ee->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4183 |
__MKSMALLINT(ee->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4184 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4185 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4186 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4187 |
case ConfigureNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4188 |
if (ce->above != None) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4189 |
siblingID = __MKOBJ(ce->above); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4190 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, siblingID); |
1540 | 4191 |
/* |
4192 |
* MKOBJ or #viewFromId: could lead to a GC - refetch event ptr |
|
4193 |
*/ |
|
1521
23aacd62bbac
care for GC before reaccessing the eventBuffer
Claus Gittinger <cg@exept.de>
parents:
1511
diff
changeset
|
4194 |
eB = __INST(eventBuffer); |
1540 | 4195 |
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
|
4196 |
} |
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 |
(*confS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4199 |
@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
|
4200 |
__MKSMALLINT(ce->x), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4201 |
__MKSMALLINT(ce->y), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4202 |
__MKSMALLINT(ce->width), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4203 |
__MKSMALLINT(ce->height), |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4204 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4205 |
if (sibling != nil) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4206 |
(*coveredS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4207 |
@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
|
4208 |
theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4209 |
sibling); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4210 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4211 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4212 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4213 |
case ClientMessage: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4214 |
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
|
4215 |
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
|
4216 |
|| (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
|
4217 |
(*termS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4218 |
@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
|
4219 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4220 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4221 |
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
|
4222 |
(*savtermS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4223 |
@symbol(saveAndTerminateView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4224 |
, nil, &savtermS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4225 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4226 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4227 |
} |
1540 | 4228 |
/* |
4229 |
* any other client message |
|
4230 |
*/ |
|
4231 |
i = (char *)(&(ev->xclient.data)) - (char *)ev; |
|
4232 |
(*clientMsg.ilc_func)(self, |
|
1543 | 4233 |
@symbol(clientMessage:type:format:dataOffset:view:) |
1540 | 4234 |
, nil, &clientMsg |
1543 | 4235 |
, __INST(eventBuffer) |
4236 |
,__MKSMALLINT(ev->xclient.message_type) |
|
4237 |
,__MKSMALLINT(ev->xclient.format) |
|
4238 |
,__MKSMALLINT(i), |
|
4239 |
theView); |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4240 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4241 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4242 |
case DestroyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4243 |
(*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
|
4244 |
, nil, &destrS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4245 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4246 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4247 |
case UnmapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4248 |
(*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
|
4249 |
, nil, &unmapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4250 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4251 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4252 |
case MapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4253 |
(*mapS.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4254 |
@symbol(mappedView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4255 |
, nil, &mapS, theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4256 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4257 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4258 |
case KeymapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4259 |
(*keymap.ilc_func)(theView, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4260 |
@symbol(keyMapChange) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4261 |
, nil, &keymap); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4262 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4263 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4264 |
case VisibilityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4265 |
switch (ve->state) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4266 |
case VisibilityUnobscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4267 |
arg = @symbol(unobscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4268 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4269 |
case VisibilityPartiallyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4270 |
arg = @symbol(partiallyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4271 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4272 |
case VisibilityFullyObscured: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4273 |
arg = @symbol(fullyObscured); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4274 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4275 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4276 |
(*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
|
4277 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4278 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4279 |
case CreateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4280 |
(*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
|
4281 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4282 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4283 |
case MapRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4284 |
(*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
|
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 ReparentNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4288 |
(*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
|
4289 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4290 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4291 |
case ConfigureRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4292 |
(*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
|
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 |
case GravityNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4296 |
(*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
|
4297 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4298 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4299 |
case ResizeRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4300 |
(*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
|
4301 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4302 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4303 |
case CirculateNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4304 |
(*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
|
4305 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4306 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4307 |
case CirculateRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4308 |
(*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
|
4309 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4310 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4311 |
case PropertyNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4312 |
(*prop.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4313 |
@symbol(propertyChangeView) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4314 |
, nil, &prop, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4315 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4316 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4317 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4318 |
case SelectionClear: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4319 |
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
|
4320 |
(*selClear.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4321 |
@symbol(selectionClear:view:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4322 |
, nil, &selClear, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4323 |
selectionID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4324 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4325 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4326 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4327 |
case SelectionNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4328 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4329 |
* 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
|
4330 |
*/ |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4331 |
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
|
4332 |
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
|
4333 |
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
|
4334 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4335 |
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
|
4336 |
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
|
4337 |
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
|
4338 |
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
|
4339 |
(*selNotify.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4340 |
@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
|
4341 |
, nil, &selNotify, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4342 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4343 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4344 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4345 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4346 |
case SelectionRequest: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4347 |
/* |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4348 |
* someone wants the selection |
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 |
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
|
4351 |
ev->xselectionrequest.property, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4352 |
ev->xselectionrequest.target, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4353 |
ev->xselectionrequest.selection, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4354 |
ev->xselectionrequest.requestor)); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4355 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4356 |
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
|
4357 |
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
|
4358 |
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
|
4359 |
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
|
4360 |
(*selReq.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4361 |
@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
|
4362 |
, nil, &selReq, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4363 |
propertyID, targetID, selectionID, requestorID, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4364 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4365 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4366 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4367 |
case ColormapNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4368 |
(*colormap.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4369 |
@symbol(colorMapChangeView:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4370 |
, nil, &colormap, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4371 |
theView); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4372 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4373 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4374 |
case MappingNotify: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4375 |
switch(mape->request) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4376 |
case MappingModifier: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4377 |
arg = @symbol(mappingModifier); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4378 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4379 |
case MappingKeyboard: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4380 |
arg = @symbol(mappingKeyboard); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4381 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4382 |
case MappingPointer: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4383 |
arg = @symbol(mappingPointer); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4384 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4385 |
default: |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4386 |
arg = nil; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4387 |
break; |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4388 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4389 |
(*mapping.ilc_func)(self, |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4390 |
@symbol(mappingChanged:event:) |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4391 |
, nil, &mapping, arg, eB); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4392 |
break; |
0 | 4393 |
} |
135 | 4394 |
#undef ae |
0 | 4395 |
#undef ee |
4396 |
#undef ke |
|
4397 |
#undef be |
|
4398 |
#undef ce |
|
4399 |
#undef me |
|
4400 |
#undef ewe |
|
4401 |
#undef lwe |
|
4402 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4403 |
#undef mape |
0 | 4404 |
%} |
4405 |
. |
|
4406 |
^ true |
|
4407 |
! |
|
4408 |
||
1344 | 4409 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4410 |
"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
|
4411 |
(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
|
4412 |
This code is somewhat special, since X has a concept of graphic |
295 | 4413 |
expose events (which are sent after a bitblt). After such a bitblt, |
4414 |
we only handle exposes until the graphicsExpose arrives. |
|
4415 |
Other systems may not need such a kludge" |
|
4416 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4417 |
"interested in exposes only ?" |
295 | 4418 |
dispatchingExpose notNil ifTrue:[ |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4419 |
[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
|
4420 |
self dispatchExposeEventFor:dispatchingExpose |
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 |
^ self |
295 | 4423 |
]. |
4424 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4425 |
[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
|
4426 |
(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
|
4427 |
AbortSignal handle:[:ex | |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4428 |
ex return |
1491 | 4429 |
] do:[ |
4430 |
self dispatchLastEvent |
|
4431 |
] |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4432 |
]. |
295 | 4433 |
] |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4434 |
|
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4435 |
"Modified: 26.3.1997 / 19:04:17 / cg" |
295 | 4436 |
! |
4437 |
||
1344 | 4438 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4439 |
"dispose (throw away) specific events. If aWindowId is nil, |
4440 |
events matching the mask are thrown away regardless of which |
|
4441 |
view they are for. Otherwise, only matching events for that |
|
4442 |
view are flushed." |
|
0 | 4443 |
|
4444 |
%{ /* NOCONTEXT */ |
|
4445 |
||
4446 |
XEvent ev; |
|
4447 |
Window win; |
|
4448 |
||
1209 | 4449 |
if (ISCONNECTED |
4450 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4451 |
Display *dpy = myDpy; |
4452 |
||
4453 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4454 |
win = _WindowVal(aWindowIdOrNil); |
|
4455 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4456 |
} else { |
|
4457 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4458 |
} |
|
4459 |
RETURN ( self ); |
|
0 | 4460 |
} |
4461 |
%} |
|
4462 |
. |
|
4463 |
self primitiveFailed |
|
4464 |
! |
|
4465 |
||
1344 | 4466 |
eventMaskFor:anEventSymbol |
295 | 4467 |
"return the eventMask bit-constant corresponding to an event symbol" |
4468 |
||
4469 |
%{ /* NOCONTEXT */ |
|
4470 |
||
4471 |
int m = 0; |
|
4472 |
||
4473 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4474 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4475 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4476 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4477 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4478 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4479 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4480 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4481 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4482 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4483 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4484 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4485 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4486 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4487 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4488 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4489 |
RETURN (__MKSMALLINT(m)); |
295 | 4490 |
%} |
4491 |
! |
|
4492 |
||
1344 | 4493 |
eventPending |
310 | 4494 |
"return true, if any event is pending. |
4495 |
This looks for both the internal queue and the display connection." |
|
12 | 4496 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4497 |
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
|
4498 |
|
12 | 4499 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4500 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4501 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4502 |
^ self eventPendingWithSync:false |
0 | 4503 |
! |
4504 |
||
1344 | 4505 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4506 |
"return true, if a specific event is pending" |
4507 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4508 |
^ 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
|
4509 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4510 |
|
1344 | 4511 |
eventPendingWithSync:doSync |
7 | 4512 |
"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
|
4513 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4514 |
before checking." |
0 | 4515 |
|
12 | 4516 |
%{ /* UNLIMITEDSTACK */ |
0 | 4517 |
|
150 | 4518 |
if (ISCONNECTED) { |
1344 | 4519 |
Display *dpy = myDpy; |
4520 |
||
4521 |
if (doSync == true) { |
|
4522 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4523 |
} |
|
4524 |
if (XPending(dpy)) { |
|
4525 |
RETURN (true); |
|
4526 |
} |
|
150 | 4527 |
} |
4528 |
RETURN ( false ); |
|
0 | 4529 |
%} |
4530 |
! |
|
4531 |
||
1344 | 4532 |
eventQueued |
341 | 4533 |
"return true, if any event is queued" |
4534 |
||
4535 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 4536 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 4537 |
]. |
4538 |
^ self eventQueuedAlready |
|
4539 |
||
4540 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
4541 |
! |
|
4542 |
||
1344 | 4543 |
eventQueuedAlready |
341 | 4544 |
"return true, if any event is queued internally. |
4545 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
4546 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
4547 |
the display connection)." |
|
4548 |
||
4549 |
%{ /* UNLIMITEDSTACK */ |
|
4550 |
||
4551 |
if (ISCONNECTED) { |
|
1344 | 4552 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
4553 |
RETURN (true); |
|
4554 |
} |
|
341 | 4555 |
} |
4556 |
RETURN ( false ); |
|
4557 |
%} |
|
4558 |
! |
|
4559 |
||
1344 | 4560 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 4561 |
"return true, if any of the masked events is pending" |
4562 |
||
4563 |
%{ /* UNLIMITEDSTACK */ |
|
4564 |
||
4565 |
XEvent ev; |
|
4566 |
Window win; |
|
4567 |
int thereIsOne; |
|
4568 |
||
4569 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 4570 |
Display *dpy = myDpy; |
4571 |
||
4572 |
if (doSync == true) { |
|
4573 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4574 |
} |
|
4575 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4576 |
win = _WindowVal(aWindowIdOrNil); |
|
4577 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
4578 |
} else { |
|
4579 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
4580 |
} |
|
4581 |
if (thereIsOne) { |
|
4582 |
XPutBackEvent(dpy, &ev); |
|
4583 |
RETURN ( true ); |
|
4584 |
} |
|
295 | 4585 |
} |
4586 |
RETURN ( false ); |
|
4587 |
%} |
|
4588 |
! |
|
4589 |
||
1344 | 4590 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 4591 |
"return true, if any expose event is pending for a specific view, |
4592 |
or any view (if the arg is nil). |
|
4593 |
This is an X specific, only required after a scroll operation." |
|
7 | 4594 |
|
12 | 4595 |
%{ /* UNLIMITEDSTACK */ |
7 | 4596 |
|
4597 |
XEvent ev; |
|
4598 |
Window win; |
|
81 | 4599 |
int thereIsOne; |
4600 |
||
150 | 4601 |
if (ISCONNECTED) { |
1344 | 4602 |
Display *dpy = myDpy; |
4603 |
||
4604 |
if (doSync == true) { |
|
4605 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4606 |
} |
|
4607 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4608 |
win = _WindowVal(aWindowIdOrNil); |
|
4609 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
4610 |
} else { |
|
4611 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
4612 |
} |
|
4613 |
if (thereIsOne) { |
|
4614 |
XPutBackEvent(dpy, &ev); |
|
4615 |
RETURN ( true ); |
|
4616 |
} |
|
81 | 4617 |
} |
4618 |
RETURN ( false ); |
|
4619 |
%} |
|
4620 |
! |
|
4621 |
||
1344 | 4622 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 4623 |
"read next event - put into local eventBuffer. |
4624 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
4625 |
otherwise only events for that specific view will be fetched. |
|
4626 |
Returns true, if there was an event, false otherwise. |
|
4627 |
This method may block - so you better check for pending events |
|
4628 |
before calling for it. |
|
4629 |
||
4630 |
Sorry I had to split dispatch into this fetch method and an extra |
|
4631 |
handle method to allow unlimitedstack here. |
|
4632 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
4633 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
4634 |
" |
|
81 | 4635 |
|
4636 |
%{ /* UNLIMITEDSTACK */ |
|
4637 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4638 |
Display *dpy; |
295 | 4639 |
Window win, wWanted; |
4640 |
int evMask; |
|
4641 |
OBJ eB; |
|
4642 |
XEvent *ev; |
|
4643 |
||
4644 |
if (! ISCONNECTED) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4645 |
RETURN (false); |
295 | 4646 |
} |
4647 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4648 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4649 |
|
555 | 4650 |
eB = __INST(eventBuffer); |
295 | 4651 |
if (__isByteArray(eB)) { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4652 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4653 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4654 |
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
|
4655 |
RETURN (false); |
295 | 4656 |
} |
4657 |
ev->type = 0; |
|
4658 |
||
4659 |
if (__isSmallInteger(eventMask)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4660 |
evMask = __intVal(eventMask); |
295 | 4661 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4662 |
evMask = ~0; |
295 | 4663 |
} |
4664 |
||
4665 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4666 |
wWanted = _WindowVal(aViewIdOrNil); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4667 |
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
|
4668 |
RETURN ( true ); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4669 |
} |
295 | 4670 |
} else { |
1489
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4671 |
if (evMask == ~0) { |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4672 |
XNextEvent(dpy, ev); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4673 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4674 |
} |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4675 |
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
|
4676 |
RETURN (true); |
f264f7852a8d
avoid creation of a block for every event when a
Claus Gittinger <cg@exept.de>
parents:
1486
diff
changeset
|
4677 |
} |
295 | 4678 |
} |
4679 |
%}. |
|
4680 |
^ false |
|
4681 |
! |
|
4682 |
||
1344 | 4683 |
handleAllEvents |
295 | 4684 |
"from now on, handle any kind of event" |
4685 |
||
4686 |
dispatchingExpose := nil |
|
4687 |
! |
|
4688 |
||
1344 | 4689 |
handleExposeOnlyFor:aView |
295 | 4690 |
"from now on, handle expose events only" |
4691 |
||
4692 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4693 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4694 |
|
1344 | 4695 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4696 |
"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
|
4697 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4698 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4699 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 4700 |
self refreshKeyboardMapping:eB. |
4701 |
"Maybe some of our modifiers have been changed" |
|
4702 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4703 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4704 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4705 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4706 |
! |
4707 |
||
1344 | 4708 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4709 |
"tell X that we are only interested in events from aMask, which |
295 | 4710 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4711 |
||
4712 |
%{ /* NOCONTEXT */ |
|
4713 |
||
4714 |
int mask; |
|
4715 |
||
1209 | 4716 |
if (ISCONNECTED |
4717 |
&& __isExternalAddress(aWindowId) |
|
295 | 4718 |
&& __isSmallInteger(aMask)) { |
1344 | 4719 |
mask = __intVal(aMask); |
295 | 4720 |
|
4721 |
#ifdef OLD |
|
1344 | 4722 |
/* these may not be disabled */ |
4723 |
mask |= ExposureMask | StructureNotifyMask | |
|
4724 |
KeyPressMask | KeyReleaseMask | |
|
4725 |
EnterWindowMask | LeaveWindowMask | |
|
4726 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 4727 |
#endif |
4728 |
||
1344 | 4729 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
4730 |
RETURN ( self ); |
|
295 | 4731 |
} |
4732 |
%} |
|
4733 |
. |
|
4734 |
self primitiveFailed |
|
4735 |
! |
|
4736 |
||
1344 | 4737 |
startDispatch |
295 | 4738 |
"redefined to clear dispatchingExpose, which is a special X feature" |
4739 |
||
4740 |
dispatching ifTrue:[^ self]. |
|
4741 |
dispatchingExpose := nil. |
|
4742 |
super startDispatch |
|
0 | 4743 |
! ! |
295 | 4744 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4745 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4746 |
|
1556 | 4747 |
sendClientEvent:msgType format:format to:targetWindowID data1:d1 data2:d2 data3:d3 data4:d4 data5:d5 |
4748 |
"send a ClientMessage to some other (possibly: non-ST/X) view. |
|
4749 |
The client message gets message_type and format as specified by |
|
4750 |
the arguments. The additional data arguments specify up to |
|
4751 |
5 longWords of user data; each may be an integer or nil. |
|
4752 |
It is passed transparently in the events data field. |
|
4753 |
See XProtocol specification for more details." |
|
4754 |
||
4755 |
"/ Event.xclient.type = ClientMessage; |
|
4756 |
"/ Event.xclient.display = dpy; |
|
4757 |
"/ Event.xclient.message_type = msgType; |
|
4758 |
"/ Event.xclient.format = format; |
|
4759 |
"/ Event.xclient.window = targetWindowID; |
|
4760 |
"/ Event.xclient.data.l[0] = d1 |
|
4761 |
"/ Event.xclient.data.l[1] = d2 |
|
4762 |
"/ Event.xclient.data.l[2] = d3 |
|
4763 |
"/ Event.xclient.data.l[3] = d4 |
|
4764 |
"/ Event.xclient.data.l[4] = d5 |
|
4765 |
"/ |
|
4766 |
"/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event); |
|
4767 |
||
4768 |
%{ /* NOCONTEXT */ |
|
4769 |
int type; |
|
4770 |
int state; |
|
4771 |
||
4772 |
if (ISCONNECTED |
|
4773 |
&& __isInteger(msgType) |
|
4774 |
&& __isInteger(format) |
|
4775 |
&& (__isExternalAddress(targetWindowID) || __isInteger(targetWindowID))) { |
|
4776 |
Display *dpy = myDpy; |
|
4777 |
XEvent ev; |
|
4778 |
Status result; |
|
4779 |
||
4780 |
if (__isInteger(d1)) { |
|
4781 |
ev.xclient.data.l[0] = __longIntVal(d1); |
|
4782 |
} else { |
|
4783 |
if (__isExternalAddress(d1)) { |
|
4784 |
ev.xclient.data.l[0] = (int)__externalAddressVal(d1); |
|
4785 |
} else { |
|
4786 |
ev.xclient.data.l[0] = 0; |
|
4787 |
} |
|
4788 |
} |
|
4789 |
if (__isInteger(d2)) { |
|
4790 |
ev.xclient.data.l[1] = __longIntVal(d2); |
|
4791 |
} else { |
|
4792 |
if (__isExternalAddress(d2)) { |
|
4793 |
ev.xclient.data.l[1] = (int)__externalAddressVal(d2); |
|
4794 |
} else { |
|
4795 |
ev.xclient.data.l[1] = 0; |
|
4796 |
} |
|
4797 |
} |
|
4798 |
if (__isInteger(d3)) { |
|
4799 |
ev.xclient.data.l[2] = __longIntVal(d3); |
|
4800 |
} else { |
|
4801 |
if (__isExternalAddress(d3)) { |
|
4802 |
ev.xclient.data.l[2] = (int)__externalAddressVal(d3); |
|
4803 |
} else { |
|
4804 |
ev.xclient.data.l[2] = 0; |
|
4805 |
} |
|
4806 |
} |
|
4807 |
if (__isInteger(d4)) { |
|
4808 |
ev.xclient.data.l[3] = __longIntVal(d4); |
|
4809 |
} else { |
|
4810 |
if (__isExternalAddress(d4)) { |
|
4811 |
ev.xclient.data.l[3] = (int)__externalAddressVal(d4); |
|
4812 |
} else { |
|
4813 |
ev.xclient.data.l[3] = 0; |
|
4814 |
} |
|
4815 |
} |
|
4816 |
if (__isInteger(d5)) { |
|
4817 |
ev.xclient.data.l[4] = __longIntVal(d5); |
|
4818 |
} else { |
|
4819 |
if (__isExternalAddress(d5)) { |
|
4820 |
ev.xclient.data.l[4] = (int)__externalAddressVal(d5); |
|
4821 |
} else { |
|
4822 |
ev.xclient.data.l[4] = 0; |
|
4823 |
} |
|
4824 |
} |
|
4825 |
||
4826 |
if (__isExternalAddress(targetWindowID)) { |
|
4827 |
ev.xclient.window = _WindowVal(targetWindowID); |
|
4828 |
} else { |
|
4829 |
ev.xclient.window = (Window)__longIntVal(targetWindowID); |
|
4830 |
} |
|
4831 |
||
4832 |
ev.xclient.type = ClientMessage; |
|
4833 |
ev.xclient.display = dpy; |
|
4834 |
ev.xclient.message_type = __longIntVal(msgType); |
|
4835 |
ev.xclient.format = __longIntVal(format); |
|
4836 |
||
4837 |
result = XSendEvent(dpy, ev.xclient.window, True, NoEventMask , &ev); |
|
4838 |
||
4839 |
if ((result == BadValue) || (result == BadWindow)) { |
|
4840 |
DPRINTF(("bad status in sendClientEvent\n")); |
|
4841 |
RETURN ( false ) |
|
4842 |
} |
|
4843 |
RETURN (true) |
|
4844 |
} |
|
4845 |
%}. |
|
4846 |
self primitiveFailed. |
|
4847 |
^ false |
|
4848 |
! |
|
4849 |
||
1344 | 4850 |
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
|
4851 |
"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
|
4852 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4853 |
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
|
4854 |
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
|
4855 |
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
|
4856 |
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
|
4857 |
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
|
4858 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4859 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4860 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4861 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4862 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4863 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4864 |
if (__isSmallInteger(stateMask)) { |
1344 | 4865 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4866 |
} else { |
1344 | 4867 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4868 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4869 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4870 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4871 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4872 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4873 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 4874 |
Display *dpy = myDpy; |
4875 |
||
4876 |
XEvent ev; |
|
4877 |
Window target; |
|
4878 |
Status result; |
|
4879 |
KeySym keySym, *syms; |
|
4880 |
int screen = __intVal(__INST(screen)); |
|
4881 |
char s[2]; |
|
4882 |
int nSyms; |
|
4883 |
||
4884 |
if ((typeSymbol == @symbol(keyPress)) |
|
4885 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
4886 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
4887 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
4888 |
} else { |
|
4889 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
4890 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
4891 |
s[1] = '\0'; |
|
4892 |
keySym = XStringToKeysym(s); |
|
4893 |
} else { |
|
4894 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
4895 |
} |
|
4896 |
} |
|
4897 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
4898 |
||
4899 |
if (stateMask == nil) { |
|
4900 |
/* |
|
4901 |
* get the modifier from the keySym |
|
4902 |
*/ |
|
4903 |
nSyms = 0; |
|
4904 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
4905 |
if (syms) { |
|
4906 |
int i; |
|
4907 |
||
4908 |
for (i=0; i<nSyms; i++) { |
|
4909 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4910 |
#ifdef MODIFIERDEBUG |
1344 | 4911 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4912 |
#endif |
1344 | 4913 |
if (i) state = (1 << (i-1)); |
4914 |
break; |
|
4915 |
} |
|
4916 |
} |
|
4917 |
XFree(syms); |
|
4918 |
} |
|
4919 |
} |
|
4920 |
} else { |
|
4921 |
if ((typeSymbol == @symbol(buttonPress)) |
|
4922 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
4923 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
4924 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
4925 |
} else { |
|
4926 |
ev.xbutton.button = 1; |
|
4927 |
} |
|
4928 |
} else { |
|
4929 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
4930 |
RETURN (false); |
|
4931 |
} |
|
4932 |
} |
|
4933 |
||
4934 |
if (typeSymbol == @symbol(keyPress)) |
|
4935 |
ev.xany.type = KeyPress; |
|
4936 |
else if (typeSymbol == @symbol(keyRelease)) |
|
4937 |
ev.xany.type = KeyRelease; |
|
4938 |
else if (typeSymbol == @symbol(buttonPress)) |
|
4939 |
ev.xany.type = ButtonPress; |
|
4940 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
4941 |
ev.xany.type = ButtonRelease; |
|
4942 |
||
4943 |
if (__isExternalAddress(targetId)) { |
|
4944 |
target = _WindowVal(targetId); |
|
4945 |
} else { |
|
4946 |
target = (Window) __longIntVal(targetId); |
|
4947 |
} |
|
4948 |
ev.xkey.window = target; |
|
4949 |
ev.xkey.same_screen = 1; |
|
4950 |
ev.xkey.subwindow = 0; |
|
4951 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
4952 |
ev.xkey.x = __intVal(xPos); |
|
4953 |
ev.xkey.y = __intVal(yPos); |
|
4954 |
ev.xkey.state = state; |
|
4955 |
ev.xkey.time = CurrentTime; |
|
4956 |
||
4957 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
|
4958 |
if ((result == BadValue) || (result == BadWindow)) { |
|
4959 |
DPRINTF(("bad status\n")); |
|
4960 |
RETURN ( false ) |
|
4961 |
} |
|
4962 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4963 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4964 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4965 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4966 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4967 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4968 |
|
1344 | 4969 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4970 |
"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
|
4971 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4972 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4973 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 4974 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4975 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4976 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4977 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4978 |
aCharacterOrString isString ifTrue:[ |
1344 | 4979 |
aCharacterOrString do:[:char | |
4980 |
self simulateKeyboardInput:char inViewId:viewId |
|
4981 |
]. |
|
4982 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4983 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4984 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4985 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4986 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4987 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4988 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 4989 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4990 |
] ifFalse:[ |
1344 | 4991 |
(aCharacterOrString == Character tab) ifTrue:[ |
4992 |
code := #Tab |
|
4993 |
] ifFalse:[ |
|
4994 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4995 |
code := #Escape |
|
4996 |
] |
|
4997 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4998 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4999 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5000 |
control ifTrue:[ |
1344 | 5001 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5002 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5003 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5004 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5005 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5006 |
"/ (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
|
5007 |
"/ 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
|
5008 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5009 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5010 |
code isNumber ifTrue:[ |
1344 | 5011 |
code >= $A asciiValue ifTrue:[ |
5012 |
code <= $Z asciiValue ifTrue:[ |
|
5013 |
state := self shiftMask |
|
5014 |
] |
|
5015 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5016 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5017 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5018 |
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
|
5019 |
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
|
5020 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5021 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5022 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5023 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5024 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5025 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5026 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5027 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5028 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5029 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5030 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
5031 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5032 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5033 |
|
295 | 5034 |
!XWorkstation methodsFor:'font stuff'! |
5035 |
||
1344 | 5036 |
createFontFor:aFontName |
295 | 5037 |
"a basic method for X-font allocation; this method allows |
5038 |
any font to be aquired (even those not conforming to |
|
5039 |
standard naming conventions, such as cursor, fixed or k14)" |
|
5040 |
||
5041 |
%{ /* UNLIMITEDSTACK */ |
|
5042 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
5043 |
||
5044 |
XFontStruct *newFont; |
|
5045 |
||
5046 |
if (ISCONNECTED) { |
|
1344 | 5047 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
5048 |
BEGIN_INTERRUPTSBLOCKED |
|
5049 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5050 |
#ifdef COUNT_RESOURCES |
1344 | 5051 |
if (newFont) |
5052 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5053 |
#endif |
1344 | 5054 |
END_INTERRUPTSBLOCKED |
5055 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
5056 |
} |
|
295 | 5057 |
} |
5058 |
%}. |
|
5059 |
^ nil |
|
5060 |
! |
|
5061 |
||
1344 | 5062 |
decomposeXFontName:aString into:aBlock |
295 | 5063 |
"extract family, face, style and size from an |
5064 |
X-font name |
|
5065 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
5066 |
evaluate aBlock with these" |
|
5067 |
||
5068 |
|origin family face style moreStyle skip fheight size |
|
5069 |
resX resY x1 x2 coding start end | |
|
5070 |
||
5071 |
aString isNil ifTrue:[^ false]. |
|
5072 |
(aString startsWith:'-') ifFalse:[ |
|
1344 | 5073 |
" |
5074 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
5075 |
" |
|
5076 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
5077 |
end := aString indexOf:$- startingAt:1. |
|
5078 |
family := aString copyFrom:1 to:(end - 1). |
|
5079 |
start := end + 1. |
|
5080 |
end := aString indexOf:$- startingAt:start. |
|
5081 |
style := aString copyFrom:start to:(end - 1). |
|
5082 |
start := end + 1. |
|
5083 |
size := aString copyFrom:start. |
|
5084 |
size := (Number readFromString:size onError:[^false]). |
|
5085 |
aBlock value:family value:nil value:style value:size value:nil. |
|
5086 |
^ true. |
|
5087 |
]. |
|
5088 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
5089 |
" |
|
5090 |
something like lucidasans-24 |
|
5091 |
" |
|
5092 |
end := aString indexOf:$- startingAt:1. |
|
5093 |
||
5094 |
family := aString copyFrom:1 to:(end - 1). |
|
5095 |
start := end + 1. |
|
5096 |
size := aString copyFrom:start. |
|
5097 |
size := (Number readFromString:size onError:[^false]). |
|
5098 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
5099 |
^ true. |
|
5100 |
]. |
|
5101 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
5102 |
^ true. |
|
295 | 5103 |
]. |
5104 |
||
5105 |
end := aString indexOf:$- startingAt:2. |
|
5106 |
(end == 0) ifTrue:[^ false]. |
|
5107 |
origin := aString copyFrom:2 to:(end - 1). |
|
5108 |
||
5109 |
start := end + 1. |
|
5110 |
end := aString indexOf:$- startingAt:start. |
|
5111 |
(end == 0) ifTrue:[^ false]. |
|
5112 |
family := aString copyFrom:start to:(end - 1). |
|
5113 |
||
5114 |
start := end + 1. |
|
5115 |
end := aString indexOf:$- startingAt:start. |
|
5116 |
(end == 0) ifTrue:[^ false]. |
|
5117 |
face := aString copyFrom:start to:(end - 1). |
|
5118 |
||
5119 |
start := end + 1. |
|
5120 |
end := aString indexOf:$- startingAt:start. |
|
5121 |
(end == 0) ifTrue:[^ false]. |
|
5122 |
style := aString copyFrom:start to:(end - 1). |
|
5123 |
(style = 'o') ifTrue:[ |
|
1344 | 5124 |
style := 'oblique' |
295 | 5125 |
] ifFalse:[ |
1344 | 5126 |
(style = 'i') ifTrue:[ |
5127 |
style := 'italic' |
|
5128 |
] ifFalse:[ |
|
5129 |
(style = 'r') ifTrue:[ |
|
5130 |
style := 'roman' |
|
5131 |
] |
|
5132 |
] |
|
295 | 5133 |
]. |
5134 |
||
5135 |
start := end + 1. |
|
5136 |
end := aString indexOf:$- startingAt:start. |
|
5137 |
(end == 0) ifTrue:[^ false]. |
|
5138 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
5139 |
||
5140 |
start := end + 1. |
|
5141 |
end := aString indexOf:$- startingAt:start. |
|
5142 |
(end == 0) ifTrue:[^ false]. |
|
5143 |
skip := aString copyFrom:start to:(end - 1). |
|
5144 |
||
5145 |
start := end + 1. |
|
5146 |
end := aString indexOf:$- startingAt:start. |
|
5147 |
(end == 0) ifTrue:[^ false]. |
|
5148 |
fheight := aString copyFrom:start to:(end - 1). |
|
5149 |
||
5150 |
start := end + 1. |
|
5151 |
end := aString indexOf:$- startingAt:start. |
|
5152 |
(end == 0) ifTrue:[^ false]. |
|
5153 |
size := aString copyFrom:start to:(end - 1). |
|
5154 |
size := (Number readFromString:size) / 10. |
|
5155 |
||
5156 |
start := end + 1. |
|
5157 |
end := aString indexOf:$- startingAt:start. |
|
5158 |
(end == 0) ifTrue:[^ false]. |
|
5159 |
resX := aString copyFrom:start to:(end - 1). |
|
5160 |
||
5161 |
start := end + 1. |
|
5162 |
end := aString indexOf:$- startingAt:start. |
|
5163 |
(end == 0) ifTrue:[^ false]. |
|
5164 |
resY := aString copyFrom:start to:(end - 1). |
|
5165 |
||
5166 |
start := end + 1. |
|
5167 |
end := aString indexOf:$- startingAt:start. |
|
5168 |
(end == 0) ifTrue:[^ false]. |
|
5169 |
x1 := aString copyFrom:start to:(end - 1). |
|
5170 |
||
5171 |
start := end + 1. |
|
5172 |
end := aString indexOf:$- startingAt:start. |
|
5173 |
(end == 0) ifTrue:[^ false]. |
|
5174 |
x2 := aString copyFrom:start to:(end - 1). |
|
5175 |
||
5176 |
start := end + 1. |
|
5177 |
end := aString indexOf:$- startingAt:start. |
|
5178 |
(end == 0) ifTrue:[^ false]. |
|
5179 |
coding := aString copyFrom:start to:(end - 1). |
|
5180 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5181 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1344 | 5182 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5183 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5184 |
|
295 | 5185 |
aBlock value:family value:face value:style value:size value:coding. |
5186 |
^ true |
|
5187 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5188 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 5189 |
! |
5190 |
||
1344 | 5191 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5192 |
"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
|
5193 |
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
|
5194 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5195 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5196 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5197 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5198 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5199 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5200 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5201 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5202 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5203 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5204 |
if (ISCONNECTED) { |
1344 | 5205 |
Display *dpy = myDpy; |
5206 |
||
5207 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
5208 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
5209 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
5210 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5211 |
||
5212 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5213 |
|
1344 | 5214 |
f = _FontVal(aFontId); |
5215 |
if (f) { |
|
5216 |
n = f->n_properties; |
|
5217 |
prop = f->properties; |
|
5218 |
if (prop) { |
|
5219 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5220 |
#ifdef SUPERDEBUG |
1344 | 5221 |
cp = XGetAtomName(dpy, prop->name); |
5222 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5223 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5224 |
#endif |
1344 | 5225 |
if (prop->name == XA_FULL_NAME) { |
5226 |
cp = XGetAtomName(dpy, prop->card32); |
|
5227 |
if (cp) { |
|
5228 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5229 |
#ifdef SUPERDEBUG |
1344 | 5230 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5231 |
#endif |
1344 | 5232 |
XFree(cp); |
5233 |
} |
|
5234 |
} else if (prop->name == fontAtom) { |
|
5235 |
cp = XGetAtomName(dpy, prop->card32); |
|
5236 |
if (cp) { |
|
5237 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5238 |
#ifdef SUPERDEBUG |
1344 | 5239 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5240 |
#endif |
1344 | 5241 |
XFree(cp); |
5242 |
} |
|
5243 |
} else if (prop->name == encodingAtom) { |
|
5244 |
cp = XGetAtomName(dpy, prop->card32); |
|
5245 |
if (cp) { |
|
5246 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5247 |
#ifdef SUPERDEBUG |
1344 | 5248 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5249 |
#endif |
1344 | 5250 |
XFree(cp); |
5251 |
} |
|
5252 |
} else if (prop->name == registryAtom) { |
|
5253 |
cp = XGetAtomName(dpy, prop->card32); |
|
5254 |
if (cp) { |
|
5255 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5256 |
#ifdef SUPERDEBUG |
1344 | 5257 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5258 |
#endif |
1344 | 5259 |
XFree(cp); |
5260 |
} |
|
5261 |
} else if (prop->name == charSetCollAtom) { |
|
5262 |
cp = XGetAtomName(dpy, prop->card32); |
|
5263 |
if (cp) { |
|
5264 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5265 |
#ifdef SUPERDEBUG |
1344 | 5266 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5267 |
#endif |
1344 | 5268 |
XFree(cp); |
5269 |
} |
|
5270 |
} |
|
5271 |
prop++; |
|
5272 |
} |
|
5273 |
} |
|
5274 |
} |
|
5275 |
} |
|
440
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 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5278 |
^ self |
1344 | 5279 |
extractEncodingFromRegistry:registry |
5280 |
encoding:encoding |
|
5281 |
charSetCollections:charSetCollections |
|
5282 |
! |
|
5283 |
||
5284 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5285 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5286 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5287 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5288 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5289 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 5290 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5291 |
] ifFalse:[ |
1344 | 5292 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
5293 |
enc := encoding asLowercase asSymbol |
|
5294 |
] ifFalse:[ |
|
5295 |
charSets := charSetCollections. |
|
5296 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
5297 |
charSets := charSets asUppercase asCollectionOfWords. |
|
5298 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
5299 |
enc := #iso8859 |
|
5300 |
] ifFalse:[ |
|
5301 |
(charSets includes:'ISO8859') ifTrue:[ |
|
5302 |
enc := #iso8859 |
|
5303 |
] ifFalse:[ |
|
5304 |
(charSets includes:'ASCII') ifTrue:[ |
|
5305 |
enc := #ascii |
|
5306 |
] ifFalse:[ |
|
5307 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
5308 |
enc := #iso8859 |
|
5309 |
] |
|
5310 |
] |
|
5311 |
] |
|
5312 |
] |
|
5313 |
] |
|
5314 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5315 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5316 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5317 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
5318 |
"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
|
5319 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5320 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5321 |
|
1344 | 5322 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5323 |
"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
|
5324 |
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
|
5325 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5326 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5327 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5328 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5329 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5330 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5331 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5332 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5333 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5334 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5335 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5336 |
|
1344 | 5337 |
fontMetricsOf:fontId into:aBlock |
991 | 5338 |
"evaluate aBlock, passing a fonts metrics as arguments" |
5339 |
||
5340 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5341 |
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
|
5342 |
res resX resY| |
991 | 5343 |
|
994 | 5344 |
%{ |
991 | 5345 |
XFontStruct *f; |
5346 |
int len; |
|
5347 |
||
5348 |
if (ISCONNECTED) { |
|
1344 | 5349 |
if (__isExternalAddress(fontId)) { |
5350 |
f = _FontVal(fontId); |
|
5351 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5352 |
#ifdef NOTDEF |
1344 | 5353 |
char *cp; |
5354 |
XFontProp *prop; |
|
5355 |
||
5356 |
n = f->n_properties; |
|
5357 |
prop = f->properties; |
|
5358 |
||
5359 |
if (prop) { |
|
5360 |
while (n--) { |
|
5361 |
if (prop->name == RESOLUTION_X) { |
|
5362 |
resX = __MKSMALLINT(prop->card32); |
|
5363 |
} else if (prop->name == RESOLUTION_Y) { |
|
5364 |
resY = __MKSMALLINT(prop->card32); |
|
5365 |
} else if (prop->name == RESOLUTION) { |
|
5366 |
res = __MKSMALLINT(prop->card32); |
|
5367 |
} |
|
5368 |
prop++; |
|
5369 |
} |
|
5370 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5371 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5372 |
|
1344 | 5373 |
avgAscent = __MKSMALLINT(f->ascent); |
5374 |
avgDescent = __MKSMALLINT(f->descent); |
|
5375 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
5376 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
5377 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
5378 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
5379 |
BEGIN_INTERRUPTSBLOCKED |
|
5380 |
len = XTextWidth(f, " ", 1); |
|
5381 |
END_INTERRUPTSBLOCKED |
|
5382 |
avgWidth = __MKSMALLINT( len ); |
|
5383 |
} |
|
5384 |
} |
|
991 | 5385 |
} |
5386 |
%}. |
|
5387 |
encoding := self encodingOf:fontId. |
|
5388 |
aBlock value:encoding |
|
1344 | 5389 |
value:avgAscent |
5390 |
value:avgDescent |
|
5391 |
value:maxAscent |
|
5392 |
value:maxDescent |
|
5393 |
value:minWidth |
|
5394 |
value:maxWidth |
|
5395 |
value:avgWidth |
|
5396 |
! |
|
5397 |
||
5398 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5399 |
"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
|
5400 |
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
|
5401 |
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
|
5402 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5403 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5404 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5405 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5406 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5407 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5408 |
if (ISCONNECTED) { |
1344 | 5409 |
Display *dpy = myDpy; |
5410 |
||
5411 |
if (__isExternalAddress(fontId)) { |
|
5412 |
f = _FontVal(fontId); |
|
5413 |
if (f) { |
|
5414 |
char *cp; |
|
5415 |
XFontProp *prop; |
|
5416 |
Atom resolutionXAtom, resolutionYAtom; |
|
5417 |
int n; |
|
5418 |
||
5419 |
n = f->n_properties; |
|
5420 |
prop = f->properties; |
|
5421 |
||
5422 |
if (prop) { |
|
5423 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
5424 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
5425 |
||
5426 |
while (n--) { |
|
5427 |
if (prop->name == resolutionXAtom) { |
|
5428 |
resX = __MKSMALLINT(prop->card32); |
|
5429 |
} else if (prop->name == resolutionYAtom) { |
|
5430 |
resY = __MKSMALLINT(prop->card32); |
|
5431 |
} else if (prop->name == XA_RESOLUTION) { |
|
5432 |
res = __MKSMALLINT(prop->card32); |
|
5433 |
} |
|
5434 |
prop++; |
|
5435 |
} |
|
5436 |
} |
|
5437 |
} |
|
5438 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5439 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5440 |
%}. |
1046 | 5441 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 5442 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5443 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5444 |
res notNil ifTrue:[ |
1344 | 5445 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5446 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5447 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5448 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5449 |
|
1344 | 5450 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5451 |
"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
|
5452 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5453 |
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
|
5454 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5455 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5456 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5457 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5458 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5459 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5460 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5461 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5462 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5463 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5464 |
if (ISCONNECTED) { |
1344 | 5465 |
Display *dpy = myDpy; |
5466 |
||
5467 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5468 |
||
5469 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5470 |
|
1344 | 5471 |
f = _FontVal(aFontId); |
5472 |
if (f) { |
|
5473 |
n = f->n_properties; |
|
5474 |
prop = f->properties; |
|
5475 |
if (prop) { |
|
5476 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5477 |
#ifdef SUPERDEBUG |
1344 | 5478 |
cp = XGetAtomName(dpy, prop->name); |
5479 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5480 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5481 |
#endif |
1344 | 5482 |
if (prop->name == XA_FULL_NAME) { |
5483 |
cp = XGetAtomName(dpy, prop->card32); |
|
5484 |
if (cp) { |
|
5485 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5486 |
#ifdef SUPERDEBUG |
1344 | 5487 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5488 |
#endif |
1344 | 5489 |
XFree(cp); |
5490 |
} |
|
5491 |
} |
|
5492 |
if (prop->name == fontAtom) { |
|
5493 |
cp = XGetAtomName(dpy, prop->card32); |
|
5494 |
if (cp) { |
|
5495 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5496 |
#ifdef SUPERDEBUG |
1344 | 5497 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5498 |
#endif |
1344 | 5499 |
XFree(cp); |
5500 |
} |
|
5501 |
} |
|
5502 |
prop++; |
|
5503 |
} |
|
5504 |
} |
|
5505 |
} |
|
5506 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5507 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5508 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5509 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 5510 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5511 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5512 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5513 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5514 |
|
1344 | 5515 |
getAvailableFontsMatching:pattern |
295 | 5516 |
"return an Array filled with font names matching aPattern" |
5517 |
||
5518 |
%{ /* UNLIMITEDSTACK */ |
|
5519 |
||
5520 |
int nnames = 1500; |
|
5521 |
int available = nnames + 1; |
|
5522 |
char **fonts; |
|
5523 |
OBJ arr, str; |
|
5524 |
int i; |
|
5525 |
||
5526 |
if (ISCONNECTED) { |
|
1344 | 5527 |
if (__isString(pattern)) { |
5528 |
for (;;) { |
|
5529 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
5530 |
if ((fonts == NULL) || (available < nnames)) break; |
|
5531 |
XFreeFontNames(fonts); |
|
5532 |
nnames = available * 2; |
|
5533 |
} |
|
5534 |
if (fonts == NULL) { |
|
5535 |
RETURN ( nil ); |
|
5536 |
} |
|
5537 |
/* |
|
5538 |
* now, that we know the number of font names, |
|
5539 |
* create the array ... |
|
5540 |
*/ |
|
5541 |
arr = __ARRAY_NEW_INT(available); |
|
5542 |
if (! arr) { |
|
5543 |
RETURN (nil); |
|
5544 |
} |
|
5545 |
/* |
|
5546 |
* ... and fill it |
|
5547 |
*/ |
|
5548 |
for (i=0; i<available; i++) { |
|
5549 |
__PROTECT__(arr); |
|
5550 |
str = __MKSTRING(fonts[i]); |
|
5551 |
__UNPROTECT__(arr); |
|
5552 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
5553 |
} |
|
5554 |
RETURN (arr); |
|
5555 |
} |
|
295 | 5556 |
} |
5557 |
%}. |
|
5558 |
^ nil |
|
5559 |
! |
|
5560 |
||
1344 | 5561 |
getDefaultFont |
295 | 5562 |
"return a default font id - used when class Font cannot |
5563 |
find anything usable" |
|
5564 |
||
5565 |
^ self createFontFor:'fixed' |
|
5566 |
! |
|
5567 |
||
1344 | 5568 |
getFontWithFamily:familyString face:faceString |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5569 |
style:styleArgString size:sizeArg encoding:encodingSym |
295 | 5570 |
|
5571 |
"try to get the specified font, if not available, try next smaller |
|
5572 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
5573 |
as family and the other parameters as nil. For example, the cursor font |
|
5574 |
can be aquired that way." |
|
5575 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5576 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5577 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5578 |
styleString := styleArgString. |
295 | 5579 |
|
5580 |
"special: if face is nil, allow access to X-fonts" |
|
5581 |
faceString isNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5582 |
sizeArg notNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5583 |
theName := familyString , '-' , sizeArg printString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5584 |
] ifFalse:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5585 |
theName := familyString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5586 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5587 |
theName isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5588 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5589 |
mhmh - fall back to the default font |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5590 |
" |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5591 |
theName := 'fixed' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5592 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5593 |
theId := self createFontFor:theName. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5594 |
theId isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5595 |
theId := self getDefaultFont |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5596 |
]. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5597 |
^ theId |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5598 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5599 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5600 |
"/ 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
|
5601 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5602 |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5603 |
(styleString notNil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5604 |
and:[(styleString endsWith:'-narrow') |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5605 |
or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5606 |
|i| |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5607 |
i := styleString lastIndexOf:$-. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5608 |
spacing := styleString copyFrom:(i+1). |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5609 |
styleString := styleString copyTo:(i-1). |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5610 |
] ifFalse:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5611 |
spacing := 'normal'. |
295 | 5612 |
]. |
5613 |
||
5614 |
xlatedStyle := styleString. |
|
5615 |
xlatedStyle notNil ifTrue:[ |
|
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5616 |
xlatedStyle := xlatedStyle first asString |
295 | 5617 |
]. |
5618 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5619 |
id := self |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5620 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5621 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5622 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5623 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5624 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5625 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5626 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5627 |
registry:encodingSym |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5628 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5629 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5630 |
id isNil ifTrue:[ |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5631 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5632 |
"/ too stupid: encodings come in both cases |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5633 |
"/ and X does not ignore case |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5634 |
"/ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5635 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5636 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5637 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5638 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5639 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5640 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5641 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5642 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5643 |
registry:encodingSym asUppercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5644 |
encoding:'*'. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5645 |
id isNil ifTrue:[ |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5646 |
id := self |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5647 |
getFontWithFoundry:'*' |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5648 |
family:familyString asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5649 |
weight:faceString |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5650 |
slant:xlatedStyle |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5651 |
spacing:spacing |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5652 |
pixelSize:nil |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5653 |
size:sizeArg |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5654 |
registry:encodingSym asLowercase |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5655 |
encoding:'*'. |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5656 |
] |
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5657 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5658 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5659 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5660 |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5661 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
1392
45ae91abdfac
care for nil styleString in #getFontWithFamily...
Claus Gittinger <cg@exept.de>
parents:
1376
diff
changeset
|
5662 |
"Modified: 28.2.1997 / 18:26:12 / cg" |
295 | 5663 |
! |
5664 |
||
1344 | 5665 |
getFontWithFoundry:foundry family:family weight:weight |
5666 |
slant:slant spacing:spc pixelSize:pSize size:size |
|
5667 |
registry:registry encoding:encoding |
|
295 | 5668 |
|
5669 |
"get the specified font, if not available, return nil. |
|
5670 |
This is the new font creation method - all others will be changed to |
|
5671 |
use this entry. |
|
5672 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
5673 |
||
5674 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
5675 |
family: 'helvetica' 'courier' 'times' ... |
|
5676 |
weight: 'bold' 'medium' 'demi' ... |
|
5677 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
5678 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
5679 |
pixelSize: 16,18 ... usually left empty |
|
5680 |
size: size in point (1/72th of an inch) |
|
5681 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5682 |
encoding: vendor specific encoding (usually '*') |
295 | 5683 |
" |
5684 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5685 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5686 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 5687 |
pSizeMatch registryMatch encodingMatch| |
295 | 5688 |
|
5689 |
"this works only on 'Release >= 3' - X-servers" |
|
5690 |
"name is: |
|
1344 | 5691 |
-foundry-family -weight -slant- |
5692 |
sony helvetica bold r |
|
5693 |
adobe courier medium i |
|
5694 |
msic fixed o |
|
5695 |
... ... |
|
295 | 5696 |
" |
5697 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5698 |
size isNil ifTrue:[ |
1344 | 5699 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5700 |
] ifFalse:[ |
1344 | 5701 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5702 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5703 |
foundry isNil ifTrue:[ |
1344 | 5704 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5705 |
] ifFalse:[ |
1344 | 5706 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5707 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5708 |
family isNil ifTrue:[ |
1344 | 5709 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5710 |
] ifFalse:[ |
1344 | 5711 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5712 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5713 |
weight isNil ifTrue:[ |
1344 | 5714 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5715 |
] ifFalse:[ |
1344 | 5716 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5717 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5718 |
slant isNil ifTrue:[ |
1344 | 5719 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5720 |
] ifFalse:[ |
1344 | 5721 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5722 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5723 |
spc isNil ifTrue:[ |
1344 | 5724 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5725 |
] ifFalse:[ |
1344 | 5726 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5727 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5728 |
pSize isNil ifTrue:[ |
1344 | 5729 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5730 |
] ifFalse:[ |
1344 | 5731 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5732 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5733 |
registry isNil ifTrue:[ |
1344 | 5734 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5735 |
] ifFalse:[ |
1344 | 5736 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5737 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5738 |
encoding isNil ifTrue:[ |
1344 | 5739 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5740 |
] ifFalse:[ |
1344 | 5741 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5742 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5743 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5744 |
theName := ('-' , foundryMatch, |
1344 | 5745 |
'-' , familyMatch, |
5746 |
'-' , weightMatch , |
|
5747 |
'-' , slantMatch , |
|
5748 |
'-' , spcMatch , |
|
5749 |
'-*' , |
|
5750 |
'-' , pSizeMatch , |
|
5751 |
'-' , sizeMatch , |
|
5752 |
'-*-*-*-*' , |
|
5753 |
'-' , registryMatch , |
|
5754 |
'-' , encodingMatch). |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5755 |
|
697 | 5756 |
"/ Transcript showCR:theName; endEntry. |
295 | 5757 |
|
5758 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5759 |
|
295 | 5760 |
|
5761 |
" |
|
5762 |
Display getFontWithFoundry:'*' |
|
1344 | 5763 |
family:'courier' |
5764 |
weight:'medium' |
|
5765 |
slant:'r' |
|
5766 |
spacing:nil |
|
5767 |
pixelSize:nil |
|
5768 |
size:13 |
|
5769 |
registry:'iso8859' |
|
5770 |
encoding:'*' |
|
295 | 5771 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5772 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5773 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 5774 |
! |
5775 |
||
1344 | 5776 |
listOfAvailableFonts |
295 | 5777 |
"return a list with all available fonts on this display. |
5778 |
Since this takes a long time, keep the result of the query for the |
|
5779 |
next time. The elements of the returned collection are instances of |
|
5780 |
FontDescription." |
|
5781 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
5782 |
|"stream aName fntDescr" names| |
295 | 5783 |
|
5784 |
listOfXFonts isNil ifTrue:[ |
|
5785 |
"/ |
|
5786 |
"/ old code; using a pipe to xlsfonts |
|
5787 |
"/ |
|
5788 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
5789 |
"/ stream isNil ifTrue:[^ nil]. |
|
5790 |
"/ listOfXFonts := OrderedCollection new. |
|
5791 |
"/ [stream atEnd] whileFalse:[ |
|
5792 |
"/ aName := stream nextLine. |
|
5793 |
"/ aName notNil ifTrue:[ |
|
5794 |
"/ self decomposeXFontName:aName into: |
|
5795 |
"/ [:family :face :style :size :coding | |
|
5796 |
"/ family notNil ifTrue:[ |
|
5797 |
"/ fntDescr := FontDescription |
|
5798 |
"/ family:family |
|
5799 |
"/ face:face |
|
5800 |
"/ style:style |
|
5801 |
"/ size:size |
|
5802 |
"/ encoding:coding. |
|
5803 |
"/ listOfXFonts add:fntDescr |
|
5804 |
"/ ] |
|
5805 |
"/ ] |
|
5806 |
"/ ] |
|
5807 |
"/ ]. |
|
5808 |
"/ stream close. |
|
5809 |
"/ "if xlsfont is broken ... (hey sco)" |
|
5810 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
5811 |
"/ listOfXFonts := nil |
|
5812 |
"/ ] ifFalse:[ |
|
5813 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
5814 |
"/ ]. |
|
5815 |
||
1344 | 5816 |
"/ |
5817 |
"/ new code: |
|
5818 |
"/ use new primitive to get font names; |
|
5819 |
"/ this is much faster, and also works on systems where |
|
5820 |
"/ a) xlsfonts is broken (sco) |
|
5821 |
"/ b) xlsfonts is not available (aix) |
|
5822 |
"/ |
|
5823 |
names := self getAvailableFontsMatching:'*'. |
|
5824 |
names isNil ifTrue:[ |
|
5825 |
"no names returned ..." |
|
5826 |
^ nil |
|
5827 |
]. |
|
5828 |
listOfXFonts := names collect:[:aName | |
|
5829 |
|fntDescr| |
|
5830 |
||
5831 |
(self decomposeXFontName:aName into: |
|
5832 |
[:family :face :style :size :coding | |
|
5833 |
family notNil ifTrue:[ |
|
5834 |
fntDescr := FontDescription |
|
5835 |
family:family |
|
5836 |
face:face |
|
5837 |
style:style |
|
5838 |
size:size |
|
5839 |
encoding:coding. |
|
5840 |
] ifFalse:[ |
|
5841 |
fntDescr := FontDescription |
|
5842 |
name:aName |
|
5843 |
] |
|
5844 |
] |
|
5845 |
) ifFalse:[ |
|
5846 |
fntDescr := FontDescription name:aName. |
|
5847 |
]. |
|
5848 |
fntDescr |
|
5849 |
]. |
|
295 | 5850 |
|
5851 |
]. |
|
5852 |
^ listOfXFonts |
|
5853 |
||
5854 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5855 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5856 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5857 |
Display getAvailableFontsMatching:'*'. |
295 | 5858 |
" |
5859 |
||
5860 |
"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
|
5861 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5862 |
! |
5863 |
||
1344 | 5864 |
releaseFont:aFontId |
295 | 5865 |
|
5866 |
%{ /* NOCONTEXT */ |
|
5867 |
||
5868 |
XFontStruct *f; |
|
5869 |
||
1212 | 5870 |
if (! ISCONNECTED) { |
1344 | 5871 |
RETURN ( self ); |
1212 | 5872 |
} |
5873 |
||
5874 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 5875 |
f = _FontVal(aFontId); |
5876 |
if (f) { |
|
5877 |
BEGIN_INTERRUPTSBLOCKED |
|
5878 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5879 |
#ifdef COUNT_RESOURCES |
1344 | 5880 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5881 |
#endif |
1344 | 5882 |
END_INTERRUPTSBLOCKED |
5883 |
RETURN ( self ); |
|
5884 |
} |
|
295 | 5885 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5886 |
%}. |
295 | 5887 |
self primitiveFailed |
5888 |
! |
|
5889 |
||
1344 | 5890 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5891 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5892 |
on this display. |
|
5893 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5894 |
||
5895 |
|sizes| |
|
5896 |
||
466 | 5897 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5898 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 5899 |
"special: in X11R5 and above, size 0 means: |
5900 |
there are scaled versions in all sizes available" |
|
5901 |
||
5902 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 5903 |
]. |
5904 |
^ sizes |
|
5905 |
||
5906 |
" |
|
5907 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5908 |
" |
|
466 | 5909 |
|
5910 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5911 |
! |
5912 |
||
1344 | 5913 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 5914 |
|
5915 |
%{ /* NOCONTEXT */ |
|
5916 |
||
5917 |
XFontStruct *f; |
|
5918 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5919 |
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
|
5920 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5921 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5922 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5923 |
int nInstBytes; |
295 | 5924 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5925 |
if (ISCONNECTED) { |
1344 | 5926 |
if (__bothSmallInteger(index1, index2) |
5927 |
&& __isExternalAddress(aFontId) |
|
5928 |
&& __isNonNilObject(aString)) { |
|
5929 |
f = _FontVal(aFontId); |
|
5930 |
if (! f) goto fail; |
|
5931 |
||
5932 |
i1 = __intVal(index1) - 1; |
|
5933 |
cls = __qClass(aString); |
|
5934 |
||
5935 |
if (i1 >= 0) { |
|
5936 |
i2 = __intVal(index2) - 1; |
|
5937 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5938 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 5939 |
} |
5940 |
||
5941 |
cp = (char *) _stringVal(aString); |
|
5942 |
l = i2 - i1 + 1; |
|
5943 |
||
5944 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5945 |
n = _stringSize(aString); |
|
5946 |
if (i2 < n) { |
|
5947 |
cp += i1; |
|
5948 |
BEGIN_INTERRUPTSBLOCKED |
|
5949 |
len = XTextWidth(f, cp, l); |
|
5950 |
END_INTERRUPTSBLOCKED |
|
5951 |
RETURN ( __MKSMALLINT(len) ); |
|
5952 |
} |
|
5953 |
} |
|
5954 |
||
5955 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5956 |
cp += nInstBytes; |
|
5957 |
||
5958 |
if (__isBytes(aString)) { |
|
5959 |
n = __byteArraySize(aString) - nInstBytes; |
|
5960 |
if (i2 < n) { |
|
5961 |
cp += i1; |
|
5962 |
BEGIN_INTERRUPTSBLOCKED |
|
5963 |
len = XTextWidth(f, cp, l); |
|
5964 |
END_INTERRUPTSBLOCKED |
|
5965 |
RETURN ( __MKSMALLINT(len) ); |
|
5966 |
} |
|
5967 |
} |
|
5968 |
||
5969 |
/* TWOBYTESTRINGS */ |
|
5970 |
if (__isWords(aString)) { |
|
5971 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5972 |
||
5973 |
if (i2 < n) { |
|
5974 |
union { |
|
5975 |
char b[2]; |
|
5976 |
unsigned short s; |
|
5977 |
} u; |
|
5978 |
int i; |
|
5979 |
XChar2b *cp2 = (XChar2b *)0; |
|
5980 |
int mustFree = 0; |
|
5981 |
||
5982 |
cp += (i1 * 2); |
|
5983 |
if (l > 1000) l = 1000; |
|
5984 |
||
5985 |
/* |
|
5986 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5987 |
* X expects them MSB first |
|
5988 |
* convert as required |
|
5989 |
*/ |
|
5990 |
||
5991 |
u.s = 0x1234; |
|
5992 |
if (u.b[0] != 0x12) { |
|
5993 |
if (l <= NLOCALBUFFER) { |
|
5994 |
cp2 = xlatebuffer; |
|
5995 |
} else { |
|
5996 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5997 |
mustFree = 1; |
|
5998 |
} |
|
5999 |
for (i=0; i<l; i++) { |
|
6000 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6001 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6002 |
} |
|
6003 |
cp = (char *) cp2; |
|
6004 |
} |
|
6005 |
BEGIN_INTERRUPTSBLOCKED |
|
6006 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
6007 |
END_INTERRUPTSBLOCKED |
|
6008 |
||
6009 |
if (mustFree) { |
|
6010 |
free(cp2); |
|
6011 |
} |
|
6012 |
||
6013 |
RETURN ( __MKSMALLINT(len) ); |
|
6014 |
} |
|
6015 |
} |
|
6016 |
} |
|
6017 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6018 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6019 |
#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
|
6020 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6021 |
%}. |
295 | 6022 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6023 |
^ 0 |
295 | 6024 |
! |
6025 |
||
1344 | 6026 |
widthOf:aString inFont:aFontId |
295 | 6027 |
|
6028 |
%{ /* NOCONTEXT */ |
|
6029 |
||
6030 |
XFontStruct *f; |
|
6031 |
char *cp; |
|
6032 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
6033 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6034 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6035 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6036 |
int nInstBytes; |
295 | 6037 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6038 |
if (ISCONNECTED) { |
1344 | 6039 |
if (__isExternalAddress(aFontId) |
6040 |
&& __isNonNilObject(aString)) { |
|
6041 |
f = _FontVal(aFontId); |
|
6042 |
if (! f) goto fail; |
|
6043 |
||
6044 |
cls = __qClass(aString); |
|
6045 |
||
6046 |
cp = (char *)_stringVal(aString); |
|
6047 |
||
6048 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
6049 |
n = _stringSize(aString); |
|
6050 |
BEGIN_INTERRUPTSBLOCKED |
|
6051 |
len = XTextWidth(f, cp, n); |
|
6052 |
END_INTERRUPTSBLOCKED |
|
6053 |
RETURN ( __MKSMALLINT(len) ); |
|
6054 |
} |
|
6055 |
||
6056 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
6057 |
cp += nInstBytes; |
|
6058 |
||
6059 |
if (__isBytes(aString)) { |
|
6060 |
n = __byteArraySize(aString) - nInstBytes; |
|
6061 |
||
6062 |
BEGIN_INTERRUPTSBLOCKED |
|
6063 |
len = XTextWidth(f, cp, n); |
|
6064 |
END_INTERRUPTSBLOCKED |
|
6065 |
RETURN ( __MKSMALLINT(len) ); |
|
6066 |
} |
|
6067 |
||
6068 |
/* TWOBYTESTRINGS */ |
|
6069 |
if (__isWords(aString)) { |
|
6070 |
union { |
|
6071 |
char b[2]; |
|
6072 |
unsigned short s; |
|
6073 |
} u; |
|
6074 |
int i; |
|
6075 |
XChar2b *cp2; |
|
6076 |
int mustFree = 0; |
|
6077 |
||
6078 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
6079 |
if (n > 1000) n = 1000; |
|
6080 |
||
6081 |
/* |
|
6082 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
6083 |
* X expects them MSB first |
|
6084 |
* convert as required |
|
6085 |
*/ |
|
6086 |
||
6087 |
u.s = 0x1234; |
|
6088 |
if (u.b[0] != 0x12) { |
|
6089 |
if (n <= NLOCALBUFFER) { |
|
6090 |
cp2 = xlatebuffer; |
|
6091 |
} else { |
|
6092 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
6093 |
mustFree = 1; |
|
6094 |
} |
|
6095 |
||
6096 |
for (i=0; i<n; i++) { |
|
6097 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
6098 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
6099 |
} |
|
6100 |
cp = (char *) cp2; |
|
6101 |
} |
|
6102 |
||
6103 |
BEGIN_INTERRUPTSBLOCKED |
|
6104 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
6105 |
END_INTERRUPTSBLOCKED |
|
6106 |
||
6107 |
if (mustFree) { |
|
6108 |
free(cp2); |
|
6109 |
} |
|
6110 |
||
6111 |
RETURN ( __MKSMALLINT(len) ); |
|
6112 |
} |
|
6113 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6114 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
6115 |
#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
|
6116 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
6117 |
%}. |
295 | 6118 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
6119 |
^ 0 |
295 | 6120 |
! ! |
6121 |
||
6122 |
!XWorkstation methodsFor:'grabbing '! |
|
6123 |
||
1344 | 6124 |
allowEvents:mode |
295 | 6125 |
%{ /* NOCONTEXT */ |
6126 |
||
6127 |
int _mode, ok = 1; |
|
6128 |
||
6129 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 6130 |
_mode = AsyncPointer; |
295 | 6131 |
else if (mode == @symbol(syncPointer)) |
1344 | 6132 |
_mode = SyncPointer; |
295 | 6133 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 6134 |
_mode = AsyncKeyboard; |
295 | 6135 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 6136 |
_mode = SyncKeyboard; |
295 | 6137 |
else if (mode == @symbol(syncBoth)) |
1344 | 6138 |
_mode = SyncBoth; |
295 | 6139 |
else if (mode == @symbol(asyncBoth)) |
1344 | 6140 |
_mode = AsyncBoth; |
295 | 6141 |
else if (mode == @symbol(replayPointer)) |
1344 | 6142 |
_mode = ReplayPointer; |
295 | 6143 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 6144 |
_mode = ReplayKeyboard; |
295 | 6145 |
else |
1344 | 6146 |
ok = 0; |
295 | 6147 |
|
6148 |
if (ok) { |
|
1344 | 6149 |
if (ISCONNECTED) { |
6150 |
BEGIN_INTERRUPTSBLOCKED |
|
6151 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
6152 |
END_INTERRUPTSBLOCKED |
|
6153 |
RETURN (self); |
|
6154 |
} |
|
295 | 6155 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
6156 |
%}. |
295 | 6157 |
self primitiveFailed |
6158 |
! |
|
6159 |
||
1344 | 6160 |
grabKeyboardIn:aWindowId |
295 | 6161 |
"grab the keyboard" |
6162 |
||
6163 |
%{ /* NOCONTEXT */ |
|
6164 |
int result, ok; |
|
6165 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6166 |
if (ISCONNECTED) { |
1344 | 6167 |
if (__isExternalAddress(aWindowId)) { |
6168 |
BEGIN_INTERRUPTSBLOCKED |
|
6169 |
result = XGrabKeyboard(myDpy, |
|
6170 |
_WindowVal(aWindowId), |
|
6171 |
True /* False */, |
|
6172 |
GrabModeAsync, |
|
6173 |
GrabModeAsync, |
|
6174 |
CurrentTime); |
|
6175 |
END_INTERRUPTSBLOCKED |
|
6176 |
ok = 0; |
|
6177 |
switch(result) { |
|
6178 |
case AlreadyGrabbed: |
|
6179 |
if (@global(ErrorPrinting) == true) { |
|
6180 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
6181 |
} |
|
6182 |
break; |
|
6183 |
case GrabNotViewable: |
|
6184 |
if (@global(ErrorPrinting) == true) { |
|
6185 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
6186 |
} |
|
6187 |
break; |
|
6188 |
case GrabInvalidTime: |
|
6189 |
if (@global(ErrorPrinting) == true) { |
|
6190 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
6191 |
} |
|
6192 |
break; |
|
6193 |
case GrabFrozen: |
|
6194 |
if (@global(ErrorPrinting) == true) { |
|
6195 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
6196 |
} |
|
6197 |
break; |
|
6198 |
default: |
|
6199 |
ok = 1; |
|
6200 |
break; |
|
6201 |
} |
|
6202 |
if (! ok) { |
|
6203 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6204 |
RETURN (false); |
|
6205 |
} |
|
6206 |
||
6207 |
RETURN ( true ); |
|
6208 |
} |
|
295 | 6209 |
} |
1183 | 6210 |
%}. |
295 | 6211 |
self primitiveFailed |
6212 |
! |
|
6213 |
||
1344 | 6214 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 6215 |
"grap the pointer - return true if ok" |
6216 |
||
6217 |
%{ /* NOCONTEXT */ |
|
6218 |
||
6219 |
int result, ok; |
|
6220 |
Window confineWin; |
|
6221 |
Cursor curs; |
|
6222 |
int pointer_mode, keyboard_mode; |
|
6223 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6224 |
if (ISCONNECTED) { |
1344 | 6225 |
if (__isExternalAddress(aWindowId)) { |
6226 |
if (__isExternalAddress(confineId)) |
|
6227 |
confineWin = _WindowVal(confineId); |
|
6228 |
else |
|
6229 |
confineWin = (Window) None; |
|
6230 |
||
6231 |
if (__isExternalAddress(aCursorId)) |
|
6232 |
curs = _CursorVal(aCursorId); |
|
6233 |
else |
|
6234 |
curs = (Cursor) None; |
|
6235 |
||
6236 |
if (pMode == @symbol(sync)) |
|
6237 |
pointer_mode = GrabModeSync; |
|
6238 |
else |
|
6239 |
pointer_mode = GrabModeAsync; |
|
6240 |
||
6241 |
if (kMode == @symbol(sync)) |
|
6242 |
keyboard_mode = GrabModeSync; |
|
6243 |
else |
|
6244 |
keyboard_mode = GrabModeAsync; |
|
6245 |
||
6246 |
BEGIN_INTERRUPTSBLOCKED |
|
6247 |
result = XGrabPointer(myDpy, |
|
6248 |
_WindowVal(aWindowId), |
|
6249 |
False, |
|
6250 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
6251 |
pointer_mode, keyboard_mode, |
|
6252 |
confineWin, |
|
6253 |
curs, |
|
6254 |
CurrentTime); |
|
6255 |
END_INTERRUPTSBLOCKED |
|
6256 |
||
6257 |
ok = 0; |
|
6258 |
switch (result) { |
|
6259 |
case AlreadyGrabbed: |
|
6260 |
if (@global(ErrorPrinting) == true) { |
|
6261 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
6262 |
} |
|
6263 |
break; |
|
6264 |
case GrabNotViewable: |
|
6265 |
if (@global(ErrorPrinting) == true) { |
|
6266 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
6267 |
} |
|
6268 |
break; |
|
6269 |
case GrabInvalidTime: |
|
6270 |
if (@global(ErrorPrinting) == true) { |
|
6271 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
6272 |
} |
|
6273 |
break; |
|
6274 |
case GrabFrozen: |
|
6275 |
if (@global(ErrorPrinting) == true) { |
|
6276 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
6277 |
} |
|
6278 |
break; |
|
6279 |
default: |
|
6280 |
ok = 1; |
|
6281 |
break; |
|
6282 |
} |
|
6283 |
||
6284 |
if (! ok) { |
|
6285 |
XUngrabPointer(myDpy, CurrentTime); |
|
6286 |
RETURN (false); |
|
6287 |
} |
|
6288 |
RETURN ( true ); |
|
6289 |
} |
|
295 | 6290 |
} |
1183 | 6291 |
%}. |
295 | 6292 |
self primitiveFailed |
6293 |
! |
|
6294 |
||
1344 | 6295 |
ungrabKeyboard |
295 | 6296 |
"release the keyboard" |
6297 |
||
6298 |
%{ /* NOCONTEXT */ |
|
6299 |
||
6300 |
if (ISCONNECTED) { |
|
1344 | 6301 |
BEGIN_INTERRUPTSBLOCKED |
6302 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
6303 |
XSync(myDpy, 0); |
|
6304 |
END_INTERRUPTSBLOCKED |
|
295 | 6305 |
} |
6306 |
%}. |
|
6307 |
activeKeyboardGrab := nil |
|
6308 |
! |
|
6309 |
||
1344 | 6310 |
ungrabPointer |
295 | 6311 |
"release the pointer" |
6312 |
||
6313 |
%{ /* NOCONTEXT */ |
|
6314 |
||
6315 |
if (ISCONNECTED) { |
|
1344 | 6316 |
BEGIN_INTERRUPTSBLOCKED |
6317 |
XUngrabPointer(myDpy, CurrentTime); |
|
6318 |
XSync(myDpy, 0); |
|
6319 |
END_INTERRUPTSBLOCKED |
|
295 | 6320 |
} |
6321 |
%}. |
|
6322 |
activePointerGrab := nil |
|
6323 |
! ! |
|
6324 |
||
6325 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
6326 |
||
1344 | 6327 |
noClipIn:aGCId |
295 | 6328 |
"disable clipping rectangle" |
6329 |
||
6330 |
%{ /* NOCONTEXT */ |
|
6331 |
||
6332 |
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
|
6333 |
GC gc; |
295 | 6334 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6335 |
if (ISCONNECTED) { |
1344 | 6336 |
if (__isExternalAddress(aGCId)) { |
6337 |
gc = _GCVal(aGCId); |
|
6338 |
gcv.clip_mask = None; |
|
6339 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
6340 |
RETURN ( self ); |
|
6341 |
} |
|
295 | 6342 |
} |
6343 |
%}. |
|
6344 |
self primitiveFailed |
|
6345 |
! |
|
6346 |
||
1344 | 6347 |
setBackground:bgColorIndex in:aGCId |
295 | 6348 |
"set background color to be drawn with" |
6349 |
||
6350 |
%{ /* NOCONTEXT */ |
|
6351 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6352 |
if (ISCONNECTED) { |
1344 | 6353 |
if (__isExternalAddress(aGCId) |
6354 |
&& __isSmallInteger(bgColorIndex)) { |
|
6355 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
|
6356 |
RETURN ( self ); |
|
6357 |
} |
|
295 | 6358 |
} |
6359 |
%}. |
|
6360 |
self primitiveFailed |
|
6361 |
! |
|
6362 |
||
1344 | 6363 |
setBitmapMask:aBitmapId in:aGCId |
295 | 6364 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
6365 |
||
6366 |
%{ /* NOCONTEXT */ |
|
6367 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6368 |
GC gc; |
295 | 6369 |
Pixmap bitmap; |
6370 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6371 |
if (ISCONNECTED) { |
1344 | 6372 |
Display *dpy = myDpy; |
6373 |
||
6374 |
if (__isExternalAddress(aGCId)) { |
|
6375 |
gc = _GCVal(aGCId); |
|
6376 |
if (__isExternalAddress(aBitmapId)) { |
|
6377 |
bitmap = _PixmapVal(aBitmapId); |
|
6378 |
XSetStipple(dpy, gc, bitmap); |
|
6379 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
6380 |
RETURN ( self ); |
|
6381 |
} |
|
6382 |
if (aBitmapId == nil) { |
|
6383 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6384 |
RETURN ( self ); |
|
6385 |
} |
|
6386 |
} |
|
295 | 6387 |
} |
6388 |
%}. |
|
6389 |
self primitiveFailed |
|
6390 |
! |
|
6391 |
||
1344 | 6392 |
setClipByChildren:aBool in:aGCId |
295 | 6393 |
"enable/disable drawing into child views" |
6394 |
||
6395 |
%{ /* NOCONTEXT */ |
|
6396 |
||
6397 |
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
|
6398 |
GC gc; |
295 | 6399 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6400 |
if (ISCONNECTED) { |
1344 | 6401 |
if (__isExternalAddress(aGCId)) { |
6402 |
gc = _GCVal(aGCId); |
|
6403 |
if (aBool == true) |
|
6404 |
gcv.subwindow_mode = ClipByChildren; |
|
6405 |
else |
|
6406 |
gcv.subwindow_mode = IncludeInferiors; |
|
6407 |
||
6408 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
6409 |
RETURN ( self ); |
|
6410 |
} |
|
295 | 6411 |
} |
6412 |
%}. |
|
6413 |
self primitiveFailed |
|
6414 |
! |
|
6415 |
||
1344 | 6416 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
295 | 6417 |
"clip to a rectangle" |
6418 |
||
6419 |
%{ /* NOCONTEXT */ |
|
6420 |
||
6421 |
XRectangle r; |
|
6422 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6423 |
if (ISCONNECTED) { |
1344 | 6424 |
if (__isExternalAddress(aGCId) |
6425 |
&& __bothSmallInteger(clipX, clipY) |
|
6426 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
6427 |
r.x = __intVal(clipX); |
|
6428 |
r.y = __intVal(clipY); |
|
6429 |
r.width = __intVal(clipWidth); |
|
6430 |
r.height = __intVal(clipHeight); |
|
6431 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
6432 |
RETURN ( self ); |
|
6433 |
} |
|
295 | 6434 |
} |
6435 |
%}. |
|
6436 |
self primitiveFailed |
|
6437 |
! |
|
6438 |
||
1344 | 6439 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 6440 |
"set line attributes" |
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(offset) |
|
6447 |
&& __isByteArray(dashList)) { |
|
6448 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
6449 |
__intVal(offset), |
|
6450 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
6451 |
__byteArraySize(dashList)); |
|
6452 |
RETURN ( self ); |
|
6453 |
} |
|
788 | 6454 |
} |
6455 |
bad: ; |
|
6456 |
%}. |
|
6457 |
" |
|
6458 |
either aGCId is invalid, |
|
6459 |
and/or dashList is not a byteArray |
|
6460 |
and/or offset is not a smallInteger |
|
6461 |
" |
|
6462 |
self primitiveFailed |
|
6463 |
! |
|
6464 |
||
1344 | 6465 |
setFont:aFontId in:aGCId |
295 | 6466 |
"set font to be drawn in" |
6467 |
||
6468 |
%{ /* NOCONTEXT */ |
|
6469 |
||
6470 |
XFontStruct *f; |
|
6471 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6472 |
if (ISCONNECTED) { |
1344 | 6473 |
if (__isExternalAddress(aFontId) |
6474 |
&& __isExternalAddress(aGCId)) { |
|
6475 |
f = (XFontStruct *) _FontVal(aFontId); |
|
6476 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
6477 |
RETURN ( self ); |
|
6478 |
} |
|
295 | 6479 |
} |
6480 |
%}. |
|
6481 |
" |
|
6482 |
aGCId and/or aFontId are invalid |
|
6483 |
" |
|
6484 |
self primitiveFailed |
|
6485 |
! |
|
6486 |
||
1344 | 6487 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 6488 |
"set foreground and background colors to be drawn with" |
6489 |
||
6490 |
%{ /* NOCONTEXT */ |
|
6491 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6492 |
GC gc; |
295 | 6493 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6494 |
if (ISCONNECTED) { |
1344 | 6495 |
Display *dpy = myDpy; |
6496 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
6497 |
&& __isExternalAddress(aGCId)) { |
|
6498 |
gc = _GCVal(aGCId); |
|
6499 |
||
6500 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
|
6501 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
6502 |
RETURN ( self ); |
|
6503 |
} |
|
295 | 6504 |
} |
6505 |
%}. |
|
6506 |
self primitiveFailed |
|
6507 |
! |
|
6508 |
||
1344 | 6509 |
setForeground:fgColorIndex in:aGCId |
295 | 6510 |
"set foreground color to be drawn with" |
6511 |
||
6512 |
%{ /* NOCONTEXT */ |
|
6513 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6514 |
if (ISCONNECTED) { |
1344 | 6515 |
if (__isExternalAddress(aGCId) |
6516 |
&& __isSmallInteger(fgColorIndex)) { |
|
6517 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
|
6518 |
RETURN ( self ); |
|
6519 |
} |
|
295 | 6520 |
} |
6521 |
%}. |
|
6522 |
self primitiveFailed |
|
6523 |
! |
|
6524 |
||
1344 | 6525 |
setFunction:aFunctionSymbol in:aGCId |
295 | 6526 |
"set alu function to be drawn with" |
6527 |
||
6528 |
%{ /* NOCONTEXT */ |
|
6529 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6530 |
GC gc; |
295 | 6531 |
int fun = -1; |
6532 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6533 |
if (ISCONNECTED) { |
1344 | 6534 |
if (__isExternalAddress(aGCId)) { |
6535 |
gc = _GCVal(aGCId); |
|
6536 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
6537 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
6538 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
6539 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
6540 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
6541 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
6542 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
6543 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
6544 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
6545 |
if (fun != -1) { |
|
6546 |
XSetFunction(myDpy, gc, fun); |
|
6547 |
RETURN ( self ); |
|
6548 |
} |
|
6549 |
} |
|
295 | 6550 |
} |
6551 |
%}. |
|
6552 |
" |
|
6553 |
either aGCId is not an integer, or an invalid symbol |
|
6554 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
6555 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
6556 |
" |
|
6557 |
self primitiveFailed |
|
6558 |
! |
|
6559 |
||
1344 | 6560 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 6561 |
"set or clear the graphics exposures flag" |
6562 |
||
6563 |
%{ /* NOCONTEXT */ |
|
6564 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6565 |
if (ISCONNECTED) { |
1344 | 6566 |
if (__isExternalAddress(aGCId)) { |
6567 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
6568 |
RETURN ( self ); |
|
6569 |
} |
|
295 | 6570 |
} |
6571 |
%} |
|
6572 |
. |
|
6573 |
self primitiveFailed |
|
6574 |
! |
|
6575 |
||
1344 | 6576 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
1455 | 6577 |
"set line attributes; |
6578 |
lineStyle must be one of #solid, #dashed or #doubleDashed; |
|
6579 |
capStyle one of: #notLast, #butt, #round or #projecting; |
|
6580 |
joinStyle one of: #miter, #bevel or #round." |
|
295 | 6581 |
|
6582 |
%{ /* NOCONTEXT */ |
|
6583 |
||
6584 |
int x_style, x_cap, x_join; |
|
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) { |
1455 | 6587 |
if (__isExternalAddress(aGCId) |
6588 |
&& __isSmallInteger(aNumber)) { |
|
6589 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
6590 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
6591 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
6592 |
else goto bad; |
|
6593 |
||
6594 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
6595 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
6596 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
6597 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
6598 |
else goto bad; |
|
6599 |
||
6600 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
6601 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
6602 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
6603 |
else goto bad; |
|
6604 |
||
6605 |
XSetLineAttributes(myDpy, |
|
6606 |
_GCVal(aGCId), __intVal(aNumber), |
|
6607 |
x_style, x_cap, x_join); |
|
6608 |
RETURN ( self ); |
|
6609 |
} |
|
295 | 6610 |
} |
6611 |
bad: ; |
|
6612 |
%}. |
|
6613 |
" |
|
6614 |
either aGCId is invalid, |
|
1455 | 6615 |
and/or lineWidth is not a smallInteger, |
295 | 6616 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
6617 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
6618 |
and/or joinStyle is none of #miter, #bevel, #round |
|
6619 |
" |
|
6620 |
self primitiveFailed |
|
6621 |
! |
|
6622 |
||
1344 | 6623 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 6624 |
"set the mask origin" |
6625 |
||
6626 |
%{ /* NOCONTEXT */ |
|
6627 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6628 |
if (ISCONNECTED) { |
1344 | 6629 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
6630 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
|
6631 |
RETURN ( self ); |
|
6632 |
} |
|
295 | 6633 |
} |
6634 |
%}. |
|
6635 |
self primitiveFailed |
|
6636 |
! |
|
6637 |
||
1344 | 6638 |
setPixmapMask:aPixmapId in:aGCId |
295 | 6639 |
"set or clear the drawing mask - a pixmap mask providing full color" |
6640 |
||
6641 |
%{ /* NOCONTEXT */ |
|
6642 |
||
6643 |
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
|
6644 |
GC gc; |
295 | 6645 |
Pixmap pixmap; |
6646 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6647 |
if (ISCONNECTED) { |
1344 | 6648 |
if (__isExternalAddress(aGCId)) { |
6649 |
gc = _GCVal(aGCId); |
|
6650 |
if (__isExternalAddress(aPixmapId)) { |
|
6651 |
pixmap = _PixmapVal(aPixmapId); |
|
6652 |
XSetTile(dpy, gc, pixmap); |
|
6653 |
XSetFillStyle(dpy, gc, FillTiled); |
|
6654 |
RETURN ( self ); |
|
6655 |
} |
|
6656 |
if (aPixmapId == nil) { |
|
6657 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6658 |
RETURN ( self ); |
|
6659 |
} |
|
6660 |
} |
|
295 | 6661 |
} |
6662 |
%}. |
|
6663 |
self primitiveFailed |
|
6664 |
! ! |
|
6665 |
||
6666 |
!XWorkstation methodsFor:'initialize / release'! |
|
6667 |
||
1344 | 6668 |
closeConnection |
295 | 6669 |
"close down the connection to the X-server" |
6670 |
||
6671 |
%{ /* NOCONTEXT */ |
|
6672 |
||
6673 |
if (ISCONNECTED) { |
|
1344 | 6674 |
Display *dpy = myDpy; |
6675 |
||
6676 |
BEGIN_INTERRUPTSBLOCKED |
|
6677 |
__INST(displayId) = nil; |
|
6678 |
XCloseDisplay(dpy); |
|
6679 |
END_INTERRUPTSBLOCKED |
|
295 | 6680 |
} |
6681 |
%} |
|
6682 |
! |
|
6683 |
||
1344 | 6684 |
initializeDefaultValues |
295 | 6685 |
buttonTranslation := ButtonTranslation. |
6686 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
6687 |
||
6688 |
self initializeModifierMappings |
|
6689 |
! |
|
6690 |
||
1344 | 6691 |
initializeEventBuffer |
295 | 6692 |
|sz| |
6693 |
||
6694 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6695 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 6696 |
%}. |
6697 |
eventBuffer isNil ifTrue:[ |
|
1344 | 6698 |
eventBuffer := ByteArray new:sz. |
295 | 6699 |
]. |
6700 |
! |
|
6701 |
||
1344 | 6702 |
initializeFor:aDisplayName |
295 | 6703 |
"initialize the receiver for a connection to an X-Server; |
6704 |
the argument, aDisplayName may be nil (for the default server from |
|
6705 |
DISPLAY-variable or command line argument) or the name of the server |
|
6706 |
as hostname:number" |
|
6707 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
6708 |
|dpyName index arguments| |
295 | 6709 |
|
6710 |
dpyName := aDisplayName. |
|
6711 |
dpyName isNil ifTrue:[ |
|
1344 | 6712 |
"look for a '-display xxx' argument" |
6713 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
6714 |
index := arguments indexOf:'-display'. |
|
6715 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
6716 |
dpyName := arguments at:index+1 |
|
6717 |
] |
|
6718 |
] |
|
295 | 6719 |
]. |
6720 |
%{ |
|
6721 |
int scr; |
|
6722 |
Display *dpy; |
|
6723 |
Visual *visual; |
|
6724 |
XVisualInfo viproto; |
|
6725 |
XVisualInfo *vip; /* retured info */ |
|
6726 |
int maxRGBDepth; |
|
6727 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6728 |
int rgbVisualID; |
|
6729 |
int nvi, i; |
|
6730 |
char *type, *nm; |
|
6731 |
int dummy; |
|
6732 |
OBJ dpyID; |
|
6733 |
||
555 | 6734 |
if (__INST(displayId) != nil) { |
1344 | 6735 |
/* |
6736 |
* already connected - you bad guy try to |
|
6737 |
* trick me manually ? |
|
6738 |
*/ |
|
6739 |
RETURN ( self ); |
|
295 | 6740 |
} |
6741 |
||
6742 |
BEGIN_INTERRUPTSBLOCKED |
|
6743 |
||
6744 |
if (__isString(dpyName)) |
|
1344 | 6745 |
nm = (char *)_stringVal(dpyName); |
295 | 6746 |
else { |
1344 | 6747 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
6748 |
nm = NULL; |
|
295 | 6749 |
} |
6750 |
dpy = XOpenDisplay(nm); |
|
6751 |
||
6752 |
if (dpy) { |
|
1344 | 6753 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 6754 |
|
6755 |
#ifdef SUPERDEBUG |
|
1344 | 6756 |
XSynchronize(dpy, 1); |
295 | 6757 |
#endif |
6758 |
||
1344 | 6759 |
XSetErrorHandler(__XErrorHandler__); |
295 | 6760 |
} |
6761 |
||
6762 |
END_INTERRUPTSBLOCKED |
|
6763 |
%}. |
|
6764 |
displayId isNil ifTrue:[ |
|
1344 | 6765 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
6766 |
^ nil |
|
295 | 6767 |
]. |
6768 |
||
6769 |
dispatching := false. |
|
6770 |
dispatchingExpose := false. |
|
6771 |
isSlow := false. |
|
6772 |
shiftDown := false. |
|
6773 |
ctrlDown := false. |
|
6774 |
metaDown := false. |
|
6775 |
altDown := false. |
|
6776 |
motionEventCompression := true. |
|
6777 |
buttonsPressed := 0. |
|
6778 |
displayName := dpyName. |
|
6779 |
||
6780 |
protocolsAtom := nil. |
|
6781 |
deleteWindowAtom := nil. |
|
6782 |
saveYourselfAtom := nil. |
|
6783 |
quitAppAtom := nil. |
|
6784 |
||
6785 |
self initializeScreenProperties. |
|
1366 | 6786 |
self initializeDeviceResourceTables. |
295 | 6787 |
|
6788 |
self initializeDefaultValues. |
|
6789 |
self initializeEventBuffer. |
|
6790 |
self initializeSpecialFlags. |
|
6791 |
self initializeKeyboardMap. |
|
6792 |
||
6793 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
6794 |
! |
|
6795 |
||
1344 | 6796 |
initializeModifierMappings |
295 | 6797 |
|map mod| |
6798 |
||
6799 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6800 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6801 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6802 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6803 |
||
6804 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6805 |
altModifierMask := metaModifierMask := nil. |
|
6806 |
||
6807 |
map := self modifierMapping. |
|
342 | 6808 |
map isNil ifTrue:[ |
1344 | 6809 |
"/ |
6810 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6811 |
"/ setup some reasonable default. If that is not sufficient, |
|
6812 |
"/ you have to change things from your display.rc file. |
|
6813 |
"/ |
|
6814 |
altModifierMask := self modifier1Mask. |
|
6815 |
metaModifierMask := self modifier2Mask. |
|
6816 |
||
6817 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6818 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6819 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6820 |
altModifiers := #(Alt_R Alt). |
|
342 | 6821 |
] ifFalse:[ |
1344 | 6822 |
altModifierMask := 0. |
6823 |
metaModifierMask := 0. |
|
6824 |
||
6825 |
mod := map at:1. |
|
6826 |
mod notNil ifTrue:[ |
|
6827 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6828 |
]. |
|
6829 |
mod := map at:3. |
|
6830 |
mod notNil ifTrue:[ |
|
6831 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6832 |
]. |
|
6833 |
mod := map at:4. |
|
6834 |
mod notNil ifTrue:[ |
|
6835 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6836 |
metaModifierMask := 1 bitShift:(4-1). |
|
6837 |
]. |
|
6838 |
mod := map at:5. |
|
6839 |
mod notNil ifTrue:[ |
|
6840 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6841 |
altModifierMask := 1 bitShift:(5-1). |
|
6842 |
] |
|
295 | 6843 |
]. |
6844 |
||
6845 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6846 |
! |
|
6847 |
||
1344 | 6848 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6849 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6850 |
|
295 | 6851 |
%{ /* NOCONTEXT */ |
6852 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6853 |
Display *dpy; |
295 | 6854 |
int scr; |
6855 |
Visual *visual; |
|
6856 |
XVisualInfo viproto; |
|
6857 |
XVisualInfo *vip; /* retured info */ |
|
6858 |
int maxRGBDepth; |
|
6859 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6860 |
int rgbVisualID; |
|
6861 |
int nvi, i; |
|
6862 |
int shapeEventBase, shapeErrorBase; |
|
6863 |
int shmEventBase, shmErrorBase; |
|
6864 |
char *type, *nm; |
|
6865 |
int dummy; |
|
6866 |
int mask, shift, nBits; |
|
6867 |
||
6868 |
if (ISCONNECTED) { |
|
1344 | 6869 |
dpy = myDpy; |
6870 |
||
6871 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
6872 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6873 |
||
6874 |
BEGIN_INTERRUPTSBLOCKED |
|
6875 |
||
6876 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6877 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6878 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6879 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6880 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6881 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6882 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6883 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6884 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6885 |
|
6886 |
#ifdef SHAPE |
|
1344 | 6887 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
6888 |
__INST(hasShapeExtension) = true; |
|
6889 |
else |
|
295 | 6890 |
#endif |
1344 | 6891 |
__INST(hasShapeExtension) = false; |
295 | 6892 |
|
6893 |
#ifdef SHM |
|
1344 | 6894 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
6895 |
__INST(hasShmExtension) = true; |
|
6896 |
else |
|
295 | 6897 |
#endif |
1344 | 6898 |
__INST(hasShmExtension) = false; |
295 | 6899 |
|
6900 |
#ifdef DPS |
|
1344 | 6901 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6902 |
__INST(hasDPSExtension) = true; |
|
6903 |
else |
|
295 | 6904 |
#endif |
1344 | 6905 |
__INST(hasDPSExtension) = false; |
295 | 6906 |
|
6907 |
#ifdef XVIDEO |
|
1344 | 6908 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6909 |
__INST(hasXVideoExtension) = true; |
|
6910 |
else |
|
295 | 6911 |
#endif |
1344 | 6912 |
__INST(hasXVideoExtension) = false; |
295 | 6913 |
|
6914 |
#ifdef MBUF |
|
1344 | 6915 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6916 |
__INST(hasMbufExtension) = true; |
|
6917 |
else |
|
295 | 6918 |
#endif |
1344 | 6919 |
__INST(hasMbufExtension) = false; |
295 | 6920 |
|
6921 |
#ifdef PEX5 |
|
1344 | 6922 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6923 |
__INST(hasPEXExtension) = true; |
|
6924 |
else |
|
295 | 6925 |
#endif |
1344 | 6926 |
__INST(hasPEXExtension) = false; |
295 | 6927 |
|
6928 |
#ifdef XIE |
|
1344 | 6929 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6930 |
__INST(hasImageExtension) = true; |
|
6931 |
else |
|
295 | 6932 |
#endif |
1344 | 6933 |
__INST(hasImageExtension) = false; |
295 | 6934 |
|
6935 |
#ifdef XI |
|
1344 | 6936 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6937 |
__INST(hasInputExtension) = true; |
|
6938 |
else |
|
295 | 6939 |
#endif |
1344 | 6940 |
__INST(hasInputExtension) = false; |
6941 |
||
6942 |
/* |
|
6943 |
* look for RGB visual |
|
6944 |
*/ |
|
6945 |
nvi = 0; |
|
6946 |
viproto.screen = scr; |
|
6947 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6948 |
maxRGBDepth = 0; |
|
6949 |
for (i = 0; i < nvi; i++) { |
|
6950 |
switch (vip[i].class) { |
|
6951 |
case TrueColor: |
|
6952 |
if (vip[i].depth > maxRGBDepth) { |
|
6953 |
maxRGBDepth = vip[i].depth; |
|
6954 |
rgbRedMask = vip[i].red_mask; |
|
6955 |
rgbGreenMask = vip[i].green_mask; |
|
6956 |
rgbBlueMask = vip[i].blue_mask; |
|
6957 |
rgbVisualID = vip[i].visualid; |
|
6958 |
} |
|
6959 |
break; |
|
6960 |
} |
|
6961 |
} |
|
6962 |
if (vip) XFree ((char *) vip); |
|
6963 |
||
6964 |
if (maxRGBDepth) { |
|
6965 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6966 |
} |
|
6967 |
||
6968 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6969 |
__INST(monitorType) = @symbol(unknown); |
|
6970 |
__INST(hasColors) = true; |
|
6971 |
__INST(hasGreyscales) = true; |
|
6972 |
switch (visual->class) { |
|
6973 |
case StaticGray: |
|
6974 |
__INST(visualType) = @symbol(StaticGray); |
|
6975 |
__INST(hasColors) = false; |
|
6976 |
__INST(monitorType) = @symbol(monochrome); |
|
6977 |
break; |
|
6978 |
case GrayScale: |
|
6979 |
__INST(visualType) = @symbol(GrayScale); |
|
6980 |
__INST(hasColors) = false; |
|
6981 |
__INST(monitorType) = @symbol(monochrome); |
|
6982 |
break; |
|
6983 |
case StaticColor: |
|
6984 |
__INST(visualType) = @symbol(StaticColor); |
|
6985 |
break; |
|
6986 |
case PseudoColor: |
|
6987 |
__INST(visualType) = @symbol(PseudoColor); |
|
6988 |
break; |
|
6989 |
case TrueColor: |
|
6990 |
__INST(visualType) = @symbol(TrueColor); |
|
6991 |
break; |
|
6992 |
case DirectColor: |
|
6993 |
__INST(visualType) = @symbol(DirectColor); |
|
6994 |
break; |
|
6995 |
} |
|
6996 |
if (DisplayCells(dpy, scr) == 2) { |
|
6997 |
__INST(hasColors) = false; |
|
6998 |
__INST(hasGreyscales) = false; |
|
6999 |
__INST(monitorType) = @symbol(monochrome); |
|
7000 |
} |
|
7001 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
7002 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
7003 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
7004 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
7005 |
switch (visual->class) { |
|
7006 |
case TrueColor: |
|
7007 |
/* extract number of bits and shift counts */ |
|
7008 |
mask = visual->red_mask; |
|
7009 |
shift = 0; |
|
7010 |
while (mask && ((mask & 1) == 0)) { |
|
7011 |
mask >>= 1; |
|
7012 |
shift++; |
|
7013 |
} |
|
7014 |
__INST(redShift) = __MKSMALLINT(shift); |
|
7015 |
nBits = 0; |
|
7016 |
while (mask) { |
|
7017 |
mask >>= 1; |
|
7018 |
nBits++; |
|
7019 |
} |
|
7020 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
7021 |
||
7022 |
mask = visual->green_mask; |
|
7023 |
shift = 0; |
|
7024 |
while (mask && ((mask & 1) == 0)) { |
|
7025 |
mask >>= 1; |
|
7026 |
shift++; |
|
7027 |
} |
|
7028 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
7029 |
nBits = 0; |
|
7030 |
while (mask) { |
|
7031 |
mask >>= 1; |
|
7032 |
nBits++; |
|
7033 |
} |
|
7034 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
7035 |
||
7036 |
mask = visual->blue_mask; |
|
7037 |
shift = 0; |
|
7038 |
while (mask && ((mask & 1) == 0)) { |
|
7039 |
mask >>= 1; |
|
7040 |
shift++; |
|
7041 |
} |
|
7042 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
7043 |
nBits = 0; |
|
7044 |
while (mask) { |
|
7045 |
mask >>= 1; |
|
7046 |
nBits++; |
|
7047 |
} |
|
7048 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
7049 |
break; |
|
7050 |
} |
|
295 | 7051 |
|
7052 |
#ifndef XA_PRIMARY |
|
1344 | 7053 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 7054 |
#else |
1344 | 7055 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 7056 |
#endif |
7057 |
#ifndef XA_SECONDARY |
|
1344 | 7058 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 7059 |
#else |
1344 | 7060 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 7061 |
#endif |
7062 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 7063 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 7064 |
#else |
1344 | 7065 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 7066 |
#endif |
7067 |
#ifndef XA_STRING |
|
1344 | 7068 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 7069 |
#else |
1344 | 7070 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 7071 |
#endif |
7072 |
#ifndef XA_LENGTH |
|
1344 | 7073 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 7074 |
#else |
1344 | 7075 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 7076 |
#endif |
1533 | 7077 |
#ifndef WM_STATE |
7078 |
__INST(wmStateAtom) = __MKATOMOBJ( XInternAtom(dpy, "WM_STATE", True) ); |
|
7079 |
#else |
|
7080 |
__INST(wmStateAtom) = __MKATOMOBJ( WM_STATE ); |
|
7081 |
#endif |
|
295 | 7082 |
|
1344 | 7083 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7084 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
7085 |
%}. |
295 | 7086 |
! |
7087 |
||
1344 | 7088 |
initializeSpecialFlags |
295 | 7089 |
"perform additional special server implementation flags" |
7090 |
||
7091 |
"/ |
|
7092 |
"/ assume we have it ... (should check) |
|
7093 |
"/ |
|
7094 |
hasSaveUnder := true. |
|
7095 |
ignoreBackingStore := false. |
|
7096 |
||
7097 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 7098 |
"/ |
7099 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
7100 |
"/ which does not correctly handle saveUnder |
|
7101 |
"/ |
|
7102 |
hasSaveUnder := false. |
|
295 | 7103 |
]. |
7104 |
! |
|
7105 |
||
1344 | 7106 |
reinitialize |
295 | 7107 |
virtualRootId := rootId := nil. |
7108 |
super reinitialize. |
|
7109 |
dispatchingExpose := nil |
|
7110 |
! ! |
|
7111 |
||
7112 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
7113 |
||
1344 | 7114 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7115 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7116 |
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
|
7117 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7118 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7119 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7120 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7121 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7122 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7123 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7124 |
|
1344 | 7125 |
altModifierMask:aSmallInteger |
341 | 7126 |
"define which key takes the role of an alt-key. |
7127 |
By default, this is X's modifier1, which is the ALT key on |
|
7128 |
most keyboards. However, there may be exceptions to this, |
|
7129 |
and the setting can be changed with: |
|
1344 | 7130 |
Display altModifierMask:(Display modifier2Mask) |
341 | 7131 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
7132 |
" |
|
7133 |
||
7134 |
altModifierMask := aSmallInteger |
|
7135 |
! |
|
7136 |
||
1344 | 7137 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7138 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7139 |
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
|
7140 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7141 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7142 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7143 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7144 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7145 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7146 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7147 |
|
1344 | 7148 |
metaModifierMask:aSmallInteger |
341 | 7149 |
"define which key takes the role of a meta key. |
7150 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
7151 |
most keyboards (if present at all). |
|
7152 |
However, there may be exceptions to this, and the setting can |
|
7153 |
be changed with: |
|
1344 | 7154 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 7155 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
7156 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
7157 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
7158 |
all the time. On those, you should disable the meta key by setting |
|
7159 |
the mask to 0. |
|
7160 |
" |
|
7161 |
||
7162 |
metaModifierMask := aSmallInteger |
|
7163 |
! |
|
7164 |
||
1344 | 7165 |
modifier1Mask |
341 | 7166 |
"return the Xlib mask bit for the 1st modifier key. |
7167 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7168 |
this could be used." |
|
7169 |
||
7170 |
%{ /* NOCONTEXT */ |
|
7171 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
7172 |
%} |
|
7173 |
! |
|
7174 |
||
1344 | 7175 |
modifier2Mask |
341 | 7176 |
"return the Xlib mask bit for the 2nd modifier key. |
7177 |
See comment in altModifierMask: / metaModifierMask: for what |
|
7178 |
this could be used." |
|
7179 |
||
7180 |
%{ /* NOCONTEXT */ |
|
7181 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
7182 |
%} |
|
7183 |
! |
|
7184 |
||
1344 | 7185 |
modifierMapping |
341 | 7186 |
"Get the Modifier Mapping. |
7187 |
We return an array of arrays of keycodes" |
|
7188 |
||
7189 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
7190 |
||
7191 |
%{ |
|
7192 |
XModifierKeymap *modmap; |
|
7193 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
7194 |
||
7195 |
if (ISCONNECTED) { |
|
1344 | 7196 |
Display *dpy = myDpy; |
7197 |
||
7198 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
7199 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7200 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
7201 |
if (modifierKeyMap != nil) { |
|
7202 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
7203 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
7204 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
7205 |
} |
|
7206 |
XFreeModifiermap(modmap); |
|
7207 |
} |
|
341 | 7208 |
} |
7209 |
%}. |
|
7210 |
||
7211 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
7212 |
||
7213 |
ret := Array new:8. |
|
7214 |
nextKey := 1. |
|
7215 |
1 to:8 do:[ :i | |
|
1344 | 7216 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
7217 |
|mod| |
|
7218 |
||
7219 |
mod := OrderedCollection new:maxKeyPerMod. |
|
7220 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
7221 |
key ~= 0 ifTrue:[ |
|
7222 |
mod add:key |
|
7223 |
]. |
|
7224 |
]. |
|
7225 |
ret at:i put:mod. |
|
7226 |
]. |
|
7227 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 7228 |
]. |
7229 |
||
7230 |
^ ret |
|
7231 |
||
7232 |
" |
|
1344 | 7233 |
Display modifierMapping |
341 | 7234 |
" |
7235 |
! |
|
7236 |
||
1344 | 7237 |
stringFromKeycode:code |
341 | 7238 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
7239 |
||
7240 |
|str| |
|
7241 |
||
7242 |
%{ |
|
7243 |
KeySym keysym; |
|
7244 |
char *keystring; |
|
7245 |
||
7246 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 7247 |
Display *dpy = myDpy; |
7248 |
||
7249 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
7250 |
(keystring = XKeysymToString(keysym)) != 0) |
|
7251 |
str = __MKSTRING(keystring); |
|
341 | 7252 |
} |
7253 |
%}. |
|
7254 |
^ str |
|
7255 |
||
7256 |
" |
|
1344 | 7257 |
Display stringFromKeycode:28 |
341 | 7258 |
" |
7259 |
! |
|
7260 |
||
1344 | 7261 |
translateKey:untranslatedKey |
295 | 7262 |
"Return the key translated via the translation table. |
7263 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
7264 |
which gets further processed in the superclasses translation method." |
|
7265 |
||
7266 |
|key| |
|
7267 |
||
7268 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 7269 |
key := RawKeysymTranslation at:key ifAbsent:key. |
7270 |
key := key asSymbol. |
|
295 | 7271 |
]. |
7272 |
^ super translateKey:key |
|
7273 |
! ! |
|
7274 |
||
7275 |
!XWorkstation methodsFor:'misc'! |
|
7276 |
||
1344 | 7277 |
beep |
295 | 7278 |
"output an audible beep or bell" |
7279 |
||
7280 |
self beep:50 |
|
7281 |
! |
|
7282 |
||
1344 | 7283 |
beep:volumeInPercent |
295 | 7284 |
"output an audible beep" |
7285 |
%{ |
|
7286 |
int volume; |
|
7287 |
||
7288 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 7289 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
7290 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
7291 |
if (volume < -100) volume = -100; |
|
7292 |
else if (volume > 100) volume = 100; |
|
7293 |
BEGIN_INTERRUPTSBLOCKED |
|
7294 |
XBell(myDpy, volume); |
|
7295 |
END_INTERRUPTSBLOCKED |
|
295 | 7296 |
} |
7297 |
%} |
|
7298 |
! |
|
7299 |
||
1344 | 7300 |
buffered |
295 | 7301 |
"buffer drawing - do not send it immediately to the display. |
374 | 7302 |
This is the default anyway. |
7303 |
See #unBuffered for additional info." |
|
295 | 7304 |
|
7305 |
%{ /* NOCONTEXT */ |
|
7306 |
||
7307 |
if (ISCONNECTED) { |
|
1344 | 7308 |
BEGIN_INTERRUPTSBLOCKED |
7309 |
XSynchronize(myDpy, 0); |
|
7310 |
END_INTERRUPTSBLOCKED |
|
295 | 7311 |
} |
7312 |
%} |
|
374 | 7313 |
" |
7314 |
Display buffered |
|
7315 |
" |
|
295 | 7316 |
! |
7317 |
||
1344 | 7318 |
flush |
295 | 7319 |
"send all buffered drawing to the display. |
7320 |
This may be required to make certain, that all previous operations |
|
7321 |
are really sent to the display before continuing. For example, |
|
7322 |
after a cursor-change with a followup long computation. |
|
374 | 7323 |
(otherwise, the cursor change request may still be in the output buffer) |
7324 |
See also #sync, which even waits until the request has been processed." |
|
295 | 7325 |
|
7326 |
%{ /* NOCONTEXT */ |
|
7327 |
||
7328 |
if (ISCONNECTED) { |
|
1344 | 7329 |
BEGIN_INTERRUPTSBLOCKED |
7330 |
XFlush(myDpy); |
|
7331 |
END_INTERRUPTSBLOCKED |
|
310 | 7332 |
} |
7333 |
%} |
|
7334 |
! |
|
7335 |
||
1344 | 7336 |
flushDpsContext:aDPSContext |
295 | 7337 |
|
7338 |
%{ /* NOCONTEXT */ |
|
7339 |
#ifdef DPS |
|
7340 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 7341 |
BEGIN_INTERRUPTSBLOCKED |
7342 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
7343 |
END_INTERRUPTSBLOCKED |
|
7344 |
RETURN ( self ); |
|
295 | 7345 |
} |
7346 |
#endif |
|
374 | 7347 |
%}. |
295 | 7348 |
self primitiveFailed |
7349 |
! |
|
7350 |
||
1344 | 7351 |
refreshKeyboardMapping:eB |
295 | 7352 |
%{ |
7353 |
XMappingEvent *ev; |
|
7354 |
||
7355 |
if (__isByteArray(eB)) { |
|
1344 | 7356 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
7357 |
XRefreshKeyboardMapping(ev); |
|
295 | 7358 |
} |
7359 |
%} |
|
7360 |
! |
|
7361 |
||
1344 | 7362 |
setInputFocusTo:aWindowId |
295 | 7363 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
7364 |
self setInputFocusTo:aWindowId revertTo:#root |
|
7365 |
! |
|
7366 |
||
1344 | 7367 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 7368 |
"set the focus to the view as defined by aWindowId. |
7369 |
Passing nil set the focus to no window and lets the display discard all |
|
7370 |
input until a new focus is set. |
|
7371 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
7372 |
passing one of #parent, #root or nil specifies that the focus should be |
|
7373 |
given to the parent view, the root view or no view." |
|
7374 |
||
7375 |
%{ /* NOCONTEXT */ |
|
7376 |
int arg; |
|
7377 |
Window focusWindow; |
|
7378 |
||
7379 |
if (ISCONNECTED) { |
|
1344 | 7380 |
if (__isExternalAddress(aWindowId)) { |
7381 |
focusWindow = _WindowVal(aWindowId); |
|
7382 |
} else { |
|
7383 |
focusWindow = None; |
|
7384 |
} |
|
7385 |
if (revertSymbol == @symbol(parent)) |
|
7386 |
arg = RevertToParent; |
|
7387 |
else if (revertSymbol == @symbol(root)) |
|
7388 |
arg = RevertToPointerRoot; |
|
7389 |
else |
|
7390 |
arg = RevertToNone; |
|
7391 |
||
7392 |
BEGIN_INTERRUPTSBLOCKED |
|
7393 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
7394 |
END_INTERRUPTSBLOCKED |
|
7395 |
RETURN ( self ); |
|
295 | 7396 |
} |
7397 |
%}. |
|
7398 |
self primitiveFailed |
|
7399 |
! |
|
7400 |
||
1344 | 7401 |
sync |
341 | 7402 |
"send all buffered drawing to the display AND wait until the display |
7403 |
has finished drawing it. |
|
7404 |
This is almost never needed, except if you are about to read previously |
|
374 | 7405 |
drawn pixels back from the display screen, or you want to wait for a beep |
7406 |
to be finished. See also #flush." |
|
341 | 7407 |
|
7408 |
%{ /* NOCONTEXT */ |
|
7409 |
||
7410 |
if (ISCONNECTED) { |
|
1344 | 7411 |
BEGIN_INTERRUPTSBLOCKED |
7412 |
XSync(myDpy, 0); |
|
7413 |
END_INTERRUPTSBLOCKED |
|
341 | 7414 |
} |
7415 |
%} |
|
7416 |
! |
|
7417 |
||
1344 | 7418 |
unBuffered |
374 | 7419 |
"make all drawing be sent immediately to the display. |
7420 |
This makes all graphics synchronous and turns off any buffering |
|
7421 |
(i.e. each individual draw-request is sent immediately without |
|
7422 |
packing multiple requests into a larger message buffer). |
|
7423 |
Be prepared, that this slows down graphics considerably. |
|
7424 |
However, it allows display errors to be handled immediately and |
|
7425 |
may be useful if you get Xdisplay errors and want to find the request |
|
7426 |
which was responsiblefor it. See also #buffered." |
|
295 | 7427 |
|
7428 |
%{ /* NOCONTEXT */ |
|
7429 |
||
7430 |
if (ISCONNECTED) { |
|
1344 | 7431 |
BEGIN_INTERRUPTSBLOCKED |
7432 |
XSynchronize(myDpy, 1); |
|
7433 |
END_INTERRUPTSBLOCKED |
|
295 | 7434 |
} |
7435 |
%} |
|
7436 |
"Display unbuffered" |
|
7437 |
! ! |
|
7438 |
||
7439 |
!XWorkstation methodsFor:'pointer queries '! |
|
7440 |
||
1344 | 7441 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7442 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7443 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7444 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7445 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7446 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7447 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7448 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7449 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7450 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7451 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7452 |
|
1344 | 7453 |
buttonStates |
295 | 7454 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7455 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7456 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7457 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 7458 |
|
7459 |
%{ /* NOCONTEXT*/ |
|
7460 |
Window w; |
|
555 | 7461 |
int screen = __intVal(__INST(screen)); |
295 | 7462 |
Window rootRet, childRet; |
7463 |
int rootX, rootY, winX, winY; |
|
7464 |
unsigned int mask; |
|
7465 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7466 |
if (ISCONNECTED) { |
1344 | 7467 |
Display *dpy = myDpy; |
7468 |
||
7469 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7470 |
#ifdef VIRTUAL_ROOT |
1344 | 7471 |
w = getRootWindow(myDpy, screen); |
295 | 7472 |
#else |
1344 | 7473 |
w = RootWindow(dpy, screen); |
295 | 7474 |
#endif |
1344 | 7475 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7476 |
&rootX, &rootY, |
|
7477 |
&winX, &winY, |
|
7478 |
&mask); |
|
7479 |
END_INTERRUPTSBLOCKED |
|
7480 |
RETURN (__MKSMALLINT(mask)); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7481 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7482 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7483 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7484 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7485 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7486 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7487 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7488 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7489 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7490 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7491 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7492 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7493 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7494 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7495 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7496 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7497 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7498 |
" |
295 | 7499 |
! |
7500 |
||
1344 | 7501 |
leftButtonStateMask |
295 | 7502 |
"return an integer for masking out the left button from a |
7503 |
buttonStates value" |
|
7504 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7505 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7506 |
|
295 | 7507 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7508 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7509 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 7510 |
! |
7511 |
||
1344 | 7512 |
middleButtonStateMask |
295 | 7513 |
"return an integer for masking out the middle button from a |
7514 |
buttonStates value" |
|
7515 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7516 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7517 |
|
295 | 7518 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7519 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7520 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 7521 |
! |
7522 |
||
1344 | 7523 |
pointerPosition |
295 | 7524 |
"return the current pointer position in root-window coordinates" |
7525 |
||
7526 |
|xpos ypos| |
|
7527 |
||
7528 |
%{ |
|
7529 |
Window w; |
|
555 | 7530 |
int screen = __intVal(__INST(screen)); |
295 | 7531 |
Window rootRet, childRet; |
7532 |
int rootX, rootY, winX, winY; |
|
7533 |
unsigned int mask; |
|
7534 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7535 |
if (ISCONNECTED) { |
1344 | 7536 |
Display *dpy = myDpy; |
7537 |
||
7538 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7539 |
#ifdef VIRTUAL_ROOT |
1344 | 7540 |
w = getRootWindow(myDpy, screen); |
295 | 7541 |
#else |
1344 | 7542 |
w = RootWindow(dpy, screen); |
295 | 7543 |
#endif |
1344 | 7544 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7545 |
&rootX, &rootY, |
|
7546 |
&winX, &winY, |
|
7547 |
&mask); |
|
7548 |
xpos = __MKSMALLINT(rootX); |
|
7549 |
ypos = __MKSMALLINT(rootY); |
|
7550 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7551 |
} |
295 | 7552 |
%} |
7553 |
. |
|
7554 |
^ xpos @ ypos |
|
7555 |
! |
|
7556 |
||
1344 | 7557 |
rightButtonStateMask |
295 | 7558 |
"return an integer for masking out the right button from a |
7559 |
buttonStates value" |
|
7560 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7561 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7562 |
|
295 | 7563 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7564 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7565 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 7566 |
! |
7567 |
||
1344 | 7568 |
rootPositionOfLastEvent |
295 | 7569 |
"return the position in root-window coordinates |
7570 |
of the last button, key or pointer event" |
|
7571 |
||
7572 |
^ eventRootX @ eventRootY |
|
7573 |
! ! |
|
7574 |
||
1556 | 7575 |
!XWorkstation methodsFor:'properties'! |
7576 |
||
7577 |
getObjectProperty:propertyID from:aWindowID |
|
7578 |
"get an object property from the server; return object or nil" |
|
7579 |
||
7580 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7581 |
type == stringAtom ifTrue:[ |
|
7582 |
^ value |
|
7583 |
]. |
|
7584 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7585 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7586 |
] |
|
7587 |
]. |
|
7588 |
^ nil |
|
7589 |
||
7590 |
"Modified: 6.4.1997 / 13:27:07 / cg" |
|
7591 |
! |
|
7592 |
||
7593 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7594 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7595 |
||
7596 |
|val typeID cls| |
|
7597 |
||
7598 |
cls := ByteArray. |
|
7599 |
%{ |
|
7600 |
Window window; |
|
7601 |
Atom property; |
|
7602 |
char *cp, *cp2; |
|
7603 |
Atom actual_type; |
|
7604 |
int actual_format,i; |
|
7605 |
unsigned long nitems, bytes_after, nread; |
|
7606 |
unsigned char *data; |
|
7607 |
int ok = 1; |
|
7608 |
# define PROP_SIZE 2048 |
|
7609 |
||
7610 |
if (ISCONNECTED) { |
|
7611 |
Display *dpy = myDpy; |
|
7612 |
||
7613 |
if (__isAtomID(propertyID)) { |
|
7614 |
property = _AtomVal(propertyID); |
|
7615 |
if (__isExternalAddress(aWindowID)) { |
|
7616 |
window = _WindowVal(aWindowID); |
|
7617 |
} else { |
|
7618 |
window = DefaultRootWindow(dpy); |
|
7619 |
} |
|
7620 |
||
7621 |
nread = 0; |
|
7622 |
cp = 0; |
|
7623 |
/* |
|
7624 |
fprintf(stderr, "getProperty: "); |
|
7625 |
*/ |
|
7626 |
do { |
|
7627 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7628 |
AnyPropertyType,&actual_type,&actual_format, |
|
7629 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7630 |
!= Success) { |
|
7631 |
ok = 0; |
|
7632 |
break; |
|
7633 |
} |
|
7634 |
typeID = __MKATOMOBJ(actual_type); |
|
7635 |
if (! cp) { |
|
7636 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7637 |
} else { |
|
7638 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7639 |
cp2 = cp + nread; |
|
7640 |
} |
|
7641 |
if (! cp) { |
|
7642 |
XFree(data); |
|
7643 |
goto fail; |
|
7644 |
} |
|
7645 |
||
7646 |
nread += nitems; |
|
7647 |
bcopy(data, cp2, nitems); |
|
7648 |
XFree(data); |
|
7649 |
/* |
|
7650 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7651 |
*/ |
|
7652 |
} while (bytes_after > 0); |
|
7653 |
/* |
|
7654 |
fprintf(stderr, "\n"); |
|
7655 |
*/ |
|
7656 |
||
7657 |
if (ok) { |
|
7658 |
if (actual_type == XA_STRING) { |
|
7659 |
cp[nread] = '\0'; |
|
7660 |
val = __MKSTRING_L(cp, nread); |
|
7661 |
} else { |
|
7662 |
val = __new(nread + OHDR_SIZE); |
|
7663 |
val->o_class = cls; |
|
7664 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
7665 |
} |
|
7666 |
} |
|
7667 |
if (cp) |
|
7668 |
free(cp); |
|
7669 |
} |
|
7670 |
} |
|
7671 |
fail: ; |
|
7672 |
%}. |
|
7673 |
typeID isNil ifTrue:[ |
|
7674 |
^ false |
|
7675 |
]. |
|
7676 |
aTwoArgBlock value:typeID value:val. |
|
7677 |
^ true |
|
7678 |
! |
|
7679 |
||
7680 |
getTextProperty:propertyID from:aWindowID |
|
7681 |
"get a text property; return string or nil" |
|
7682 |
||
7683 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7684 |
type == stringAtom ifTrue:[ |
|
7685 |
^ value |
|
7686 |
] |
|
7687 |
]. |
|
7688 |
^ nil |
|
7689 |
! |
|
7690 |
||
7691 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7692 |
"set a size property" |
|
7693 |
||
7694 |
^ self |
|
7695 |
setProperty:propertyID |
|
7696 |
type:(self atomIDOfLENGTH) |
|
7697 |
value:aNumber |
|
7698 |
for:aWindowID |
|
7699 |
||
7700 |
"Modified: 6.4.1997 / 13:27:26 / cg" |
|
7701 |
! |
|
7702 |
||
7703 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7704 |
"set a property to a smalltalk object in the XServer. |
|
7705 |
Can only be retrieved by another ST/X smalltalk" |
|
7706 |
||
7707 |
|s| |
|
7708 |
||
7709 |
(anObject isMemberOf:String) ifTrue:[ |
|
7710 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7711 |
]. |
|
7712 |
s := WriteStream on:(ByteArray new:200). |
|
7713 |
anObject storeBinaryOn:s. |
|
7714 |
^ self |
|
7715 |
setProperty:propertyID |
|
7716 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7717 |
value:(s contents) |
|
7718 |
for:aWindowID |
|
7719 |
||
7720 |
"Modified: 6.4.1997 / 13:27:57 / cg" |
|
7721 |
! |
|
7722 |
||
7723 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7724 |
"set a property in the XServer" |
|
7725 |
||
7726 |
%{ /* UNLIMITEDSTACK */ |
|
7727 |
||
7728 |
Atom prop, type; |
|
7729 |
Window window; |
|
7730 |
unsigned int value; |
|
7731 |
||
7732 |
if (__isAtomID(propertyID) |
|
7733 |
&& __isAtomID(typeID) |
|
7734 |
&& ISCONNECTED |
|
7735 |
&& (__isString(anObject) |
|
7736 |
|| __isSmallInteger(anObject) |
|
7737 |
|| __isSymbol(anObject) |
|
7738 |
|| __isByteArray(anObject) |
|
7739 |
|| __isWords(anObject))) { |
|
7740 |
||
7741 |
Display *dpy = myDpy; |
|
7742 |
||
7743 |
prop = _AtomVal(propertyID); |
|
7744 |
type = _AtomVal(typeID); |
|
7745 |
||
7746 |
if (__isExternalAddress(aWindowID)) { |
|
7747 |
window = _WindowVal(aWindowID); |
|
7748 |
} else { |
|
7749 |
window = DefaultRootWindow(dpy); |
|
7750 |
} |
|
7751 |
if (__isSmallInteger(anObject)) { |
|
7752 |
value = __intVal(anObject); |
|
7753 |
XChangeProperty(dpy, window, prop, type, 32, |
|
7754 |
PropModeReplace, |
|
7755 |
(unsigned char *)(&value), sizeof(unsigned int)); |
|
7756 |
} else { |
|
7757 |
if (__isByteArray(anObject)) { |
|
7758 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7759 |
PropModeReplace, |
|
7760 |
__ByteArrayInstPtr(anObject)->ba_element, |
|
7761 |
__byteArraySize(anObject)); |
|
7762 |
} else { |
|
7763 |
/* string or symbol or wordArray-like (16bit-string) object */ |
|
7764 |
type = _AtomVal(typeID); |
|
7765 |
if (__isWords(__qClass(anObject))) { |
|
7766 |
XChangeProperty(dpy, window, prop, type, 16, |
|
7767 |
PropModeReplace, |
|
7768 |
__stringVal(anObject), |
|
7769 |
__wordArraySize(anObject)); |
|
7770 |
} else { |
|
7771 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7772 |
PropModeReplace, |
|
7773 |
__stringVal(anObject), |
|
1557
c37fd33dc7d8
don use strlen when setting a string prop;
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
7774 |
__stringSize(anObject)); |
1556 | 7775 |
} |
7776 |
} |
|
7777 |
} |
|
7778 |
RETURN (true); |
|
7779 |
} |
|
7780 |
%}. |
|
7781 |
^ false |
|
7782 |
! |
|
7783 |
||
7784 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7785 |
"set a property to a stringValue in the XServer" |
|
7786 |
||
7787 |
^ self |
|
7788 |
setProperty:propertyID |
|
7789 |
type:(self atomIDOfSTRING) |
|
7790 |
value:aString |
|
7791 |
for:aWindowID |
|
7792 |
||
7793 |
"Modified: 6.4.1997 / 13:26:32 / cg" |
|
7794 |
! ! |
|
7795 |
||
295 | 7796 |
!XWorkstation methodsFor:'resources'! |
7797 |
||
1344 | 7798 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7799 |
"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
|
7800 |
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
|
7801 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7802 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7803 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7804 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7805 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7806 |
Display atomIDOf:'FULL_NAME' |
1535 | 7807 |
Display atomIDOf:'DndProtocol' |
7808 |
Display atomIDOf:'DndSelection' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7809 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7810 |
|
1535 | 7811 |
"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
|
7812 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7813 |
|
1344 | 7814 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7815 |
"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
|
7816 |
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
|
7817 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7818 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7819 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7820 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7821 |
if (ISCONNECTED) { |
1344 | 7822 |
if (__isString(aStringOrSymbol) |
7823 |
|| __isSymbol(aStringOrSymbol)) { |
|
7824 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
7825 |
(create == true) ? False : True); |
|
7826 |
if (prop == None) { |
|
7827 |
RETURN (nil); |
|
7828 |
} |
|
7829 |
RETURN ( __MKATOMOBJ(prop) ); |
|
7830 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7831 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7832 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7833 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7834 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7835 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7836 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7837 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7838 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7839 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7840 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7841 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7842 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7843 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7844 |
|
1344 | 7845 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7846 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7847 |
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
|
7848 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7849 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7850 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7851 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7852 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7853 |
|
1344 | 7854 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7855 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7856 |
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
|
7857 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7858 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7859 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7860 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7861 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7862 |
|
1344 | 7863 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7864 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7865 |
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
|
7866 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7867 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7868 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7869 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7870 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7871 |
|
1344 | 7872 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7873 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7874 |
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
|
7875 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7876 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7877 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7878 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7879 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7880 |
|
1344 | 7881 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7882 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7883 |
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
|
7884 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7885 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7886 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7887 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7888 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7889 |
|
1344 | 7890 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7891 |
"given an AtomID, return its name. |
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 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7895 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7896 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7897 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7898 |
if (ISCONNECTED) { |
1344 | 7899 |
if (__isAtomID(anAtomID)) { |
7900 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
7901 |
if (name == 0) { |
|
7902 |
RETURN (nil); |
|
7903 |
} |
|
7904 |
str = __MKSTRING(name); |
|
7905 |
XFree(name); |
|
7906 |
RETURN ( str ); |
|
7907 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7908 |
} |
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 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7911 |
^ nil |
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 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7914 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7915 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7916 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7917 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7918 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7919 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7920 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7921 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7922 |
" |
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 |
|
1344 | 7925 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7926 |
"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
|
7927 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7928 |
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
|
7929 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7930 |
Notice: |
1344 | 7931 |
we do not plan to use X's resources for ST/X's defaults, |
7932 |
styles or resources. This would make porting of applications |
|
7933 |
to different platforms much more difficult (Windows has no resource |
|
7934 |
database). If you stay within ST/X's resource files, these can be |
|
7935 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7936 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7937 |
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
|
7938 |
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
|
7939 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7940 |
|
295 | 7941 |
%{ |
7942 |
char *rslt; |
|
7943 |
||
7944 |
if ((__isString(name) || __isSymbol(name)) |
|
7945 |
&& (__isString(cls) || __isSymbol(cls)) |
|
7946 |
&& ISCONNECTED) { |
|
1344 | 7947 |
BEGIN_INTERRUPTSBLOCKED |
7948 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
7949 |
(char *)_stringVal(name)); |
|
7950 |
END_INTERRUPTSBLOCKED |
|
7951 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7952 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7953 |
%}. |
295 | 7954 |
self primitiveFailed. |
7955 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7956 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7957 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 7958 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7959 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7960 |
|
1344 | 7961 |
Display getResource:'Beep' class:'OpenWindows' |
487
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 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 7964 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7965 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7966 |
|
1344 | 7967 |
Display getResource:'beNiceToColormap' class:'any' |
7968 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7969 |
" |
295 | 7970 |
! ! |
7971 |
||
7972 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
7973 |
||
1462
f8b2909deb3c
renamed getBitsFrom to getBitsFromId
Claus Gittinger <cg@exept.de>
parents:
1455
diff
changeset
|
7974 |
getBitsFromId:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 7975 |
"get bits from a drawable into the imageBits. The storage for the bits |
7976 |
must be big enough for the data to fit. If ok, returns an array with some |
|
7977 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
7978 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
7979 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
7980 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7981 |
|rawInfo info| |
295 | 7982 |
|
7983 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 7984 |
self primitiveFailed. |
7985 |
^ nil |
|
295 | 7986 |
]. |
7987 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7988 |
rawInfo := Array new:8. |
1344 | 7989 |
"1 -> bit order" |
7990 |
"2 -> depth" |
|
7991 |
"3 -> bytes_per_line" |
|
7992 |
"4 -> byte_order" |
|
7993 |
"5 -> format" |
|
7994 |
"6 -> bitmap_unit" |
|
7995 |
"7 -> bitmap_pad" |
|
7996 |
"8 -> bits_per_pixel" |
|
295 | 7997 |
|
7998 |
"/ had to extract the getPixel call into a separate method, to specify |
|
7999 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
8000 |
"/ of temporary stack space |
|
8001 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
8002 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 8003 |
info := IdentityDictionary new. |
8004 |
info at:#bitOrder put:(rawInfo at:1). |
|
8005 |
info at:#depth put:(rawInfo at:2). |
|
8006 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
8007 |
info at:#byteOrder put:(rawInfo at:4). |
|
8008 |
info at:#format put:(rawInfo at:5). |
|
8009 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
8010 |
info at:#bitmapPad put:(rawInfo at:7). |
|
8011 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
8012 |
^ info |
|
295 | 8013 |
]. |
8014 |
" |
|
8015 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
8016 |
or is too small to hold the bits |
|
8017 |
" |
|
8018 |
^ self primitiveFailed |
|
8019 |
! |
|
8020 |
||
1344 | 8021 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
8022 |
"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
|
8023 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 8024 |
|
8025 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
8026 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8027 |
Window win; |
295 | 8028 |
XImage *img; |
8029 |
int ret; |
|
8030 |
int xpos, ypos; |
|
8031 |
||
1209 | 8032 |
if (ISCONNECTED |
8033 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 8034 |
win = _WindowVal(aDrawableId); |
8035 |
xpos = __intVal(x); |
|
8036 |
ypos = __intVal(y); |
|
8037 |
if ((xpos < 0) || (ypos < 0)) { |
|
8038 |
RETURN ( __MKSMALLINT(0) ); |
|
8039 |
} |
|
8040 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
8041 |
if (img != 0) { |
|
8042 |
ret = XGetPixel(img, 0, 0); |
|
8043 |
XDestroyImage(img); |
|
8044 |
RETURN ( __MKSMALLINT(ret) ); |
|
8045 |
} |
|
295 | 8046 |
} |
8047 |
%}. |
|
8048 |
^ nil |
|
8049 |
! |
|
8050 |
||
1344 | 8051 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 8052 |
"since XGetImage may allocate huge amount of stack space |
8053 |
(some implementations use alloca), this must run with unlimited stack." |
|
8054 |
||
8055 |
%{ /* UNLIMITEDSTACK */ |
|
8056 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
8057 |
Window win; |
295 | 8058 |
XImage *image = (XImage *)0; |
8059 |
int pad, bytes_per_line, numBytes; |
|
8060 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8061 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8062 |
&& __isExternalAddress(aDrawableId) |
295 | 8063 |
&& __bothSmallInteger(srcx, srcy) |
8064 |
&& __bothSmallInteger(w, h) |
|
8065 |
&& __isArray(info) |
|
8066 |
&& __isByteArray(imageBits)) { |
|
1344 | 8067 |
Display *dpy = myDpy; |
8068 |
||
8069 |
win = _WindowVal(aDrawableId); |
|
8070 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
|
8071 |
__intVal(w), __intVal(h), |
|
8072 |
(unsigned)AllPlanes, ZPixmap); |
|
8073 |
||
8074 |
if (! image) { |
|
8075 |
RETURN ( false ); |
|
8076 |
} |
|
8077 |
||
8078 |
pad = image->bitmap_pad; |
|
295 | 8079 |
#ifdef SUPERDEBUG |
1344 | 8080 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 8081 |
#endif |
1344 | 8082 |
switch (image->depth) { |
8083 |
case 1: |
|
8084 |
case 2: |
|
8085 |
case 4: |
|
8086 |
case 8: |
|
8087 |
case 16: |
|
8088 |
case 24: |
|
8089 |
case 32: |
|
8090 |
numBytes = image->bytes_per_line * image->height; |
|
8091 |
break; |
|
8092 |
default: |
|
8093 |
/* unsupported depth ? */ |
|
8094 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
8095 |
numBytes = image->bytes_per_line * image->height; |
|
8096 |
break; |
|
8097 |
} |
|
295 | 8098 |
|
8099 |
#ifdef SUPERDEBUG |
|
1344 | 8100 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 8101 |
#endif |
8102 |
||
1344 | 8103 |
if (numBytes > __byteArraySize(imageBits)) { |
8104 |
/* imageBits too small */ |
|
8105 |
printf("provided byteArray too small\n"); |
|
8106 |
goto fail; |
|
8107 |
} |
|
8108 |
if (image->bitmap_bit_order == MSBFirst) |
|
8109 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
8110 |
else |
|
8111 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
8112 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
8113 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
8114 |
if (image->byte_order == MSBFirst) |
|
8115 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
8116 |
else |
|
8117 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
8118 |
if (image->format == XYBitmap) |
|
8119 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
8120 |
else if (image->format == XYPixmap) |
|
8121 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
8122 |
else if (image->format == ZPixmap) |
|
8123 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
8124 |
|
1344 | 8125 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
8126 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
8127 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
8128 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
8129 |
XDestroyImage(image); |
|
8130 |
RETURN ( true ); |
|
295 | 8131 |
} |
8132 |
fail: |
|
8133 |
if (image) { |
|
1344 | 8134 |
XDestroyImage(image); |
295 | 8135 |
} |
8136 |
%}. |
|
8137 |
^ false |
|
8138 |
! ! |
|
8139 |
||
8140 |
!XWorkstation methodsFor:'selections'! |
|
8141 |
||
1344 | 8142 |
getSelectionFor:drawableId |
295 | 8143 |
"get the object selection - either immediate, or asynchronous. |
8144 |
Returns nil, if async request is on its way" |
|
8145 |
||
8146 |
|selProp sel| |
|
8147 |
||
8148 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8149 |
"no primary selection - use cut buffer" |
8150 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
8151 |
^ sel |
|
295 | 8152 |
]. |
8153 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
8154 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
8155 |
^ nil |
|
8156 |
! |
|
8157 |
||
1344 | 8158 |
getSelectionOwnerOf:selectionAtomID |
295 | 8159 |
"get the owner of a selection" |
8160 |
||
8161 |
%{ /* NOCONTEXT */ |
|
8162 |
Atom selection; |
|
8163 |
Window window; |
|
8164 |
||
8165 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 8166 |
Display *dpy = myDpy; |
8167 |
||
8168 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
8169 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
295 | 8170 |
} |
8171 |
%}. |
|
8172 |
self primitiveFailed. |
|
8173 |
^ nil |
|
8174 |
! |
|
8175 |
||
1344 | 8176 |
getTextSelectionFor:drawableId |
295 | 8177 |
"get the text selection - either immediate, or asynchronous. |
8178 |
Returns nil, if async request is on its way" |
|
8179 |
||
8180 |
|selProp sel| |
|
8181 |
||
8182 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 8183 |
"no primary selection - use cut buffer" |
8184 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
8185 |
^ sel |
|
295 | 8186 |
]. |
8187 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
8188 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
8189 |
^ nil |
|
8190 |
! |
|
8191 |
||
1344 | 8192 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 8193 |
"ask the server to send us the selection - the view with ID aWindowID |
8194 |
will later receive a SelectionNotify event for it." |
|
8195 |
||
8196 |
^ self requestSelection:selectionID |
|
1344 | 8197 |
property:propertyID |
8198 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
8199 |
for:aWindowId |
|
8200 |
! |
|
8201 |
||
8202 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 8203 |
"ask the server to send us the selection - the view with id aWindowID |
8204 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
8205 |
with the selections value)." |
|
8206 |
||
8207 |
%{ /* NOCONTEXT */ |
|
8208 |
Atom sel_prop; |
|
8209 |
char *cp; |
|
8210 |
||
8211 |
if (__isExternalAddress(aWindowId) |
|
8212 |
&& ISCONNECTED |
|
8213 |
&& __isSmallInteger(typeID) |
|
8214 |
&& __isAtomID(selectionID)) { |
|
1344 | 8215 |
Display *dpy = myDpy; |
8216 |
||
8217 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
8218 |
/* |
|
8219 |
* no owner of primary selection |
|
8220 |
*/ |
|
8221 |
RETURN (false); |
|
8222 |
} |
|
8223 |
/* |
|
8224 |
* PRIMARY selection |
|
8225 |
*/ |
|
8226 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
8227 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
8228 |
RETURN (true); |
|
295 | 8229 |
} |
8230 |
%}. |
|
8231 |
self primitiveFailed. |
|
8232 |
^ false |
|
8233 |
||
8234 |
" |
|
8235 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 8236 |
property:(Display atomIDOf:'VT_SELECTION') |
8237 |
for:0 |
|
295 | 8238 |
" |
8239 |
! |
|
8240 |
||
1344 | 8241 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 8242 |
"ask the server to send us the selection - the view with ID aWindowID |
8243 |
will later receive a SelectionNotify event for it." |
|
8244 |
||
8245 |
^ self requestSelection:selectionID |
|
1344 | 8246 |
property:propertyID |
8247 |
type:stringAtom |
|
8248 |
for:aWindowId |
|
8249 |
! |
|
8250 |
||
8251 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8252 |
"send aString back from a SelectionRequest" |
8253 |
||
8254 |
self |
|
1344 | 8255 |
sendSelection:something |
8256 |
selection:primaryAtom |
|
8257 |
property:propertyID |
|
8258 |
target:targetID |
|
8259 |
from:windowID |
|
8260 |
to:requestorID |
|
8261 |
! |
|
8262 |
||
8263 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8264 |
"send aString back from a SelectionRequest" |
8265 |
||
8266 |
self |
|
1344 | 8267 |
setProperty:propertyID |
8268 |
type:targetID |
|
8269 |
value:something |
|
8270 |
for:requestorID. |
|
295 | 8271 |
self |
1344 | 8272 |
sendSelectionNotifySelection:selectionID |
8273 |
property:propertyID |
|
8274 |
target:targetID |
|
8275 |
from:requestorID |
|
8276 |
to:requestorID. |
|
8277 |
! |
|
8278 |
||
8279 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 8280 |
"send a selectionNotify back from a SelectionRequest" |
8281 |
||
8282 |
%{ /* NOCONTEXT */ |
|
8283 |
||
8284 |
if (__isAtomID(propertyID) |
|
8285 |
&& __isExternalAddress(requestorID) |
|
8286 |
&& ISCONNECTED |
|
8287 |
&& __isAtomID(targetID) |
|
8288 |
&& __isAtomID(selectionID)) { |
|
1344 | 8289 |
Display *dpy = myDpy; |
8290 |
XEvent ev; |
|
8291 |
Window requestor = _WindowVal(requestorID); |
|
8292 |
Atom property = _AtomVal(propertyID); |
|
8293 |
Atom target = _AtomVal(targetID); |
|
8294 |
Atom selection = _AtomVal(selectionID); |
|
8295 |
Status result; |
|
8296 |
||
8297 |
ev.xselection.type = SelectionNotify; |
|
8298 |
ev.xselection.selection = selection; |
|
8299 |
ev.xselection.target = target; |
|
8300 |
if (__isExternalAddress(windowID)) |
|
8301 |
ev.xselection.requestor = _WindowVal(windowID); |
|
8302 |
else |
|
8303 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
8304 |
ev.xselection.time = CurrentTime; |
|
8305 |
if (property == None) |
|
8306 |
ev.xselection.property = target; |
|
8307 |
else |
|
8308 |
ev.xselection.property = property; |
|
8309 |
||
8310 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
8311 |
ev.xselection.selection, |
|
8312 |
ev.xselection.property, |
|
8313 |
ev.xselection.target, |
|
8314 |
ev.xselection.requestor, |
|
8315 |
requestor)); |
|
8316 |
||
8317 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
8318 |
if ((result == BadValue) || (result == BadWindow)) { |
|
8319 |
DPRINTF(("bad status\n")); |
|
8320 |
RETURN (false); |
|
8321 |
} |
|
8322 |
RETURN (true) |
|
382 | 8323 |
} |
8324 |
%}. |
|
8325 |
self primitiveFailed. |
|
8326 |
^ false |
|
295 | 8327 |
! |
8328 |
||
1344 | 8329 |
setSelection:anObject owner:aWindowId |
295 | 8330 |
"set the object selection, and make aWindowId be the owner. |
8331 |
This can be used by other Smalltalk(X) applications only." |
|
8332 |
||
8333 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8334 |
^ false |
295 | 8335 |
]. |
8336 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
8337 |
^ true |
|
8338 |
! |
|
8339 |
||
1344 | 8340 |
setSelectionOwner:aWindowId of:selectionID |
295 | 8341 |
"set the owner of a selection; return false if failed" |
8342 |
||
8343 |
%{ /* NOCONTEXT */ |
|
8344 |
Window win; |
|
8345 |
||
8346 |
if (__isExternalAddress(aWindowId) |
|
8347 |
&& __isAtomID(selectionID) |
|
8348 |
&& ISCONNECTED) { |
|
1344 | 8349 |
Display *dpy = myDpy; |
8350 |
||
8351 |
win = _WindowVal(aWindowId); |
|
8352 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
8353 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
8354 |
RETURN (false); |
|
8355 |
} |
|
8356 |
RETURN (true); |
|
295 | 8357 |
} |
8358 |
%} |
|
8359 |
. |
|
8360 |
self primitiveFailed. |
|
8361 |
^ nil |
|
8362 |
! |
|
8363 |
||
1344 | 8364 |
setTextSelection:aString owner:aWindowId |
295 | 8365 |
"set the text selection, and make aWindowId be the owner. |
8366 |
This can be used by any other X application." |
|
8367 |
||
8368 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 8369 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 8370 |
]. |
8371 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8372 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8373 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 8374 |
! ! |
8375 |
||
8376 |
!XWorkstation methodsFor:'window stuff'! |
|
8377 |
||
1344 | 8378 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 8379 |
"clear a rectangular area to viewbackground" |
8380 |
||
8381 |
%{ /* NOCONTEXT */ |
|
8382 |
||
8383 |
int w, h; |
|
8384 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8385 |
if (ISCONNECTED) { |
1344 | 8386 |
if (__isExternalAddress(aWindowId) |
8387 |
&& __bothSmallInteger(x, y) |
|
8388 |
&& __bothSmallInteger(width, height)) { |
|
8389 |
w = __intVal(width); |
|
8390 |
h = __intVal(height); |
|
8391 |
/* |
|
8392 |
* need this check here: some servers simply dump core with bad args |
|
8393 |
*/ |
|
8394 |
if ((w >= 0) && (h >= 0)) { |
|
8395 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
|
8396 |
} |
|
8397 |
RETURN ( self ); |
|
8398 |
} |
|
295 | 8399 |
} |
8400 |
%} |
|
8401 |
. |
|
8402 |
self primitiveFailed |
|
8403 |
! |
|
8404 |
||
1344 | 8405 |
clearWindow:aWindowId |
295 | 8406 |
"clear a window to viewbackground" |
8407 |
||
8408 |
%{ /* NOCONTEXT */ |
|
8409 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8410 |
if (ISCONNECTED) { |
1344 | 8411 |
if (__isExternalAddress(aWindowId)) { |
8412 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
8413 |
RETURN ( self ); |
|
8414 |
} |
|
295 | 8415 |
} |
8416 |
%} |
|
8417 |
. |
|
8418 |
self primitiveFailed |
|
8419 |
! |
|
8420 |
||
1344 | 8421 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 8422 |
"configure stacking operation of aWindowId w.r.t siblingId" |
8423 |
||
8424 |
%{ /* NOCONTEXT */ |
|
8425 |
||
8426 |
XWindowChanges chg; |
|
8427 |
int mask = CWSibling | CWStackMode; |
|
8428 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8429 |
if (ISCONNECTED) { |
1344 | 8430 |
if (__isExternalAddress(aWindowId) |
8431 |
&& __isExternalAddress(siblingId)) { |
|
8432 |
if (modeSymbol == @symbol(above)) { |
|
8433 |
chg.stack_mode = Above; |
|
8434 |
} else if (modeSymbol == @symbol(below)) { |
|
8435 |
chg.stack_mode = Below; |
|
8436 |
} else if (modeSymbol == @symbol(topIf)) { |
|
8437 |
chg.stack_mode = TopIf; |
|
8438 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
8439 |
chg.stack_mode = BottomIf; |
|
8440 |
} else if (modeSymbol == @symbol(opposite)) { |
|
8441 |
chg.stack_mode = Opposite; |
|
8442 |
} else { |
|
8443 |
mask = CWSibling; |
|
8444 |
} |
|
8445 |
||
8446 |
chg.sibling = _WindowVal(siblingId); |
|
8447 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
8448 |
mask, &chg); |
|
8449 |
RETURN ( self ); |
|
8450 |
} |
|
295 | 8451 |
} |
8452 |
bad: ; |
|
8453 |
%} |
|
8454 |
. |
|
8455 |
self primitiveFailed |
|
8456 |
! |
|
8457 |
||
1344 | 8458 |
lowerWindow:aWindowId |
295 | 8459 |
"bring a window to back" |
8460 |
||
8461 |
%{ /* NOCONTEXT */ |
|
8462 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8463 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8464 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8465 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
8466 |
RETURN ( self ); |
|
295 | 8467 |
} |
8468 |
%} |
|
8469 |
. |
|
8470 |
self primitiveFailed |
|
8471 |
! |
|
8472 |
||
1344 | 8473 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 8474 |
"make a window visible - either as icon or as a real view - needed for restart" |
8475 |
||
8476 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
8477 |
||
8478 |
aBoolean ifTrue:[ |
|
1344 | 8479 |
wicon := aView icon. |
8480 |
wicon notNil ifTrue:[ |
|
8481 |
wiconId := wicon id |
|
8482 |
]. |
|
8483 |
wiconView := aView iconView. |
|
8484 |
wiconView notNil ifTrue:[ |
|
8485 |
wiconViewId := wiconView id |
|
8486 |
]. |
|
8487 |
wlabel := aView label. |
|
295 | 8488 |
]. |
8489 |
%{ |
|
8490 |
||
8491 |
XWMHints wmhints; |
|
8492 |
XSizeHints szhints; |
|
8493 |
Window win; |
|
8494 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8495 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8496 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8497 |
Display *dpy = myDpy; |
8498 |
||
8499 |
win = _WindowVal(aWindowId); |
|
8500 |
||
8501 |
szhints.flags = 0; |
|
8502 |
if (__bothSmallInteger(xPos, yPos)) { |
|
8503 |
szhints.x = __intVal(xPos); |
|
8504 |
szhints.y = __intVal(yPos); |
|
8505 |
szhints.flags |= USPosition; |
|
8506 |
} |
|
8507 |
if (__bothSmallInteger(w, h)) { |
|
8508 |
szhints.width = __intVal(w); |
|
8509 |
szhints.height = __intVal(h); |
|
8510 |
szhints.flags |= USSize; |
|
8511 |
} |
|
8512 |
||
8513 |
if (aBoolean == true) { |
|
8514 |
char *windowName; |
|
8515 |
Pixmap iconBitmap = (Pixmap)0; |
|
8516 |
Window iconWindow; |
|
8517 |
||
8518 |
if (__isExternalAddress(wiconId)) |
|
8519 |
iconBitmap = _PixmapVal(wiconId); |
|
8520 |
else |
|
8521 |
iconBitmap = (Pixmap)0; |
|
8522 |
||
8523 |
if (__isExternalAddress(wiconViewId)) |
|
8524 |
iconWindow = _WindowVal(wiconViewId); |
|
8525 |
else |
|
8526 |
iconWindow = (Window)0; |
|
8527 |
||
8528 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
8529 |
windowName = (char *)_stringVal(wlabel); |
|
8530 |
else |
|
8531 |
windowName = ""; |
|
8532 |
||
8533 |
if (iconBitmap || windowName) { |
|
8534 |
XSetStandardProperties(dpy, win, |
|
8535 |
windowName, windowName, |
|
8536 |
iconBitmap, |
|
8537 |
0, 0, &szhints); |
|
8538 |
} |
|
8539 |
||
8540 |
wmhints.flags = 0; |
|
8541 |
if (iconBitmap) { |
|
8542 |
wmhints.flags |= IconPixmapHint; |
|
8543 |
wmhints.icon_pixmap = iconBitmap; |
|
8544 |
} |
|
8545 |
if (iconWindow) { |
|
8546 |
wmhints.flags |= IconWindowHint; |
|
8547 |
wmhints.icon_window = iconWindow; |
|
8548 |
} |
|
8549 |
||
8550 |
wmhints.initial_state = IconicState; |
|
8551 |
wmhints.flags |= StateHint; |
|
8552 |
XSetWMHints(dpy, win, &wmhints); |
|
8553 |
} |
|
8554 |
||
8555 |
if (szhints.flags) { |
|
8556 |
XSetNormalHints(dpy, win, &szhints); |
|
8557 |
} |
|
8558 |
||
8559 |
XMapWindow(dpy, win); |
|
8560 |
RETURN ( self ); |
|
295 | 8561 |
} |
8562 |
%} |
|
8563 |
. |
|
8564 |
self primitiveFailed |
|
8565 |
! |
|
8566 |
||
1344 | 8567 |
mapWindow:aWindowId |
295 | 8568 |
"make a window visible" |
8569 |
||
8570 |
%{ /* NOCONTEXT */ |
|
8571 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8572 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8573 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8574 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
8575 |
RETURN ( self ); |
|
295 | 8576 |
} |
8577 |
%} |
|
8578 |
. |
|
8579 |
self primitiveFailed |
|
8580 |
! |
|
8581 |
||
1344 | 8582 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 8583 |
"move and resize a window" |
8584 |
||
8585 |
%{ /* NOCONTEXT */ |
|
8586 |
||
8587 |
int newWidth, newHeight; |
|
8588 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8589 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8590 |
&& __isExternalAddress(aWindowId) |
295 | 8591 |
&& __bothSmallInteger(w, h) |
8592 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 8593 |
newWidth = __intVal(w); |
8594 |
newHeight = __intVal(h); |
|
8595 |
if (newWidth < 1) newWidth = 1; |
|
8596 |
if (newHeight < 1) newHeight = 1; |
|
8597 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
8598 |
__intVal(x), __intVal(y), |
|
8599 |
newWidth, newHeight); |
|
8600 |
RETURN ( self ); |
|
295 | 8601 |
} |
8602 |
%} |
|
8603 |
. |
|
8604 |
self primitiveFailed |
|
8605 |
! |
|
8606 |
||
1344 | 8607 |
moveWindow:aWindowId x:x y:y |
295 | 8608 |
"move a window" |
8609 |
||
8610 |
%{ /* NOCONTEXT */ |
|
8611 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8612 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8613 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1344 | 8614 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
8615 |
RETURN ( self ); |
|
295 | 8616 |
} |
8617 |
%} |
|
8618 |
. |
|
8619 |
self primitiveFailed |
|
8620 |
! |
|
8621 |
||
1344 | 8622 |
raiseWindow:aWindowId |
295 | 8623 |
"bring a window to front" |
8624 |
||
8625 |
%{ /* NOCONTEXT */ |
|
8626 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8627 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8628 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8629 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
8630 |
RETURN ( self ); |
|
295 | 8631 |
} |
8632 |
%} |
|
8633 |
. |
|
8634 |
self primitiveFailed |
|
8635 |
! |
|
8636 |
||
1344 | 8637 |
resizeWindow:aWindowId width:w height:h |
295 | 8638 |
"resize a window" |
8639 |
||
8640 |
%{ /* NOCONTEXT */ |
|
8641 |
||
8642 |
int newWidth, newHeight; |
|
8643 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8644 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8645 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 8646 |
newWidth = __intVal(w); |
8647 |
newHeight = __intVal(h); |
|
8648 |
if (newWidth < 1) newWidth = 1; |
|
8649 |
if (newHeight < 1) newHeight = 1; |
|
8650 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
8651 |
RETURN ( self ); |
|
295 | 8652 |
} |
8653 |
%} |
|
8654 |
. |
|
8655 |
self primitiveFailed |
|
8656 |
! |
|
8657 |
||
1344 | 8658 |
setBackingStore:how in:aWindowId |
295 | 8659 |
"turn on/off backing-store for a window" |
8660 |
||
8661 |
%{ /* NOCONTEXT */ |
|
8662 |
||
8663 |
XSetWindowAttributes wa; |
|
8664 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8665 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8666 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8667 |
if (__INST(ignoreBackingStore) != true) { |
8668 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
8669 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
8670 |
else if (how == true) wa.backing_store = Always; |
|
8671 |
else wa.backing_store = 0; |
|
8672 |
BEGIN_INTERRUPTSBLOCKED |
|
8673 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
8674 |
END_INTERRUPTSBLOCKED |
|
8675 |
} |
|
8676 |
RETURN ( self ); |
|
295 | 8677 |
} |
8678 |
%}. |
|
8679 |
self primitiveFailed |
|
8680 |
! |
|
8681 |
||
1344 | 8682 |
setBitGravity:how in:aWindowId |
295 | 8683 |
"set bit gravity for a window" |
8684 |
||
8685 |
%{ /* NOCONTEXT */ |
|
8686 |
||
8687 |
XSetWindowAttributes wa; |
|
8688 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8689 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8690 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8691 |
if (how == @symbol(NorthWest)) { |
8692 |
wa.bit_gravity = NorthWestGravity; |
|
8693 |
} else if (how == @symbol(NorthEast)) { |
|
8694 |
wa.bit_gravity = NorthEastGravity; |
|
8695 |
} else if (how == @symbol(SouthWest)) { |
|
8696 |
wa.bit_gravity = SouthWestGravity; |
|
8697 |
} else if (how == @symbol(SouthEast)) { |
|
8698 |
wa.bit_gravity = SouthEastGravity; |
|
8699 |
} else if (how == @symbol(Center)) { |
|
8700 |
wa.bit_gravity = CenterGravity; |
|
8701 |
} else if (how == @symbol(North)) { |
|
8702 |
wa.bit_gravity = NorthGravity; |
|
8703 |
} else if (how == @symbol(South)) { |
|
8704 |
wa.bit_gravity = SouthGravity; |
|
8705 |
} else if (how == @symbol(West)) { |
|
8706 |
wa.bit_gravity = WestGravity; |
|
8707 |
} else if (how == @symbol(East)) { |
|
8708 |
wa.bit_gravity = EastGravity; |
|
8709 |
} else { |
|
8710 |
wa.bit_gravity = NorthWestGravity; |
|
8711 |
} |
|
8712 |
||
8713 |
BEGIN_INTERRUPTSBLOCKED |
|
8714 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
8715 |
END_INTERRUPTSBLOCKED |
|
8716 |
RETURN ( self ); |
|
295 | 8717 |
} |
8718 |
%}. |
|
8719 |
self primitiveFailed |
|
8720 |
! |
|
8721 |
||
1344 | 8722 |
setCursor:aCursorId in:aWindowId |
295 | 8723 |
"define a windows cursor" |
8724 |
||
8725 |
%{ /* NOCONTEXT */ |
|
8726 |
||
8727 |
Display *dpy = myDpy; |
|
8728 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8729 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8730 |
&& __isExternalAddress(aWindowId) |
295 | 8731 |
&& __isExternalAddress(aCursorId)) { |
1344 | 8732 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
8733 |
RETURN ( self ); |
|
295 | 8734 |
} |
8735 |
%}. |
|
8736 |
self primitiveFailed |
|
8737 |
! |
|
8738 |
||
1344 | 8739 |
setIconName:aString in:aWindowId |
295 | 8740 |
"define a windows iconname" |
8741 |
||
8742 |
%{ /* NOCONTEXT */ |
|
8743 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8744 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8745 |
&& __isExternalAddress(aWindowId) |
295 | 8746 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8747 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8748 |
RETURN ( self ); |
|
295 | 8749 |
} |
8750 |
%}. |
|
8751 |
self primitiveFailed |
|
8752 |
! |
|
8753 |
||
1344 | 8754 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 8755 |
"turn on/off save-under for a window" |
8756 |
||
8757 |
%{ /* NOCONTEXT */ |
|
8758 |
||
8759 |
XSetWindowAttributes wa; |
|
8760 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8761 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8762 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8763 |
if (__INST(hasSaveUnder) == true) { |
8764 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
8765 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
8766 |
} |
|
8767 |
RETURN ( self ); |
|
295 | 8768 |
} |
8769 |
%}. |
|
8770 |
self primitiveFailed |
|
8771 |
! |
|
8772 |
||
1344 | 8773 |
setTransient:aWindowId for:aMainWindowId |
295 | 8774 |
"set aWindowId to be a transient of aMainWindow" |
8775 |
||
8776 |
%{ /* NOCONTEXT */ |
|
8777 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8778 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8779 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8780 |
Window w; |
8781 |
||
8782 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
8783 |
w = (Window) 0; |
|
8784 |
} else { |
|
8785 |
if (__isExternalAddress(aMainWindowId)) { |
|
8786 |
w = _WindowVal(aMainWindowId); |
|
8787 |
} else { |
|
8788 |
goto getOutOfHere; |
|
8789 |
} |
|
8790 |
} |
|
8791 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
|
8792 |
RETURN ( self ); |
|
295 | 8793 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
8794 |
getOutOfHere: ; |
295 | 8795 |
%}. |
8796 |
self primitiveFailed |
|
8797 |
! |
|
8798 |
||
1344 | 8799 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 8800 |
"set the windows background color. This is the color with which |
8801 |
the view is filled whenever exposed. Do not confuse this with |
|
8802 |
the background drawing color, which is used with opaque drawing." |
|
8803 |
||
8804 |
%{ /* NOCONTEXT */ |
|
8805 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8806 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8807 |
&& __isExternalAddress(aWindowId) |
295 | 8808 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8809 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8810 |
RETURN ( self ); |
|
295 | 8811 |
} |
8812 |
%}. |
|
8813 |
self primitiveFailed |
|
8814 |
! |
|
8815 |
||
1344 | 8816 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 8817 |
"set the windows background pattern to be a form. |
8818 |
This is the pattern with which the view is filled whenever exposed. |
|
8819 |
Do not confuse this with the background drawing color, which is used |
|
8820 |
with opaque drawing." |
|
8821 |
||
8822 |
%{ /* NOCONTEXT */ |
|
8823 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8824 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8825 |
&& __isExternalAddress(aWindowId) |
295 | 8826 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8827 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8828 |
RETURN ( self ); |
|
295 | 8829 |
} |
8830 |
%}. |
|
8831 |
self primitiveFailed |
|
8832 |
! |
|
8833 |
||
1344 | 8834 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 8835 |
"set the windows border color" |
8836 |
||
8837 |
%{ /* NOCONTEXT */ |
|
8838 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8839 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8840 |
&& __isExternalAddress(aWindowId) |
295 | 8841 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8842 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8843 |
RETURN ( self ); |
|
295 | 8844 |
} |
8845 |
%}. |
|
8846 |
self primitiveFailed |
|
8847 |
! |
|
8848 |
||
1344 | 8849 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 8850 |
"set the windows border pattern" |
8851 |
||
8852 |
%{ /* NOCONTEXT */ |
|
8853 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8854 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8855 |
&& __isExternalAddress(aWindowId) |
295 | 8856 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8857 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8858 |
RETURN ( self ); |
|
295 | 8859 |
} |
8860 |
%} |
|
8861 |
. |
|
8862 |
self primitiveFailed |
|
8863 |
! |
|
8864 |
||
1344 | 8865 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 8866 |
"set the windows border shape" |
8867 |
||
8868 |
hasShapeExtension ifFalse:[^ self]. |
|
8869 |
||
8870 |
%{ /* NOCONTEXT */ |
|
8871 |
||
8872 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8873 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8874 |
&& __isExternalAddress(aWindowId) |
295 | 8875 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8876 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
8877 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
8878 |
RETURN ( self ); |
|
295 | 8879 |
} |
8880 |
#endif |
|
8881 |
%}. |
|
8882 |
self primitiveFailed |
|
8883 |
! |
|
8884 |
||
1344 | 8885 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 8886 |
"set the windows border width" |
8887 |
||
8888 |
%{ /* NOCONTEXT */ |
|
8889 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8890 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8891 |
&& __isExternalAddress(aWindowId) |
295 | 8892 |
&& __isSmallInteger(aNumber)) { |
1344 | 8893 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
8894 |
RETURN ( self ); |
|
295 | 8895 |
} |
8896 |
%}. |
|
8897 |
self primitiveFailed |
|
8898 |
! |
|
8899 |
||
1344 | 8900 |
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
|
8901 |
"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
|
8902 |
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
|
8903 |
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
|
8904 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8905 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8906 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8907 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8908 |
XClassHint classhint; |
8909 |
||
8910 |
classhint.res_class = classhint.res_name = 0; |
|
8911 |
||
8912 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
8913 |
classhint.res_class = (char *)_stringVal(wClass); |
|
8914 |
} else if (wClass != nil) |
|
8915 |
goto error; |
|
8916 |
||
8917 |
if (__isString(wName) || __isSymbol(wName)) { |
|
8918 |
classhint.res_name = (char *)_stringVal(wName); |
|
8919 |
} else if (wName != nil) |
|
8920 |
goto error; |
|
8921 |
||
8922 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
|
8923 |
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
|
8924 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8925 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8926 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8927 |
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
|
8928 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8929 |
|
1344 | 8930 |
setWindowGravity:how in:aWindowId |
295 | 8931 |
"set window gravity for a window" |
8932 |
||
8933 |
%{ /* NOCONTEXT */ |
|
8934 |
||
8935 |
XSetWindowAttributes wa; |
|
8936 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8937 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8938 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8939 |
if (how == @symbol(NorthWest)) { |
8940 |
wa.win_gravity = NorthWestGravity; |
|
8941 |
} else if (how == @symbol(NorthEast)) { |
|
8942 |
wa.win_gravity = NorthEastGravity; |
|
8943 |
} else if (how == @symbol(SouthWest)) { |
|
8944 |
wa.win_gravity = SouthWestGravity; |
|
8945 |
} else if (how == @symbol(SouthEast)) { |
|
8946 |
wa.win_gravity = SouthEastGravity; |
|
8947 |
} else if (how == @symbol(Center)) { |
|
8948 |
wa.win_gravity = CenterGravity; |
|
8949 |
} else if (how == @symbol(North)) { |
|
8950 |
wa.win_gravity = NorthGravity; |
|
8951 |
} else if (how == @symbol(South)) { |
|
8952 |
wa.win_gravity = SouthGravity; |
|
8953 |
} else if (how == @symbol(West)) { |
|
8954 |
wa.win_gravity = WestGravity; |
|
8955 |
} else if (how == @symbol(East)) { |
|
8956 |
wa.win_gravity = EastGravity; |
|
8957 |
} else { |
|
8958 |
wa.win_gravity = NorthWestGravity; |
|
8959 |
} |
|
8960 |
||
8961 |
BEGIN_INTERRUPTSBLOCKED |
|
8962 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8963 |
END_INTERRUPTSBLOCKED |
|
8964 |
RETURN ( self ); |
|
295 | 8965 |
} |
8966 |
%}. |
|
8967 |
self primitiveFailed |
|
8968 |
! |
|
8969 |
||
1344 | 8970 |
setWindowIcon:aForm in:aWindowId |
295 | 8971 |
"define a bitmap to be used as icon" |
8972 |
||
8973 |
|iconId| |
|
8974 |
||
8975 |
aForm notNil ifTrue:[ |
|
1344 | 8976 |
iconId := aForm id |
295 | 8977 |
]. |
8978 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8979 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8980 |
&& __isExternalAddress(iconId) |
295 | 8981 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8982 |
XWMHints hints; |
8983 |
||
8984 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8985 |
hints.flags = IconPixmapHint; |
|
8986 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8987 |
RETURN ( self ); |
|
295 | 8988 |
} |
8989 |
%}. |
|
8990 |
self primitiveFailed |
|
8991 |
! |
|
8992 |
||
1376 | 8993 |
setWindowIcon:aForm mask:aMaskForm in:aWindowId |
1535 | 8994 |
"define a windows icon and (optional) iconMask." |
8995 |
||
8996 |
|iconId maskId| |
|
8997 |
||
8998 |
aForm notNil ifTrue:[ |
|
8999 |
iconId := aForm id |
|
9000 |
]. |
|
9001 |
aMaskForm notNil ifTrue:[ |
|
9002 |
maskId := aMaskForm id. |
|
9003 |
]. |
|
9004 |
%{ |
|
9005 |
if (ISCONNECTED |
|
9006 |
&& __isExternalAddress(iconId) |
|
9007 |
&& __isExternalAddress(aWindowId)) { |
|
9008 |
XWMHints hints; |
|
9009 |
||
9010 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
9011 |
hints.flags = IconPixmapHint; |
|
9012 |
if ((maskId != nil) |
|
9013 |
&& __isExternalAddress(maskId)) { |
|
9014 |
hints.icon_mask = _PixmapVal(maskId); |
|
9015 |
hints.flags |= IconMaskHint; |
|
9016 |
} |
|
9017 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
9018 |
RETURN ( self ); |
|
9019 |
} |
|
9020 |
%}. |
|
9021 |
self primitiveFailed |
|
9022 |
||
1376 | 9023 |
! |
9024 |
||
1344 | 9025 |
setWindowIconWindow:aView in:aWindowId |
295 | 9026 |
"define a window to be used as icon" |
9027 |
||
9028 |
|iconWindowId| |
|
9029 |
||
9030 |
aView notNil ifTrue:[ |
|
1344 | 9031 |
iconWindowId := aView id |
295 | 9032 |
]. |
9033 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9034 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9035 |
&& __isExternalAddress(iconWindowId) |
295 | 9036 |
&& __isExternalAddress(aWindowId)) { |
1344 | 9037 |
XWMHints wmhints; |
9038 |
||
9039 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
9040 |
wmhints.flags = IconWindowHint; |
|
9041 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
9042 |
RETURN ( self ); |
|
295 | 9043 |
} |
9044 |
%}. |
|
9045 |
self primitiveFailed |
|
9046 |
! |
|
9047 |
||
1344 | 9048 |
setWindowName:aString in:aWindowId |
295 | 9049 |
"define a windows name" |
9050 |
||
9051 |
%{ /* NOCONTEXT */ |
|
9052 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9053 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
9054 |
&& __isExternalAddress(aWindowId) |
295 | 9055 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 9056 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
9057 |
RETURN ( self ); |
|
295 | 9058 |
} |
9059 |
%}. |
|
9060 |
self primitiveFailed |
|
9061 |
! |
|
9062 |
||
1344 | 9063 |
setWindowShape:aPixmapId in:aWindowId |
295 | 9064 |
"set the windows shape" |
9065 |
||
9066 |
hasShapeExtension ifFalse:[^ self]. |
|
9067 |
||
9068 |
%{ /* NOCONTEXT */ |
|
9069 |
||
9070 |
#ifdef SHAPE |
|
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(aWindowId) |
295 | 9073 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 9074 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
9075 |
0, 0, |
|
9076 |
_PixmapVal(aPixmapId), ShapeSet); |
|
9077 |
RETURN ( self ); |
|
295 | 9078 |
} |
9079 |
#endif |
|
9080 |
%}. |
|
9081 |
self primitiveFailed |
|
9082 |
! |
|
9083 |
||
1344 | 9084 |
unmapWindow:aWindowId |
295 | 9085 |
"make a window invisible" |
9086 |
||
9087 |
%{ /* NOCONTEXT */ |
|
9088 |
||
1214 | 9089 |
if (!ISCONNECTED) { |
1344 | 9090 |
RETURN ( self ); |
1214 | 9091 |
} |
9092 |
||
9093 |
if (__isExternalAddress(aWindowId)) { |
|
1344 | 9094 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
9095 |
RETURN ( self ); |
|
9096 |
} |
|
9097 |
%}. |
|
295 | 9098 |
self primitiveFailed |
1535 | 9099 |
! |
9100 |
||
9101 |
windowIsIconified:aWindowId |
|
9102 |
"return true, if some window is iconified. |
|
9103 |
The passed windowID may be an alien windows id." |
|
9104 |
||
9105 |
%{ /* NOCONTEXT */ |
|
9106 |
||
9107 |
if (ISCONNECTED |
|
9108 |
&& __isExternalAddress(aWindowId)) { |
|
9109 |
Atom JunkAtom; |
|
9110 |
int JunkInt; |
|
9111 |
unsigned long WinState,JunkLong; |
|
9112 |
unsigned char *Property; |
|
9113 |
Atom WM_STATE_Atom; |
|
9114 |
||
9115 |
if (__INST(wmStateAtom) != nil) { |
|
9116 |
WM_STATE_Atom = _AtomVal(__INST(wmStateAtom)); |
|
9117 |
||
9118 |
XGetWindowProperty(myDpy, _WindowVal(aWindowId), |
|
9119 |
WM_STATE_Atom, |
|
9120 |
0L, 2L, False, AnyPropertyType, |
|
9121 |
&JunkAtom,&JunkInt,&WinState,&JunkLong, |
|
9122 |
&Property); |
|
9123 |
WinState=(unsigned long)(*((long*)Property)); |
|
9124 |
if (WinState==3) { |
|
9125 |
RETURN (true); |
|
9126 |
} |
|
9127 |
} |
|
9128 |
RETURN (false); |
|
9129 |
} |
|
9130 |
%}. |
|
9131 |
self primitiveFailed |
|
9132 |
||
9133 |
||
9134 |
||
295 | 9135 |
! ! |
9136 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
9137 |
!XWorkstation class methodsFor:'documentation'! |
295 | 9138 |
|
9139 |
version |
|
1557
c37fd33dc7d8
don use strlen when setting a string prop;
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
9140 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.231 1997-04-06 12:31:28 cg Exp $' |
295 | 9141 |
! ! |
9142 |
XWorkstation initialize! |