author | Claus Gittinger <cg@exept.de> |
Mon, 24 Feb 1997 18:37:48 +0100 | |
changeset 1366 | f6bf6c707e32 |
parent 1361 | 784d654780e6 |
child 1376 | 8b2ceb27230d |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
1344 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
DeviceWorkstation subclass:#XWorkstation |
|
1344 | 14 |
instanceVariableNames:'screen hasShapeExtension hasShmExtension hasDPSExtension |
15 |
hasMbufExtension hasXVideoExtension hasSaveUnder hasPEXExtension |
|
16 |
hasImageExtension hasInputExtension ignoreBackingStore blackpixel |
|
17 |
whitepixel protocolsAtom deleteWindowAtom saveYourselfAtom |
|
18 |
quitAppAtom primaryAtom secondaryAtom cutBuffer0Atom stringAtom |
|
19 |
lengthAtom listOfXFonts buttonsPressed eventRootX eventRootY |
|
20 |
displayName eventTrace dispatchingExpose rgbVisual virtualRootId |
|
21 |
rootId eventBuffer altModifierMask metaModifierMask multiClickTime' |
|
22 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
|
23 |
poolDictionaries:'' |
|
24 |
category:'Interface-Graphics' |
|
295 | 25 |
! |
0 | 26 |
|
78 | 27 |
!XWorkstation primitiveDefinitions! |
0 | 28 |
%{ |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
29 |
|
1062 | 30 |
#ifdef LINUX |
31 |
# define SHM |
|
32 |
#endif |
|
33 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
34 |
#define COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
35 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
36 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
37 |
static int __cnt_color = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
38 |
static int __cnt_bitmap = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
39 |
static int __cnt_view = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
40 |
static int __cnt_gc = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
41 |
static int __cnt_cursor = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
42 |
static int __cnt_font = 0; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
43 |
|
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
44 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
45 |
|
46 | 46 |
/* |
47 |
* x does a typedef Time - I need Object Time ... |
|
48 |
*/ |
|
0 | 49 |
#define Time XTime |
50 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
51 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
52 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
53 |
* 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
|
54 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
55 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
56 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
57 |
|
37 | 58 |
#ifdef memset |
59 |
# undef memset |
|
60 |
#endif |
|
61 |
||
0 | 62 |
#include <stdio.h> |
63 |
#include <X11/Xlib.h> |
|
64 |
#include <X11/Xutil.h> |
|
65 |
#include <X11/Xatom.h> |
|
66 |
||
150 | 67 |
#define XK_MISCELLANY |
68 |
#include <X11/keysymdef.h> |
|
69 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
70 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
71 |
|
90 | 72 |
/* |
73 |
* this define adds support for two-byte-strings. |
|
74 |
* leaving it undefined does not really save you much |
|
75 |
* (the define will vanish) |
|
76 |
*/ |
|
36 | 77 |
#define TWOBYTESTRINGS |
78 |
||
0 | 79 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
80 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
81 |
* 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
|
82 |
* 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
|
83 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
84 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
85 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
86 |
/* |
0 | 87 |
* shape support works; enabled by -DSHAPE in makefile |
88 |
* see RoundClock and RoundGlobe examples |
|
89 |
*/ |
|
90 |
#ifdef SHAPE |
|
91 |
# include <X11/extensions/shape.h> |
|
92 |
#endif |
|
93 |
||
94 |
/* |
|
150 | 95 |
* shared memory extension access is currently not supported |
0 | 96 |
* (only query is implemented) |
97 |
*/ |
|
98 |
#ifdef SHM |
|
99 |
# include <X11/extensions/XShm.h> |
|
100 |
#endif |
|
101 |
||
102 |
/* |
|
150 | 103 |
* multiBuffer extension access is currently not supported |
104 |
* (only query is implemented) |
|
105 |
*/ |
|
106 |
#ifdef MBUF |
|
107 |
# include <X11/extensions/multibuf.h> |
|
108 |
#endif |
|
109 |
||
110 |
/* |
|
111 |
* XVideo extension access is currently not supported |
|
112 |
* (only query is implemented) |
|
113 |
*/ |
|
114 |
#ifdef XVIDEO |
|
115 |
# include <X11/extensions/Xv.h> |
|
116 |
#endif |
|
117 |
||
118 |
/* |
|
186 | 119 |
* PEX extension - if available |
120 |
*/ |
|
121 |
#ifdef PEX5 |
|
122 |
# include <PEX5/PEX.h> |
|
123 |
#endif |
|
124 |
||
125 |
/* |
|
126 |
* XImage extension - if available |
|
127 |
*/ |
|
128 |
#ifdef XIE |
|
129 |
# include <X11/extensions/XIE.h> |
|
130 |
#endif |
|
131 |
||
132 |
/* |
|
90 | 133 |
* when I have more time to check it out, I will support display-PS |
0 | 134 |
*/ |
135 |
#ifdef DPS |
|
136 |
# ifdef sgi |
|
137 |
# include <X11/extensions/XDPS.h> |
|
138 |
# include <X11/extensions/XDPSlib.h> |
|
139 |
# include <X11/extensions/dpsXclient.h> |
|
140 |
# else |
|
141 |
# include <DPS/XDPS.h> |
|
142 |
# include <DPS/XDPSlib.h> |
|
143 |
# include <DPS/dpsXclient.h> |
|
144 |
# endif |
|
145 |
#endif |
|
146 |
||
90 | 147 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
148 |
/* |
|
149 |
* accessing private data in Display ... sorry |
|
150 |
*/ |
|
151 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
152 |
#else |
|
153 |
# define DISPLAYACCESS(d) d |
|
154 |
#endif |
|
155 |
||
78 | 156 |
/* |
157 |
* some defines - tired of typing ... |
|
158 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
159 |
#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
|
160 |
#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
|
161 |
#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
|
162 |
#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
|
163 |
#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
|
164 |
#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
|
165 |
#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
|
166 |
|
211 | 167 |
#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
|
168 |
#define _AtomVal(o) __intVal(o) |
211 | 169 |
#define __isAtomID(o) __isSmallInteger(o) |
170 |
||
555 | 171 |
#define myDpy _DisplayVal(__INST(displayId)) |
172 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 173 |
|
174 |
#ifndef THISCONTEXT_IN_REGISTER |
|
1098 | 175 |
|
78 | 176 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
177 |
# define END_INTERRUPTSBLOCKED /* */ |
|
1098 | 178 |
|
78 | 179 |
#else |
1098 | 180 |
|
78 | 181 |
# define BEGIN_INTERRUPTSBLOCKED \ |
182 |
{ \ |
|
1344 | 183 |
int needUnblock = 0; \ |
184 |
\ |
|
185 |
__BEGIN_PROTECT_REGISTERS__ \ |
|
186 |
if (!__interruptsBlocked) { \ |
|
187 |
__BLOCKINTERRUPTS(); \ |
|
188 |
needUnblock = 1; \ |
|
189 |
} |
|
78 | 190 |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
191 |
# define END_INTERRUPTSBLOCKED_NOW \ |
1344 | 192 |
__END_PROTECT_REGISTERS__ \ |
193 |
if (needUnblock) { \ |
|
194 |
__UNBLOCKINTERRUPTS(); \ |
|
195 |
} \ |
|
78 | 196 |
} |
197 |
||
1103
8378530a4e8d
XShmQueryExtension -> XQueryExtension
Claus Gittinger <cg@exept.de>
parents:
1099
diff
changeset
|
198 |
# define END_INTERRUPTSBLOCKED \ |
1344 | 199 |
__END_PROTECT_REGISTERS__ |
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
200 |
|
78 | 201 |
#endif |
202 |
%} |
|
203 |
! ! |
|
204 |
||
205 |
!XWorkstation primitiveVariables! |
|
206 |
%{ |
|
0 | 207 |
/* |
146 | 208 |
* remembered info from private error handler |
0 | 209 |
*/ |
2 | 210 |
static char lastErrorMsg[80] = ""; |
211 |
static unsigned lastRequestCode = 0; |
|
212 |
static unsigned lastMinorCode = 0; |
|
213 |
static unsigned lastResource = 0; |
|
129 | 214 |
|
215 |
static int __debug__ = 0; |
|
216 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 217 |
%} |
218 |
! ! |
|
219 |
||
220 |
!XWorkstation primitiveFunctions! |
|
221 |
%{ |
|
1062 | 222 |
|
1081 | 223 |
#ifdef __GNUC__ |
224 |
VOLATILE |
|
225 |
#endif |
|
226 |
||
227 |
static |
|
1062 | 228 |
dummyToForceLoading() { |
1344 | 229 |
XCreateSimpleWindow(0, 0, 0, 0, 0, 0, 0, 0, 0); |
230 |
XCloseDisplay(0); |
|
231 |
XCreateImage(0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0); |
|
232 |
XSetWindowColormap(0, 0, 0); |
|
233 |
XQueryColors(0,0,0,0); |
|
1062 | 234 |
#ifdef SHM |
1344 | 235 |
XShmAttach(0, 0); |
236 |
XShmCreateImage(0, 0, 0, 0, 0, 0, 0 ,0); |
|
237 |
XShmDetach(0, 0); |
|
238 |
XShmPutImage(0, 0, 0, 0 , 0,0,0,0,0,0,0); |
|
239 |
shmctl(0,0,0); |
|
240 |
fgetc(0); |
|
1062 | 241 |
#endif |
242 |
} |
|
243 |
||
18 | 244 |
/* |
144 | 245 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
246 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 247 |
* the implementation below is somewhat wrong: it will |
78 | 248 |
* report all errors for Display, even though there could be |
162 | 249 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
250 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 251 |
*/ |
963
45ebbbb40f38
simply suppress those BadWindow-destroy messages (sigh)
Claus Gittinger <cg@exept.de>
parents:
928
diff
changeset
|
252 |
|
12 | 253 |
__XErrorHandler__(dpy, event) |
0 | 254 |
Display *dpy; |
255 |
XErrorEvent *event; |
|
256 |
{ |
|
1060
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
257 |
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
|
258 |
lastErrorMsg[79] = '\0'; |
bc581886fe8f
dont interrupt immediately; use superclasses colorName processing as fallBack
Claus Gittinger <cg@exept.de>
parents:
1056
diff
changeset
|
259 |
|
0 | 260 |
if (lastErrorMsg[0] == '\0') { |
1344 | 261 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 262 |
} |
2 | 263 |
lastRequestCode = event->request_code; |
264 |
lastMinorCode = event->minor_code; |
|
265 |
lastResource = event->resourceid; |
|
911 | 266 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
1344 | 267 |
/* |
268 |
* this is a BadWindow error for X_DestroyWindow. |
|
269 |
* ignore it here, since it results from the GC freeing windows |
|
270 |
* in non bottom-up window order. |
|
271 |
*/ |
|
272 |
return 0; |
|
911 | 273 |
} |
2 | 274 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
275 |
if (@global(ErrorPrinting) == true) { |
1344 | 276 |
fprintf(stderr, "XWorkstation [error]: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
277 |
event->request_code, event->request_code, |
|
278 |
event->minor_code, event->minor_code, event->resourceid); |
|
279 |
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
|
280 |
} |
43 | 281 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
282 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 283 |
return 0; |
284 |
} |
|
285 |
||
90 | 286 |
#ifdef VIRTUAL_ROOT |
0 | 287 |
/* |
18 | 288 |
* added since RootWindow-macro is not suficient |
289 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
290 |
*/ |
|
291 |
static Window |
|
292 |
getRootWindow(dpy, screen) |
|
293 |
Display *dpy; |
|
294 |
{ |
|
295 |
Window root; |
|
296 |
Atom vRootAtom = None; |
|
297 |
int i; |
|
298 |
Window rootReturn, parentReturn; |
|
1050
b2c03e24d56c
another memoryLeak, due to an ommited XFree
Claus Gittinger <cg@exept.de>
parents:
1049
diff
changeset
|
299 |
Window* children = (Window *)0; |
18 | 300 |
unsigned int numChildren; |
301 |
||
302 |
root = RootWindow(dpy, screen); |
|
303 |
/* |
|
304 |
* on IRIS, this creates a badwindow error - why ? |
|
305 |
* children contains a funny window (000034) |
|
306 |
*/ |
|
90 | 307 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 308 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
1344 | 309 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
310 |
if (vRootAtom != None) { |
|
311 |
for (i=0; i < numChildren; i++) { |
|
312 |
Atom actual_type; |
|
313 |
int actual_format; |
|
314 |
unsigned long nitems, bytesafter; |
|
315 |
Window* newRoot = (Window*) 0; |
|
316 |
||
317 |
if (children[i]) { |
|
318 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
319 |
0L, 1L, False, XA_WINDOW, |
|
320 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
321 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
322 |
root = *newRoot; |
|
323 |
XFree(newRoot); /* XXX */ |
|
324 |
break; |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
329 |
if (children) XFree( children ); |
|
18 | 330 |
} |
90 | 331 |
# endif |
18 | 332 |
return root; |
333 |
} |
|
90 | 334 |
#endif |
0 | 335 |
%} |
78 | 336 |
! ! |
0 | 337 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
338 |
!XWorkstation class methodsFor:'documentation'! |
295 | 339 |
|
340 |
copyright |
|
341 |
" |
|
342 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
1344 | 343 |
All Rights Reserved |
295 | 344 |
|
345 |
This software is furnished under a license and may be used |
|
346 |
only in accordance with the terms of that license and with the |
|
347 |
inclusion of the above copyright notice. This software may not |
|
348 |
be provided or otherwise made available to, or used by, any |
|
349 |
other person. No title to or ownership of the software is |
|
350 |
hereby transferred. |
|
351 |
" |
|
352 |
! |
|
353 |
||
354 |
documentation |
|
355 |
" |
|
356 |
this class provides the interface to X11. It redefines all required methods |
|
357 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
358 |
limited to one display - in theory, you can create Views on many displays |
|
359 |
simultanously. However, the default setup is for one display only. |
|
360 |
To support multiple displays, you will have to start another event dispatcher |
|
361 |
process for the other display(s) and create the other views with a slightly |
|
362 |
different protocol. However, 'normal' applications do not have to care for |
|
363 |
all of this ... |
|
364 |
||
365 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 366 |
|
367 |
[author:] |
|
1344 | 368 |
Claus Gittinger |
295 | 369 |
" |
370 |
! ! |
|
371 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
372 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
373 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
374 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
375 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
376 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
377 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
378 |
|
386 | 379 |
RawKeysymTranslation isNil ifTrue:[ |
1344 | 380 |
"/ the following table maps X-keyevents to ST/X |
381 |
"/ device independed events. |
|
382 |
"/ It is NOT meant as a keyboardMap replacement. |
|
383 |
||
384 |
RawKeysymTranslation := d := Dictionary new. |
|
385 |
d at:'Delete_line' put:#DeleteLine. |
|
386 |
d at:'Delete_word' put:#DeleteWord. |
|
387 |
d at:'Down' put:#CursorDown. |
|
388 |
d at:'Up' put:#CursorUp. |
|
389 |
d at:'Left' put:#CursorLeft. |
|
390 |
d at:'Right' put:#CursorRight. |
|
386 | 391 |
] |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
392 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
393 |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
394 |
!XWorkstation class methodsFor:'error handling'! |
2 | 395 |
|
129 | 396 |
debug:aBoolean |
397 |
%{ /* NOCONTEXT */ |
|
398 |
||
399 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
400 |
%} |
|
401 |
! |
|
402 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
403 |
debugResources |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
404 |
%{ |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
405 |
#ifdef COUNT_RESOURCES |
928 | 406 |
printf("colors %d bitmaps %d view %d gc %d cursor %d font %d\n", |
1344 | 407 |
__cnt_color, __cnt_bitmap, |
408 |
__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
|
409 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
410 |
%} |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
411 |
! |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
412 |
|
78 | 413 |
errorStringOfLastError |
414 |
%{ |
|
1065
fdc5b9059d82
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
415 |
RETURN ( __MKSTRING(lastErrorMsg) ); |
78 | 416 |
%} |
417 |
! |
|
418 |
||
135 | 419 |
lastErrorString |
2 | 420 |
"return the last X-error string - |
421 |
when buffering is on, this may be |
|
422 |
an error for a long-ago operation" |
|
78 | 423 |
|
424 |
|string requestCode s match line| |
|
425 |
||
426 |
string := self errorStringOfLastError. |
|
427 |
requestCode := self requestCodeOfLastError. |
|
428 |
" |
|
429 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
430 |
and append the name of the corresponding X-request |
|
431 |
" |
|
432 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
433 |
s notNil ifTrue:[ |
|
1344 | 434 |
match := 'XRequest.' , requestCode printString. |
435 |
line := s peekForLineStartingWith:match. |
|
436 |
line notNil ifTrue:[ |
|
437 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
438 |
]. |
|
439 |
s close. |
|
78 | 440 |
]. |
441 |
^ string |
|
295 | 442 |
! |
443 |
||
444 |
minorCodeOfLastError |
|
445 |
%{ /* NOCONTEXT */ |
|
446 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
447 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 448 |
%} |
449 |
! |
|
450 |
||
451 |
requestCodeOfLastError |
|
152 | 452 |
%{ /* NOCONTEXT */ |
453 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
454 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 455 |
%} |
135 | 456 |
! |
457 |
||
295 | 458 |
resourceIdOfLastError |
0 | 459 |
%{ /* NOCONTEXT */ |
295 | 460 |
|
461 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 462 |
%} |
463 |
! ! |
|
464 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
465 |
!XWorkstation class methodsFor:'queries'! |
104 | 466 |
|
467 |
platformName |
|
133 | 468 |
"ST-80 compatibility. |
469 |
Return a string describing the display systems platform." |
|
470 |
||
715 | 471 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
472 |
||
473 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 474 |
! ! |
475 |
||
0 | 476 |
!XWorkstation methodsFor:'accessing & queries'! |
477 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
478 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
479 |
"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
|
480 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
481 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
482 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
483 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
484 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
485 |
^ nil |
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 |
|
295 | 488 |
blackpixel |
489 |
"return the colornumber of black" |
|
490 |
||
491 |
^ blackpixel |
|
492 |
! |
|
493 |
||
494 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
495 |
"return the state-mask for button1 in motion events' state-field. |
295 | 496 |
For backward compatibility." |
497 |
||
498 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
499 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 500 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
501 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
502 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
503 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
504 |
" |
295 | 505 |
! |
506 |
||
507 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
508 |
"return the state-mask for button2 in motion events' state-field |
295 | 509 |
For backward compatibility." |
510 |
||
511 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
512 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 513 |
%} |
514 |
! |
|
515 |
||
516 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
517 |
"return the state-mask for button3 in motion events' state-field |
295 | 518 |
For backward compatibility." |
519 |
||
520 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
521 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 522 |
%} |
523 |
! |
|
524 |
||
525 |
buttonMotionMask:aButton |
|
526 |
"return the state-mask for button1 in motion events state-field. |
|
527 |
This is the devices mask." |
|
528 |
||
529 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
530 |
if (aButton == __MKSMALLINT(1)) { |
1344 | 531 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
532 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
533 |
if (aButton == __MKSMALLINT(2)) { |
1344 | 534 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
535 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
536 |
if (aButton == __MKSMALLINT(3)) { |
1344 | 537 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 538 |
} |
539 |
%}. |
|
540 |
^ nil |
|
541 |
! |
|
542 |
||
382 | 543 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
544 |
"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
|
545 |
|
382 | 546 |
%{ /* NOCONTEXT */ |
547 |
RETURN (__MKSMALLINT(ControlMask)); |
|
548 |
%} |
|
549 |
! |
|
550 |
||
295 | 551 |
defaultEventMask |
552 |
"return a mask to enable some events by default." |
|
553 |
||
554 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
555 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
1344 | 556 |
KeyPressMask | KeyReleaseMask | |
557 |
EnterWindowMask | LeaveWindowMask | |
|
558 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
295 | 559 |
%} |
560 |
! |
|
561 |
||
0 | 562 |
displayFileDescriptor |
563 |
"return the displays fileNumber - for select" |
|
564 |
||
565 |
%{ /* NOCONTEXT */ |
|
566 |
||
150 | 567 |
if (ISCONNECTED) { |
1344 | 568 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 569 |
} |
570 |
RETURN (nil); |
|
0 | 571 |
%} |
572 |
! |
|
573 |
||
133 | 574 |
displayName |
575 |
"return the X-connections display name. |
|
576 |
This is (currently) nil for the default display, |
|
577 |
something like foo:0 for any other remote display. |
|
578 |
Future versions may return non-nil strings for the default display as well." |
|
579 |
||
580 |
^ displayName |
|
581 |
! |
|
582 |
||
341 | 583 |
protocolVersion |
584 |
"return the X-servers protocol version - should normally not be of |
|
585 |
any interest" |
|
586 |
||
587 |
%{ /* NOCONTEXT */ |
|
588 |
if (ISCONNECTED) { |
|
1344 | 589 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
341 | 590 |
} |
591 |
RETURN (nil); |
|
592 |
%} |
|
593 |
||
594 |
" |
|
595 |
Display protocolVersion |
|
596 |
" |
|
597 |
! |
|
598 |
||
599 |
serverVendor |
|
600 |
"return the X-server vendor string - this should normally not be of |
|
601 |
any interest, but can be for special cases |
|
602 |
(to avoid bugs in certain implementations)" |
|
603 |
%{ |
|
604 |
if (ISCONNECTED) { |
|
1344 | 605 |
RETURN ( __MKSTRING(XServerVendor(myDpy)) ); |
341 | 606 |
} |
607 |
RETURN (nil); |
|
608 |
%} |
|
609 |
||
610 |
" |
|
611 |
Display serverVendor |
|
612 |
" |
|
613 |
! |
|
614 |
||
382 | 615 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
616 |
"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
|
617 |
|
382 | 618 |
%{ /* NOCONTEXT */ |
619 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
620 |
%} |
|
621 |
! |
|
622 |
||
341 | 623 |
translatePoint:aPoint from:windowId1 to:windowId2 |
624 |
"given a point in window1, return the coordinate in window2. |
|
625 |
This expects a device coordinate (relative to the first views origin) |
|
626 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
627 |
- use to xlate points from a window to rootwindow" |
|
628 |
||
629 |
|x1 y1 x2 y2| |
|
630 |
||
631 |
x1 := x2 := aPoint x truncated. |
|
632 |
y1 := y2 := aPoint y truncated. |
|
633 |
%{ |
|
634 |
int xpos, ypos; |
|
635 |
Window w1, w2, child_return; |
|
555 | 636 |
int screen = __intVal(__INST(screen)); |
1209 | 637 |
|
638 |
if (ISCONNECTED |
|
639 |
&& __isExternalAddress(windowId1) |
|
341 | 640 |
&& __isExternalAddress(windowId2) |
641 |
&& __bothSmallInteger(x1, y1)) { |
|
1344 | 642 |
Display *dpy = myDpy; |
643 |
||
644 |
w1 = _WindowVal(windowId1); |
|
645 |
w2 = _WindowVal(windowId2); |
|
341 | 646 |
#ifdef VIRTUAL_ROOT |
1344 | 647 |
if ((w1 == RootWindow(dpy, screen)) |
648 |
|| (w2 == RootWindow(dpy, screen))) { |
|
649 |
if (w1 == RootWindow(dpy, screen)) { |
|
650 |
w1 = getRootWindow(dpy, screen); |
|
651 |
} |
|
652 |
if (w2 == RootWindow(dpy, screen)) { |
|
653 |
w2 = getRootWindow(dpy, screen); |
|
654 |
} |
|
655 |
} |
|
341 | 656 |
#endif |
1344 | 657 |
BEGIN_INTERRUPTSBLOCKED |
658 |
XTranslateCoordinates(dpy, w1, w2, |
|
659 |
__intVal(x1), __intVal(y1), |
|
660 |
&xpos, &ypos, &child_return); |
|
661 |
END_INTERRUPTSBLOCKED |
|
662 |
x2 = __MKSMALLINT(xpos); |
|
663 |
y2 = __MKSMALLINT(ypos); |
|
341 | 664 |
} |
665 |
%}. |
|
666 |
||
667 |
^ (x2 @ y2) |
|
668 |
! |
|
669 |
||
670 |
vendorRelease |
|
671 |
"return the X-servers vendor release - should normally not be of |
|
672 |
any interest, but can be for special cases. |
|
673 |
(to avoid bugs in certain implementations)" |
|
674 |
||
675 |
%{ /* NOCONTEXT */ |
|
676 |
if (ISCONNECTED) { |
|
1344 | 677 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
341 | 678 |
} |
679 |
RETURN (nil); |
|
680 |
%} |
|
681 |
||
682 |
" |
|
683 |
Display vendorRelease |
|
684 |
" |
|
685 |
! |
|
686 |
||
687 |
viewIdFromPoint:aPoint in:windowId |
|
688 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
689 |
hit by this coordinate. Return nil if no view was hit. |
|
690 |
The returned id may be the id of a non ST view. |
|
691 |
- used to find the window to drop objects after a cross-view drag." |
|
692 |
||
693 |
%{ /* NOCONTEXT */ |
|
694 |
||
555 | 695 |
int screen = __intVal(__INST(screen)); |
341 | 696 |
OBJ xp, yp; |
697 |
int xpos, ypos; |
|
698 |
Window child_return; |
|
699 |
||
1209 | 700 |
if (ISCONNECTED |
701 |
&& __isExternalAddress(windowId) |
|
341 | 702 |
&& __isPoint(aPoint)) { |
1344 | 703 |
Display *dpy = myDpy; |
704 |
||
705 |
xp = _point_X(aPoint); |
|
706 |
yp = _point_Y(aPoint); |
|
707 |
if (__bothSmallInteger(xp, yp)) { |
|
708 |
BEGIN_INTERRUPTSBLOCKED |
|
709 |
XTranslateCoordinates(dpy, |
|
710 |
RootWindow(dpy, screen), |
|
711 |
_WindowVal(windowId), |
|
712 |
__intVal(xp), __intVal(yp), |
|
713 |
&xpos, &ypos, &child_return); |
|
714 |
END_INTERRUPTSBLOCKED |
|
715 |
if (child_return) { |
|
716 |
RETURN ( __MKOBJ(child_return) ); |
|
717 |
} |
|
718 |
RETURN ( nil ); |
|
719 |
} |
|
341 | 720 |
} |
721 |
%}. |
|
722 |
windowId notNil ifTrue:[ |
|
1344 | 723 |
aPoint isPoint ifTrue:[ |
724 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
725 |
] |
|
341 | 726 |
]. |
727 |
||
728 |
^ nil |
|
729 |
! |
|
730 |
||
731 |
virtualExtent |
|
732 |
"return the virtual extent of the display (in pixels). |
|
733 |
On most systems, this is the same as the physical width; |
|
734 |
except, if a window manager with a virtual desktop like olvwm |
|
735 |
(simulating a bigger screen) is running." |
|
736 |
||
737 |
%{ |
|
1209 | 738 |
if (ISCONNECTED |
739 |
&& (__INST(rootId) != __INST(virtualRootId)) |
|
555 | 740 |
&& __isExternalAddress(__INST(virtualRootId))) { |
1344 | 741 |
Window vRootWin; |
742 |
Window root; |
|
743 |
int x, y; |
|
744 |
unsigned int width, height; |
|
745 |
unsigned int dummy; |
|
746 |
||
747 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
|
748 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
|
749 |
&dummy, &dummy)) { |
|
750 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
751 |
} |
|
341 | 752 |
} |
753 |
%}. |
|
754 |
^ width @ height |
|
755 |
! |
|
756 |
||
757 |
whitepixel |
|
758 |
"return the colornumber of white" |
|
759 |
||
760 |
^ whitepixel |
|
761 |
! ! |
|
762 |
||
763 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
764 |
||
0 | 765 |
hasDPS |
186 | 766 |
"return true, if this workstation supports display postscript. |
767 |
Both the server must support it, and the feature must have been |
|
768 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 769 |
|
770 |
^ hasDPSExtension |
|
186 | 771 |
|
772 |
" |
|
773 |
Display hasDPS |
|
774 |
" |
|
775 |
! |
|
776 |
||
150 | 777 |
hasExtension:extensionString |
778 |
"query for an X extension. The argument, extensionString |
|
779 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 780 |
Return true, if that extension is available in the server. |
781 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 782 |
|
783 |
%{ |
|
784 |
int dummy; |
|
785 |
||
786 |
if (__isString(extensionString) && ISCONNECTED) { |
|
1344 | 787 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
788 |
RETURN ( true ); |
|
789 |
} |
|
150 | 790 |
} |
791 |
%}. |
|
792 |
^ false |
|
186 | 793 |
|
794 |
" |
|
795 |
Display hasExtension:'XVideo' |
|
796 |
Display hasExtension:'Input' |
|
797 |
Display hasExtension:'GLX' |
|
798 |
Display hasExtension:'X3D-PEX' |
|
799 |
Display hasExtension:'XInputExtension' |
|
800 |
Display hasExtension:'SHAPE' |
|
801 |
Display hasExtension:'MIT-SHM' |
|
802 |
Display hasExtension:'SGIFullScreenStereo' |
|
803 |
" |
|
150 | 804 |
! |
805 |
||
295 | 806 |
hasImageExtension |
807 |
"return true, if this workstation supports the X image extension. |
|
808 |
Both the server must support it, and the feature must have been |
|
809 |
enabled in the smalltalk system, for true to be returned." |
|
810 |
||
811 |
^ hasImageExtension |
|
812 |
||
813 |
" |
|
814 |
Display hasImageExtension |
|
815 |
" |
|
816 |
! |
|
817 |
||
818 |
hasInputExtension |
|
819 |
"return true, if this workstation supports the X input extension. |
|
820 |
Both the server must support it, and the feature must have been |
|
821 |
enabled in the smalltalk system, for true to be returned." |
|
822 |
||
823 |
^ hasInputExtension |
|
824 |
||
825 |
" |
|
826 |
Display hasInputExtension |
|
827 |
" |
|
828 |
! |
|
829 |
||
830 |
hasMultibuffer |
|
831 |
"return true, if this workstation supports the multibuffer extension. |
|
832 |
Both the server must support it, and the feature must have been |
|
833 |
enabled in the smalltalk system, for true to be returned." |
|
834 |
||
835 |
^ hasMbufExtension |
|
836 |
||
837 |
" |
|
838 |
Display hasMultibuffer |
|
839 |
" |
|
840 |
! |
|
841 |
||
842 |
hasPEX |
|
843 |
"return true, if this workstation supports PEX 3D graphics. |
|
844 |
Both the server must support it, and the feature must have been |
|
845 |
enabled in the smalltalk system, for true to be returned." |
|
846 |
||
847 |
^ hasPEXExtension |
|
848 |
||
849 |
" |
|
850 |
Display hasPEX |
|
851 |
" |
|
852 |
! |
|
853 |
||
854 |
hasShape |
|
855 |
"return true, if this workstation supports non-rectangular windows. |
|
856 |
Both the server must support it, and the feature must have been |
|
857 |
enabled in the smalltalk system, for true to be returned." |
|
858 |
||
859 |
^ hasShapeExtension |
|
860 |
||
861 |
" |
|
862 |
Display hasShape |
|
863 |
" |
|
864 |
! |
|
865 |
||
866 |
hasShm |
|
867 |
"return true, if this workstation supports the shared pixmap extension. |
|
868 |
Both the server must support it, and the feature must have been |
|
869 |
enabled in the smalltalk system, for true to be returned." |
|
870 |
||
871 |
^ hasShmExtension |
|
872 |
||
873 |
" |
|
874 |
Display hasShm |
|
875 |
" |
|
876 |
! |
|
877 |
||
878 |
hasXVideo |
|
879 |
"return true, if this workstation supports the XVideo extension. |
|
880 |
Both the server must support it, and the feature must have been |
|
881 |
enabled in the smalltalk system, for true to be returned." |
|
882 |
||
883 |
^ hasXVideoExtension |
|
884 |
||
885 |
" |
|
886 |
Display hasXVideo |
|
887 |
" |
|
888 |
! |
|
889 |
||
890 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
891 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 892 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 893 |
|
894 |
|xIconSizes count ret| |
|
895 |
||
896 |
%{ |
|
555 | 897 |
int screen = __intVal(__INST(screen)); |
295 | 898 |
XIconSize *sizeList; |
899 |
int cnt; |
|
900 |
||
901 |
if (ISCONNECTED) { |
|
1344 | 902 |
Display *dpy = myDpy; |
903 |
||
904 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
|
905 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
906 |
count = __MKSMALLINT(cnt); |
|
907 |
} |
|
295 | 908 |
} |
909 |
%}. |
|
910 |
xIconSizes isNil ifTrue:[^ nil]. |
|
911 |
||
912 |
ret := OrderedCollection new:count. |
|
913 |
1 to:count do:[ :i | |
|
1344 | 914 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 915 |
|
916 |
%{ |
|
1344 | 917 |
XIconSize *slp; |
918 |
||
919 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
920 |
minWidth = __MKSMALLINT(slp->min_width); |
|
921 |
minHeight = __MKSMALLINT(slp->min_height); |
|
922 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
923 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
924 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
925 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 926 |
%}. |
1344 | 927 |
d := IdentityDictionary new. |
928 |
d at:#minWidth put:minWidth. |
|
929 |
d at:#maxWidth put:maxWidth. |
|
930 |
d at:#widthStep put:widthStep. |
|
931 |
d at:#minHeight put:minHeight. |
|
932 |
d at:#maxHeight put:maxHeight. |
|
933 |
d at:#heightStep put:heightStep. |
|
934 |
||
935 |
ret add:d |
|
295 | 936 |
]. |
937 |
||
938 |
xIconSizes free. |
|
939 |
^ ret |
|
940 |
||
941 |
" |
|
819 | 942 |
Display iconSizes |
295 | 943 |
" |
944 |
! |
|
945 |
||
341 | 946 |
ignoreBackingStore:aBoolean |
947 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
948 |
no backing store used - this can be used on servers where backing store is |
|
949 |
very slow or is broken (can be put into display-rc-file)" |
|
950 |
||
951 |
ignoreBackingStore := aBoolean |
|
295 | 952 |
! |
953 |
||
823 | 954 |
preferredIconSize |
955 |
"return the displays preferred size for icons. |
|
956 |
Redefined to return a special value on SGI servers." |
|
957 |
||
958 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
1344 | 959 |
^ 86@68 |
823 | 960 |
]. |
961 |
^ super preferredIconSize |
|
962 |
||
963 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
964 |
! |
|
965 |
||
1025 | 966 |
scrollsAsynchronous |
1008
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
967 |
"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
|
968 |
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
|
969 |
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
|
970 |
|
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
971 |
^ true |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
972 |
! |
ca0a38a11bdc
support (prepared) for devices which do not send asynchronous exposes
Claus Gittinger <cg@exept.de>
parents:
995
diff
changeset
|
973 |
|
43 | 974 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
975 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
976 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
977 |
depth, bitsPerPixel and padding values." |
43 | 978 |
|
150 | 979 |
|nFormats "{ Class: SmallInteger }" |
980 |
formatArray| |
|
43 | 981 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
982 |
Display *dpy; |
150 | 983 |
|
984 |
if (! ISCONNECTED) { |
|
1344 | 985 |
RETURN (nil); |
150 | 986 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
987 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
988 |
dpy = myDpy; |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
989 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 990 |
%}. |
991 |
formatArray := Array new:nFormats. |
|
150 | 992 |
1 to:nFormats do:[:index | |
1344 | 993 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
994 |
||
995 |
i := index. |
|
43 | 996 |
%{ |
1344 | 997 |
ScreenFormat *format; |
998 |
Display *dpy = myDpy; |
|
999 |
||
1000 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
|
1001 |
format += (__intVal(i)-1); |
|
1002 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
|
1003 |
depthInfo = __MKSMALLINT(format->depth); |
|
1004 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
|
43 | 1005 |
%}. |
1344 | 1006 |
info := IdentityDictionary new. |
1007 |
info at:#depth put:depthInfo. |
|
1008 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
|
1009 |
info at:#padding put:paddingInfo. |
|
1010 |
formatArray at:index put:info. |
|
43 | 1011 |
]. |
1012 |
^ formatArray |
|
1013 |
||
1014 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
1015 |
Display supportedImageFormats |
43 | 1016 |
" |
1017 |
! |
|
1018 |
||
823 | 1019 |
supportsIconViews |
1020 |
"return true, if this device supports views as icons. |
|
1021 |
Only Xservers (currently) support this." |
|
1022 |
||
1023 |
^ true |
|
1024 |
||
1025 |
" |
|
1026 |
Display supportsIconViews |
|
1027 |
" |
|
1028 |
||
1029 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
1030 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
1031 |
! |
|
1032 |
||
81 | 1033 |
supportsViewGravity |
1034 |
"return true, if this device supports gravity attributes. |
|
82 | 1035 |
We do not depend on it being implemented, but some resizing operations |
81 | 1036 |
are faster, it is is." |
1037 |
||
1038 |
^ true |
|
0 | 1039 |
! ! |
1040 |
||
1041 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
1042 |
||
295 | 1043 |
createBitmapFromArray:anArray width:w height:h |
1044 |
|bitmapId| |
|
1045 |
||
1046 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
1047 |
bitmapId isNil ifTrue:[ |
|
1344 | 1048 |
self primitiveFailed |
295 | 1049 |
]. |
1050 |
^ bitmapId |
|
1051 |
! |
|
1052 |
||
1053 |
createBitmapFromFile:aString for:aForm |
|
1054 |
|id w h| |
|
1055 |
||
1056 |
%{ |
|
555 | 1057 |
int screen = __intVal(__INST(screen)); |
295 | 1058 |
Pixmap newBitmap; |
1059 |
char *filename; |
|
1060 |
unsigned b_width, b_height; |
|
1061 |
int b_x_hot, b_y_hot; |
|
1062 |
int status; |
|
1063 |
||
1064 |
if (ISCONNECTED) { |
|
1344 | 1065 |
Display *dpy = myDpy; |
1066 |
||
1067 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1068 |
filename = (char *)_stringVal(aString); |
|
1069 |
||
1070 |
BEGIN_INTERRUPTSBLOCKED |
|
1071 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1072 |
filename, &b_width, &b_height, &newBitmap, |
|
1073 |
&b_x_hot, &b_y_hot); |
|
1074 |
END_INTERRUPTSBLOCKED |
|
1075 |
||
1076 |
if ((status == BitmapSuccess) && newBitmap) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1077 |
#ifdef COUNT_RESOURCES |
1344 | 1078 |
__cnt_bitmap++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1079 |
#endif |
1344 | 1080 |
w = __MKSMALLINT(b_width); |
1081 |
h = __MKSMALLINT(b_height); |
|
1082 |
id = __MKOBJ(newBitmap); |
|
1083 |
} |
|
1084 |
} |
|
295 | 1085 |
} |
1086 |
%}. |
|
1087 |
id notNil ifTrue:[ |
|
1344 | 1088 |
aForm setWidth:w height:h |
295 | 1089 |
]. |
1090 |
^ id |
|
1091 |
! |
|
1092 |
||
1093 |
createBitmapWidth:w height:h |
|
1094 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1095 |
(i.e. random). Return a bitmap id or nil" |
|
1096 |
||
1097 |
%{ /* NOCONTEXT */ |
|
1098 |
||
555 | 1099 |
int screen = __intVal(__INST(screen)); |
295 | 1100 |
Pixmap newBitmap; |
1101 |
||
1102 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1344 | 1103 |
Display *dpy = myDpy; |
1104 |
||
1105 |
BEGIN_INTERRUPTSBLOCKED |
|
1106 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1107 |
__intVal(w), __intVal(h), 1); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1108 |
#ifdef COUNT_RESOURCES |
1344 | 1109 |
if (newBitmap) |
1110 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1111 |
#endif |
1344 | 1112 |
END_INTERRUPTSBLOCKED |
1113 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
295 | 1114 |
} |
1115 |
%} |
|
1116 |
. |
|
1117 |
self primitiveFailed. |
|
1118 |
^ nil |
|
1119 |
! |
|
1120 |
||
0 | 1121 |
createPixmapWidth:w height:h depth:d |
1122 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1123 |
(i.e. random). Return a bitmap id or nil" |
|
1124 |
||
1125 |
%{ /* NOCONTEXT */ |
|
1126 |
||
555 | 1127 |
int screen = __intVal(__INST(screen)); |
0 | 1128 |
Pixmap newBitmap; |
1129 |
||
150 | 1130 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
1344 | 1131 |
Display *dpy = myDpy; |
1132 |
||
1133 |
BEGIN_INTERRUPTSBLOCKED |
|
1134 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
1135 |
__intVal(w), __intVal(h), __intVal(d)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1136 |
#ifdef COUNT_RESOURCES |
1344 | 1137 |
if (newBitmap) |
1138 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1139 |
#endif |
1344 | 1140 |
END_INTERRUPTSBLOCKED |
1141 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1142 |
} |
1143 |
%} |
|
1144 |
. |
|
43 | 1145 |
self primitiveFailed. |
1146 |
^ nil |
|
0 | 1147 |
! |
1148 |
||
1149 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1150 |
"will vanish - for compatibility with previous versions" |
1151 |
||
1152 |
^ self |
|
1344 | 1153 |
createWindowFor:aView |
1154 |
origin:(xpos @ ypos) |
|
1155 |
extent:(wwidth @ wheight) |
|
1156 |
minExtent:(aView minExtent) |
|
1157 |
maxExtent:(aView maxExtent) |
|
1158 |
borderWidth:(aView borderWidth) |
|
1159 |
subViewOf:(aView superView) |
|
1160 |
onTop:(aView isPopUpView) |
|
1161 |
inputOnly:(aView isInputOnly) |
|
1162 |
label:(aView label) |
|
1163 |
cursor:(aView cursor) |
|
1164 |
icon:(aView icon) |
|
1165 |
iconView:(aView iconView) |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1166 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1167 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1168 |
! |
1169 |
||
1170 |
createWindowFor:aView |
|
1344 | 1171 |
origin:origin |
1172 |
extent:extent |
|
1173 |
minExtent:minExt |
|
1174 |
maxExtent:maxExt |
|
1175 |
borderWidth:bWidth |
|
1176 |
subViewOf:wsuperView |
|
1177 |
onTop:wisPopUpView |
|
1178 |
inputOnly:winputOnly |
|
1179 |
label:wlabel |
|
1180 |
cursor:wcursor |
|
1181 |
icon:wicon |
|
1182 |
iconView:wiconView |
|
46 | 1183 |
|
1184 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1185 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1186 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1187 |
vBgForm deepForm preferredVisual preferredDepth| |
1188 |
||
1189 |
displayId isNil ifTrue:[ |
|
1344 | 1190 |
self primitiveFailed. |
1191 |
^ nil |
|
150 | 1192 |
]. |
0 | 1193 |
|
46 | 1194 |
origin notNil ifTrue:[ |
1344 | 1195 |
xpos := origin x. |
1196 |
ypos := origin y. |
|
46 | 1197 |
] ifFalse:[ |
1344 | 1198 |
xpos := ypos := 0. |
0 | 1199 |
]. |
46 | 1200 |
extent notNil ifTrue:[ |
1344 | 1201 |
wwidth := extent x. |
1202 |
wheight := extent y. |
|
46 | 1203 |
] ifFalse:[ |
1344 | 1204 |
wwidth := wheight := 100. |
46 | 1205 |
]. |
1206 |
minExt notNil ifTrue:[ |
|
1344 | 1207 |
minWidth := minExt x. |
1208 |
minHeight := minExt y |
|
0 | 1209 |
]. |
46 | 1210 |
maxExt notNil ifTrue:[ |
1344 | 1211 |
maxWidth := maxExt x. |
1212 |
maxHeight := maxExt y |
|
46 | 1213 |
]. |
1214 |
||
0 | 1215 |
wsuperView notNil ifTrue:[ |
1344 | 1216 |
wsuperViewId := wsuperView id |
0 | 1217 |
]. |
1218 |
wcursor isNil ifTrue:[ |
|
1344 | 1219 |
'XWorkstation [info]: cursor nil - defaulted' infoPrintCR |
0 | 1220 |
] ifFalse:[ |
1344 | 1221 |
wcursorId := wcursor id |
0 | 1222 |
]. |
1223 |
||
1224 |
wicon notNil ifTrue:[ |
|
1344 | 1225 |
wiconId := wicon id |
0 | 1226 |
]. |
1227 |
wiconView notNil ifTrue:[ |
|
1344 | 1228 |
wiconViewId := wiconView id |
0 | 1229 |
]. |
1230 |
weventMask := aView eventMask. |
|
1231 |
||
150 | 1232 |
preferredVisual := aView preferredVisual. |
1233 |
preferredDepth := aView preferredDepth. |
|
23 | 1234 |
|
72 | 1235 |
%{ /* STACK:16000 */ |
0 | 1236 |
Display *dpy = myDpy; |
555 | 1237 |
int screen = __intVal(__INST(screen)); |
0 | 1238 |
Visual visual; |
1239 |
XGCValues xgcv; |
|
1240 |
XSetWindowAttributes xswa; |
|
1241 |
XSizeHints sizehints; |
|
1242 |
XWMHints wmhints; |
|
46 | 1243 |
int bw, bd, bg; |
0 | 1244 |
Window newWindow, parentWindow; |
1245 |
char *windowName; |
|
1246 |
XFontStruct *f; |
|
1247 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1248 |
int flags = 0, depth, ioClass; |
|
1249 |
Window iconWindow; |
|
1250 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1251 |
Atom WmQuitAppAtom; |
|
1252 |
Atom atoms[3]; |
|
1253 |
int atomCount = 0, isTopWindow = 0; |
|
1254 |
||
1255 |
sizehints.flags = 0; |
|
1256 |
sizehints.width = 100; |
|
1257 |
sizehints.height = 100; |
|
1258 |
sizehints.x = 0; |
|
1259 |
sizehints.y = 0; |
|
1260 |
||
97 | 1261 |
if (__bothSmallInteger(wwidth, wheight)) { |
1344 | 1262 |
sizehints.flags |= PSize; |
1263 |
sizehints.width = __intVal(wwidth); |
|
1264 |
sizehints.height = __intVal(wheight); |
|
0 | 1265 |
} |
97 | 1266 |
if (__bothSmallInteger(xpos, ypos)) { |
1344 | 1267 |
sizehints.flags |= PPosition; |
1268 |
sizehints.x = __intVal(xpos); |
|
1269 |
sizehints.y = __intVal(ypos); |
|
0 | 1270 |
} |
97 | 1271 |
if (__bothSmallInteger(minWidth, minHeight)) { |
1344 | 1272 |
sizehints.flags |= PMinSize; |
1273 |
sizehints.min_width = __intVal(minWidth); |
|
1274 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1275 |
} |
97 | 1276 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
1344 | 1277 |
sizehints.flags |= PMaxSize; |
1278 |
sizehints.max_width = __intVal(maxWidth); |
|
1279 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1280 |
} |
1281 |
||
37 | 1282 |
bg = WhitePixel(dpy, screen); |
0 | 1283 |
|
97 | 1284 |
if (__isSmallInteger(bWidth)) { |
1344 | 1285 |
bw = __intVal(bWidth); |
46 | 1286 |
} else { |
1344 | 1287 |
bw = 0; |
0 | 1288 |
} |
1289 |
||
72 | 1290 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1291 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1292 |
if (__isExternalAddress(wsuperViewId)) { |
1344 | 1293 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1294 |
} else { |
1344 | 1295 |
parentWindow = RootWindow(dpy, screen); |
1296 |
isTopWindow = 1; |
|
0 | 1297 |
} |
1298 |
||
157 | 1299 |
if (wisPopUpView == true) |
1344 | 1300 |
xswa.override_redirect = 1; |
0 | 1301 |
else |
1344 | 1302 |
xswa.override_redirect = 0; |
0 | 1303 |
|
1304 |
if (winputOnly == true) |
|
1344 | 1305 |
ioClass = InputOnly; |
0 | 1306 |
else |
1344 | 1307 |
ioClass = InputOutput; |
0 | 1308 |
|
97 | 1309 |
if (__isSmallInteger(weventMask)) { |
1344 | 1310 |
xswa.event_mask = __intVal(weventMask); |
0 | 1311 |
} else { |
1344 | 1312 |
xswa.event_mask = 0; |
0 | 1313 |
} |
1314 |
||
1315 |
if (ioClass == InputOnly) { |
|
1344 | 1316 |
bw = 0; |
1317 |
depth = 0; |
|
1318 |
flags |= CWEventMask; |
|
0 | 1319 |
} else { |
1344 | 1320 |
depth = DefaultDepth(dpy,screen); |
1321 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1322 |
||
1323 |
if (backPixmap != (Pixmap)0) { |
|
1324 |
xswa.background_pixmap = backPixmap; |
|
1325 |
flags |= CWBackPixmap; |
|
1326 |
} else { |
|
1327 |
xswa.background_pixel = bg; |
|
1328 |
flags |= CWBackPixel; |
|
1329 |
} |
|
1330 |
xswa.border_pixel = bd; |
|
0 | 1331 |
} |
23 | 1332 |
|
0 | 1333 |
visual.visualid = CopyFromParent; |
150 | 1334 |
if (__isSmallInteger(preferredDepth)) { |
1344 | 1335 |
depth = __intVal(preferredDepth); |
23 | 1336 |
} |
54 | 1337 |
|
1338 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1339 |
if (preferredVisual != nil) { |
1344 | 1340 |
XVisualInfo vi; |
1341 |
int cls; |
|
1342 |
||
1343 |
if (preferredVisual == @symbol(StaticGray)) |
|
1344 |
cls = StaticGray; |
|
1345 |
else if (preferredVisual == @symbol(GrayScale)) |
|
1346 |
cls = GrayScale; |
|
1347 |
else if (preferredVisual == @symbol(StaticColor)) |
|
1348 |
cls = StaticColor; |
|
1349 |
else if (preferredVisual == @symbol(PseudoColor)) |
|
1350 |
cls = PseudoColor; |
|
1351 |
else if (preferredVisual == @symbol(TrueColor)) |
|
1352 |
cls = TrueColor; |
|
1353 |
else if (preferredVisual == @symbol(DirectColor)) |
|
1354 |
cls = DirectColor; |
|
1355 |
else |
|
1356 |
cls = PseudoColor; |
|
1357 |
||
1358 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
|
1359 |
visual.visualid = vi.visualid; |
|
163 | 1360 |
/* |
1344 | 1361 |
printf("visualId=%x\n", vi.visualid); |
163 | 1362 |
*/ |
1344 | 1363 |
} |
23 | 1364 |
} |
0 | 1365 |
|
1366 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
1344 | 1367 |
sizehints.x, sizehints.y, |
1368 |
sizehints.width, sizehints.height, |
|
1369 |
bw, depth, ioClass, &visual, |
|
1370 |
flags, &xswa); |
|
54 | 1371 |
END_INTERRUPTSBLOCKED |
0 | 1372 |
|
1373 |
if (! newWindow) { |
|
1344 | 1374 |
RETURN ( nil ); |
0 | 1375 |
} |
1376 |
||
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1377 |
#ifdef COUNT_RESOURCES |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1378 |
__cnt_view++; |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1379 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1380 |
|
54 | 1381 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1382 |
/* |
1383 |
* define its cursor |
|
1384 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1385 |
if (__isExternalAddress(wcursorId)) { |
1344 | 1386 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1387 |
} |
1388 |
||
1389 |
/* |
|
1390 |
* define its icon and name |
|
1391 |
* (only makes sense for topWindows) |
|
1392 |
*/ |
|
1393 |
if (isTopWindow) { |
|
1344 | 1394 |
if (__isExternalAddress(wiconId)) |
1395 |
iconBitmap = _PixmapVal(wiconId); |
|
1396 |
else |
|
1397 |
iconBitmap = (Pixmap)0; |
|
1398 |
||
1399 |
if (__isExternalAddress(wiconViewId)) |
|
1400 |
iconWindow = _WindowVal(wiconViewId); |
|
1401 |
else |
|
1402 |
iconWindow = (Window)0; |
|
1403 |
||
1404 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1405 |
windowName = (char *)_stringVal(wlabel); |
|
1406 |
else |
|
1407 |
windowName = ""; |
|
1408 |
||
1409 |
if (iconBitmap || windowName) { |
|
1410 |
XSetStandardProperties(dpy, newWindow, |
|
1411 |
windowName, windowName, |
|
1412 |
iconBitmap, |
|
1413 |
0, 0, &sizehints); |
|
1414 |
||
1415 |
} |
|
1416 |
||
1417 |
wmhints.flags = 0; |
|
1418 |
if (iconBitmap) { |
|
1419 |
wmhints.flags |= IconPixmapHint; |
|
1420 |
wmhints.icon_pixmap = iconBitmap; |
|
1421 |
} |
|
1422 |
if (iconWindow) { |
|
1423 |
wmhints.flags |= IconWindowHint; |
|
1424 |
wmhints.icon_window = iconWindow; |
|
1425 |
} |
|
0 | 1426 |
/* |
1344 | 1427 |
wmhints.flags |= InputHint; |
1428 |
wmhints.input = True; |
|
0 | 1429 |
*/ |
1344 | 1430 |
XSetWMHints(dpy, newWindow, &wmhints); |
1431 |
||
1432 |
/* |
|
1433 |
* tell window manager to not kill us but send an event instead |
|
1434 |
*/ |
|
1435 |
/* |
|
1436 |
* get atoms first (if not already known) |
|
1437 |
*/ |
|
1438 |
if (__INST(protocolsAtom) == nil) { |
|
1439 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
|
1440 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
|
0 | 1441 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1442 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
1443 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
|
0 | 1444 |
#endif |
1445 |
#ifdef USE_QUIT_APP_ATOM |
|
1344 | 1446 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
1447 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
|
0 | 1448 |
#endif |
1344 | 1449 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1450 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
|
1451 |
} else { |
|
0 | 1452 |
#ifdef USE_QUIT_APP_ATOM |
1344 | 1453 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1454 |
#else |
1344 | 1455 |
WmQuitAppAtom = 0; |
0 | 1456 |
#endif |
1344 | 1457 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1458 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1459 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1460 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1461 |
#else |
1344 | 1462 |
WmSaveYourselfAtom = 0; |
0 | 1463 |
#endif |
1344 | 1464 |
} |
1465 |
||
1466 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1467 |
#ifdef USE_SAVEYOURSELF_ATOM |
1344 | 1468 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1469 |
#endif |
1470 |
#ifdef USE_QUIT_APP_ATOM |
|
1344 | 1471 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1472 |
#endif |
1344 | 1473 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1474 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1475 |
} |
1476 |
||
54 | 1477 |
END_INTERRUPTSBLOCKED |
1478 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1479 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1480 |
%}. |
0 | 1481 |
self addKnownView:aView withId:windowId. |
1482 |
^ windowId |
|
1483 |
! |
|
1484 |
||
1485 |
destroyGC:aGCId |
|
1486 |
||
1487 |
%{ /* NOCONTEXT */ |
|
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 |
if (! ISCONNECTED) { |
1344 | 1490 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1491 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1492 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1493 |
if (__isExternalAddress(aGCId)) { |
1344 | 1494 |
GC gc = _GCVal(aGCId); |
1495 |
||
1496 |
if (gc) { |
|
1497 |
BEGIN_INTERRUPTSBLOCKED |
|
1498 |
XFreeGC(myDpy, gc); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1499 |
#ifdef COUNT_RESOURCES |
1344 | 1500 |
__cnt_gc--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1501 |
#endif |
1344 | 1502 |
END_INTERRUPTSBLOCKED |
1503 |
} |
|
1504 |
RETURN ( self ); |
|
0 | 1505 |
} |
118 | 1506 |
%}. |
0 | 1507 |
self primitiveFailed |
1508 |
! |
|
1509 |
||
295 | 1510 |
destroyPixmap:aDrawableId |
0 | 1511 |
|
1512 |
%{ /* NOCONTEXT */ |
|
1513 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1514 |
if (! ISCONNECTED) { |
1344 | 1515 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1516 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1517 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1518 |
if (__isExternalAddress(aDrawableId)) { |
1344 | 1519 |
Pixmap pix = _PixmapVal(aDrawableId); |
1520 |
||
1521 |
if (pix) { |
|
1522 |
BEGIN_INTERRUPTSBLOCKED |
|
1523 |
XFreePixmap(myDpy, pix); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1524 |
#ifdef COUNT_RESOURCES |
1344 | 1525 |
__cnt_bitmap--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1526 |
#endif |
1344 | 1527 |
END_INTERRUPTSBLOCKED |
1528 |
} |
|
1529 |
RETURN ( self ); |
|
0 | 1530 |
} |
118 | 1531 |
%}. |
295 | 1532 |
self primitiveFailed |
1533 |
! |
|
1534 |
||
1535 |
destroyView:aView withId:aWindowId |
|
1536 |
%{ |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1537 |
if (! ISCONNECTED) { |
1344 | 1538 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1539 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1540 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
1541 |
if (__isExternalAddress(aWindowId)) { |
1344 | 1542 |
Window win = _WindowVal(aWindowId); |
1543 |
||
1544 |
if (win) { |
|
1545 |
BEGIN_INTERRUPTSBLOCKED |
|
1546 |
XDestroyWindow(myDpy, win); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1547 |
#ifdef COUNT_RESOURCES |
1344 | 1548 |
__cnt_view--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1549 |
#endif |
1344 | 1550 |
END_INTERRUPTSBLOCKED |
1551 |
} |
|
295 | 1552 |
} |
1553 |
%}. |
|
1554 |
self removeKnownView:aView |
|
0 | 1555 |
! |
1556 |
||
1557 |
dpsContextFor:aDrawableId and:aGCId |
|
1558 |
||
1559 |
%{ /* NOCONTEXT */ |
|
1560 |
#ifdef XXDPS |
|
555 | 1561 |
int screen = __intVal(__INST(screen)); |
0 | 1562 |
DPSContext dps; |
1563 |
int height; |
|
1564 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1565 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1566 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1567 |
&& ISCONNECTED) { |
1344 | 1568 |
BEGIN_INTERRUPTSBLOCKED |
1569 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1570 |
_GCVal(aGCId), |
|
1571 |
0, height, 0, colormap, NULL, 0, |
|
1572 |
XDPSDefaultTextBackstop, |
|
1573 |
XDPSDefaultErrorProc, |
|
1574 |
NULL); |
|
1575 |
END_INTERRUPTSBLOCKED |
|
1576 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
|
0 | 1577 |
} |
1578 |
#endif |
|
1579 |
%} |
|
1580 |
. |
|
43 | 1581 |
self primitiveFailed. |
1582 |
^ nil |
|
295 | 1583 |
! |
1584 |
||
1585 |
gcFor:aDrawableId |
|
132 | 1586 |
|
1587 |
%{ /* NOCONTEXT */ |
|
555 | 1588 |
int screen = __intVal(__INST(screen)); |
295 | 1589 |
GC gc; |
1590 |
||
1591 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1344 | 1592 |
BEGIN_INTERRUPTSBLOCKED |
1593 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1594 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1595 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1596 |
#ifdef COUNT_RESOURCES |
1344 | 1597 |
if (gc) |
1598 |
__cnt_gc++; |
|
1089 | 1599 |
#endif |
1600 |
||
1344 | 1601 |
END_INTERRUPTSBLOCKED |
1602 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1603 |
} |
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 |
self primitiveFailed. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1606 |
^ nil |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1607 |
! |
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 |
gcForBitmap:aDrawableId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1610 |
"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
|
1611 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1612 |
%{ /* NOCONTEXT */ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1613 |
int screen = __intVal(__INST(screen)); |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1614 |
GC gc; |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1615 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1616 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
1344 | 1617 |
BEGIN_INTERRUPTSBLOCKED |
1618 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1619 |
0L, (XGCValues *)0); |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1103
diff
changeset
|
1620 |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1621 |
#ifdef COUNT_RESOURCES |
1344 | 1622 |
if (gc) |
1623 |
__cnt_gc++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1624 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1625 |
|
1344 | 1626 |
END_INTERRUPTSBLOCKED |
1627 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1628 |
} |
1629 |
%}. |
|
1630 |
self primitiveFailed. |
|
1631 |
^ nil |
|
295 | 1632 |
! |
1633 |
||
1634 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1635 |
|
1636 |
%{ /* UNLIMITEDSTACK */ |
|
1637 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1638 |
Display *dpy; |
555 | 1639 |
int screen = __intVal(__INST(screen)); |
295 | 1640 |
Pixmap newBitmap; |
1641 |
unsigned int b_width, b_height; |
|
1642 |
REGISTER unsigned char *cp; |
|
1643 |
REGISTER unsigned char *pBits; |
|
1644 |
unsigned char *b_bits, *allocatedBits; |
|
1645 |
int index, row; |
|
1646 |
REGISTER int col; |
|
1647 |
unsigned bits; |
|
1648 |
static char reverseBitTable[256]; |
|
1649 |
static firstCall = 1; |
|
1650 |
int nBytes; |
|
1651 |
unsigned char fastBits[10000]; |
|
1652 |
OBJ num, *op; |
|
1653 |
int bytesPerRow; |
|
1654 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1655 |
if (! ISCONNECTED) { |
1344 | 1656 |
RETURN (nil); |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1657 |
} |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1658 |
|
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1659 |
dpy = myDpy; |
295 | 1660 |
if (firstCall) { |
1344 | 1661 |
for (index=0; index < 256; index++) { |
1662 |
reverseBitTable[index] = 0; |
|
1663 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1664 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1665 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1666 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1667 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1668 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1669 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1670 |
if (index & 1) reverseBitTable[index] |= 128; |
|
1671 |
} |
|
1672 |
firstCall = 0; |
|
295 | 1673 |
} |
1674 |
||
1675 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
1344 | 1676 |
newBitmap = (Pixmap)0; |
1677 |
b_width = __intVal(w); |
|
1678 |
b_height = __intVal(h); |
|
1679 |
bytesPerRow = (b_width + 7) / 8; |
|
1680 |
nBytes = b_height * bytesPerRow; |
|
1681 |
if (nBytes < sizeof(fastBits)) { |
|
1682 |
cp = b_bits = fastBits; |
|
1683 |
allocatedBits = 0; |
|
1684 |
} else { |
|
1685 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1686 |
if (! cp) goto fail; |
|
1687 |
} |
|
1688 |
||
1689 |
if (__qClass(anArray) == @global(Array)) { |
|
1690 |
index = 1; |
|
1691 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
1692 |
for (row = b_height; row; row--) { |
|
1693 |
for (col = bytesPerRow; col; col--) { |
|
1694 |
num = *op++; |
|
1695 |
if (! __isSmallInteger(num)) goto fail; |
|
1696 |
bits = __intVal(num); |
|
1697 |
*cp++ = reverseBitTable[bits]; |
|
1698 |
} |
|
1699 |
} |
|
1700 |
} else { |
|
1701 |
if (__qClass(anArray) == @global(ByteArray)) { |
|
1702 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
1703 |
for (col = b_height*bytesPerRow; col; col--) { |
|
1704 |
*cp++ = reverseBitTable[*pBits++]; |
|
1705 |
} |
|
1706 |
} else { |
|
1707 |
goto fail; |
|
1708 |
} |
|
1709 |
} |
|
1710 |
||
1711 |
BEGIN_INTERRUPTSBLOCKED |
|
1712 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1713 |
(char *)b_bits, |
|
1714 |
b_width, b_height); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1715 |
#ifdef COUNT_RESOURCES |
1344 | 1716 |
if (newBitmap) |
1717 |
__cnt_bitmap++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1718 |
#endif |
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1719 |
|
1344 | 1720 |
END_INTERRUPTSBLOCKED |
295 | 1721 |
fail: ; |
1344 | 1722 |
if (allocatedBits) |
1723 |
free(allocatedBits); |
|
1724 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1725 |
} |
1726 |
%} |
|
295 | 1727 |
! |
1728 |
||
1729 |
realRootWindowFor:aView |
|
1730 |
"the name of this method is historic; |
|
1731 |
- it will vanish" |
|
1732 |
||
1733 |
|id| |
|
1734 |
||
1735 |
id := self realRootWindowId. |
|
1736 |
self addKnownView:aView withId:id. |
|
1737 |
^ id |
|
1738 |
! |
|
1739 |
||
1740 |
realRootWindowId |
|
1741 |
"return the id of the real root window. |
|
1742 |
This may not be the window you see as background, |
|
1743 |
since some window managers install a virtual root window on top |
|
1744 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1745 |
care of any virtual root." |
|
0 | 1746 |
|
1747 |
%{ /* NOCONTEXT */ |
|
1748 |
||
555 | 1749 |
int screen = __intVal(__INST(screen)); |
295 | 1750 |
Window root; |
1751 |
OBJ id; |
|
1752 |
||
555 | 1753 |
if (__INST(rootId) != nil) { |
1344 | 1754 |
RETURN (__INST(rootId)); |
295 | 1755 |
} |
0 | 1756 |
|
150 | 1757 |
if (ISCONNECTED) { |
1344 | 1758 |
root = RootWindow(myDpy, screen); |
1759 |
if (! root) { |
|
1760 |
id = nil; |
|
1761 |
} else { |
|
1762 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
|
1763 |
} |
|
1764 |
RETURN (id); |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1765 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1766 |
%}. |
295 | 1767 |
self primitiveFailed |
1768 |
! |
|
1769 |
||
1770 |
rootWindowFor:aView |
|
1771 |
|id| |
|
1772 |
||
1773 |
id := self rootWindowId. |
|
1774 |
self addKnownView:aView withId:id. |
|
0 | 1775 |
^ id |
1776 |
! |
|
1777 |
||
295 | 1778 |
rootWindowId |
1779 |
"return the id of the root window. |
|
1780 |
This is the window you see as background, |
|
1781 |
however, it may or may not be the real physical root window, |
|
1782 |
since some window managers install a virtual root window on top |
|
1783 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1784 |
|
0 | 1785 |
%{ /* NOCONTEXT */ |
555 | 1786 |
int screen = __intVal(__INST(screen)); |
295 | 1787 |
Window rootWin, vRootWin; |
1788 |
OBJ id; |
|
1789 |
||
555 | 1790 |
if (__INST(virtualRootId) != nil) { |
1344 | 1791 |
RETURN (__INST(virtualRootId)); |
295 | 1792 |
} |
0 | 1793 |
|
169 | 1794 |
if (ISCONNECTED) { |
1344 | 1795 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
295 | 1796 |
#ifndef IRIS |
1344 | 1797 |
BEGIN_INTERRUPTSBLOCKED |
1798 |
/* |
|
1799 |
* on IRIS, this creates a badwindow error - why ? |
|
1800 |
* children contains a funny window (000034) |
|
1801 |
*/ |
|
1802 |
||
1803 |
/* |
|
1804 |
* care for virtual root windows (tvtwm & friends) |
|
1805 |
*/ |
|
1806 |
{ |
|
1807 |
Atom vRootAtom = None; |
|
1808 |
int i; |
|
1809 |
Window rootReturn, parentReturn; |
|
1810 |
Window* children = (Window *)0; |
|
1811 |
unsigned int numChildren; |
|
1812 |
||
1813 |
if (XQueryTree(myDpy, rootWin, |
|
1814 |
&rootReturn, &parentReturn, |
|
1815 |
&children, &numChildren)) { |
|
1816 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1817 |
if (vRootAtom != None) { |
|
1818 |
for (i=0; i < numChildren; i++) { |
|
1819 |
Atom actual_type; |
|
1820 |
int actual_format; |
|
1821 |
unsigned long nitems, bytesafter; |
|
1822 |
Window* newRoot = (Window*) 0; |
|
1823 |
||
1824 |
if (children[i]) { |
|
1825 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1826 |
0L, 1L, False, XA_WINDOW, |
|
1827 |
&actual_type, &actual_format, |
|
1828 |
&nitems, &bytesafter, |
|
1829 |
(unsigned char**) &newRoot |
|
1830 |
) == Success && newRoot) { |
|
1831 |
vRootWin = *newRoot; |
|
1832 |
XFree(newRoot); /* XXX */ |
|
1833 |
break; |
|
1834 |
} |
|
1835 |
} |
|
1836 |
} |
|
1837 |
} |
|
1838 |
if (children) XFree( children ); |
|
1839 |
} |
|
1840 |
} |
|
1841 |
END_INTERRUPTSBLOCKED |
|
295 | 1842 |
#endif |
1843 |
} |
|
1844 |
||
1845 |
/* cannot happen */ |
|
1846 |
if (! vRootWin) { |
|
1344 | 1847 |
vRootWin = rootWin; |
1848 |
if (! rootWin) { |
|
1849 |
RETURN ( nil ); |
|
1850 |
} |
|
295 | 1851 |
} |
555 | 1852 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1853 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1854 |
RETURN ( id ); |
63 | 1855 |
%} |
0 | 1856 |
! ! |
1857 |
||
1858 |
!XWorkstation methodsFor:'color stuff'! |
|
1859 |
||
295 | 1860 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1861 |
"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
|
1862 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1863 |
|
1864 |
%{ /* NOCONTEXT */ |
|
1865 |
||
555 | 1866 |
int screen = __intVal(__INST(screen)); |
295 | 1867 |
XColor color; |
1868 |
unsigned long dummy; |
|
1869 |
Status ok; |
|
1870 |
||
1209 | 1871 |
if (ISCONNECTED) { |
1344 | 1872 |
Display *dpy = myDpy; |
1873 |
||
1874 |
BEGIN_INTERRUPTSBLOCKED |
|
1875 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1876 |
&dummy, 0, &color.pixel, 1); |
|
1877 |
END_INTERRUPTSBLOCKED |
|
1878 |
if (ok) { |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1879 |
#ifdef COUNT_RESOURCES |
1344 | 1880 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1881 |
#endif |
1344 | 1882 |
RETURN ( __MKSMALLINT(color.pixel) ); |
1883 |
} |
|
0 | 1884 |
} |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1885 |
%}. |
43 | 1886 |
^ nil |
0 | 1887 |
! |
1888 |
||
1889 |
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
|
1890 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1891 |
Dont use this method, colornames are mostly X specific" |
1892 |
||
1893 |
%{ /* NOCONTEXT */ |
|
1894 |
||
1895 |
char *colorname; |
|
1896 |
XColor scolor, ecolor; |
|
555 | 1897 |
int screen = __intVal(__INST(screen)); |
850 | 1898 |
int id; |
54 | 1899 |
Status ok; |
0 | 1900 |
|
150 | 1901 |
if (ISCONNECTED) { |
1344 | 1902 |
Display *dpy = myDpy; |
1903 |
||
1904 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1905 |
colorname = (char *)_stringVal(aString); |
|
1906 |
||
1907 |
BEGIN_INTERRUPTSBLOCKED |
|
1908 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1909 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1910 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1911 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1912 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1913 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1914 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1915 |
RETURN ( __MKSMALLINT(id) ); |
|
1916 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1917 |
#endif |
1344 | 1918 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1919 |
} |
|
1920 |
END_INTERRUPTSBLOCKED |
|
1921 |
if (! ok) { |
|
1922 |
RETURN ( nil ); |
|
1923 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1924 |
#ifdef COUNT_RESOURCES |
1344 | 1925 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1926 |
#endif |
1344 | 1927 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
1928 |
} |
|
0 | 1929 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1930 |
%}. |
43 | 1931 |
self primitiveFailed. |
1932 |
^ nil |
|
0 | 1933 |
! |
1934 |
||
295 | 1935 |
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
|
1936 |
"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
|
1937 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1938 |
|
1939 |
|r g b| |
|
1940 |
||
1941 |
r := self percentToXColorValue:redVal. |
|
1942 |
g := self percentToXColorValue:greenVal. |
|
1943 |
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
|
1944 |
^ 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
|
1945 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1946 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1947 |
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
|
1948 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1949 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1950 |
Display *dpy; |
295 | 1951 |
XColor ecolor; |
555 | 1952 |
int screen = __intVal(__INST(screen)); |
295 | 1953 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1954 |
int id; |
295 | 1955 |
|
1956 |
if (__bothSmallInteger(r, g) |
|
1957 |
&& __isSmallInteger(b) |
|
1958 |
&& ISCONNECTED) { |
|
1344 | 1959 |
ecolor.red = __intVal(r); |
1960 |
ecolor.green= __intVal(g); |
|
1961 |
ecolor.blue = __intVal(b); |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1962 |
#ifdef QUICK_TRUE_COLORS |
1344 | 1963 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1964 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1965 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1966 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1967 |
RETURN ( __MKSMALLINT(id) ); |
|
1968 |
} |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1969 |
#endif |
1344 | 1970 |
dpy = myDpy; |
1971 |
BEGIN_INTERRUPTSBLOCKED |
|
1972 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1973 |
END_INTERRUPTSBLOCKED |
|
1974 |
if (! ok) { |
|
1975 |
RETURN ( nil ); |
|
1976 |
} |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1977 |
#ifdef COUNT_RESOURCES |
1344 | 1978 |
__cnt_color++; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
1979 |
#endif |
1344 | 1980 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1981 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1982 |
%}. |
295 | 1983 |
self primitiveFailed. |
1984 |
^ nil |
|
1985 |
! |
|
1986 |
||
1987 |
freeColor:colorIndex |
|
1988 |
"free a display color when its no longer needed" |
|
0 | 1989 |
|
1990 |
%{ /* NOCONTEXT */ |
|
1991 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
1992 |
Display *dpy; |
295 | 1993 |
unsigned long color; |
555 | 1994 |
int screen = __intVal(__INST(screen)); |
295 | 1995 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1996 |
#ifdef QUICK_TRUE_COLORS |
555 | 1997 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1344 | 1998 |
/* no need to do anything on TrueColor displays ... */ |
1999 |
RETURN (self); |
|
295 | 2000 |
} |
2001 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2002 |
|
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2003 |
if (! ISCONNECTED) { |
1344 | 2004 |
RETURN (self); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2005 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2006 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2007 |
if (__isSmallInteger(colorIndex)) { |
1344 | 2008 |
dpy = myDpy; |
2009 |
color = (long) __intVal(colorIndex); |
|
2010 |
BEGIN_INTERRUPTSBLOCKED |
|
2011 |
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
|
2012 |
#ifdef COUNT_RESOURCES |
1344 | 2013 |
__cnt_color--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2014 |
#endif |
1344 | 2015 |
END_INTERRUPTSBLOCKED |
2016 |
RETURN ( self ); |
|
0 | 2017 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2018 |
%}. |
295 | 2019 |
self primitiveFailed |
2020 |
! |
|
2021 |
||
2022 |
getRGBFrom:index into:aBlock |
|
2023 |
"get rgb components (0..100) of color in map at:index, |
|
2024 |
and evaluate the 3-arg block, aBlock with them" |
|
2025 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2026 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2027 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2028 |
self getScaledRGBFrom:index into:[:r :g :b | |
1344 | 2029 |
val := aBlock |
2030 |
value:(r * 100.0 / 16rFFFF) |
|
2031 |
value:(g * 100.0 / 16rFFFF) |
|
2032 |
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
|
2033 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2034 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2035 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2036 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2037 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2038 |
"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
|
2039 |
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
|
2040 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2041 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2042 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
1344 | 2043 |
r isNil ifTrue:[ |
2044 |
^ super getRGBFromName:colorName into:aBlock |
|
2045 |
]. |
|
2046 |
val := aBlock |
|
2047 |
value:(r * 100.0 / 16rFFFF) |
|
2048 |
value:(g * 100.0 / 16rFFFF) |
|
2049 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2050 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2051 |
^ val |
1056 | 2052 |
|
2053 |
"Modified: 16.9.1996 / 17:27:42 / cg" |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2054 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
2055 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2056 |
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
|
2057 |
"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
|
2058 |
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
|
2059 |
|
295 | 2060 |
|r g b| |
2061 |
%{ |
|
555 | 2062 |
int screen = __intVal(__INST(screen)); |
295 | 2063 |
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
|
2064 |
int sr, sg, sb; |
295 | 2065 |
int bits, scale, shift; |
2066 |
||
1209 | 2067 |
if (ISCONNECTED |
2068 |
&& __isSmallInteger(index)) { |
|
1344 | 2069 |
Display *dpy = myDpy; |
2070 |
||
2071 |
color.pixel = __intVal(index); |
|
2072 |
BEGIN_INTERRUPTSBLOCKED |
|
2073 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2074 |
END_INTERRUPTSBLOCKED |
|
2075 |
||
2076 |
/* |
|
2077 |
* have to compensate for an error in X ?, which does not scale |
|
2078 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2079 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2080 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2081 |
*/ |
|
2082 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2083 |
scale = (1<<bits) - 1; |
|
2084 |
shift = 16 - bits; |
|
2085 |
||
2086 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2087 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2088 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2089 |
r = __MKSMALLINT(sr); |
|
2090 |
g = __MKSMALLINT(sg); |
|
2091 |
b = __MKSMALLINT(sb); |
|
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 |
^ aBlock value:r value:g value:b |
295 | 2095 |
! |
2096 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2097 |
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
|
2098 |
"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
|
2099 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2100 |
|
2101 |
|r g b| |
|
2102 |
||
2103 |
displayId isNil ifTrue:[ |
|
1344 | 2104 |
self pimitiveFailed. |
2105 |
^ nil |
|
295 | 2106 |
]. |
2107 |
%{ |
|
555 | 2108 |
int screen = __intVal(__INST(screen)); |
295 | 2109 |
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
|
2110 |
int sr, sg, sb; |
295 | 2111 |
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
|
2112 |
int bits, scale, shift; |
295 | 2113 |
|
1209 | 2114 |
if (ISCONNECTED |
2115 |
&& __isString(colorName) || __isSymbol(colorName)) { |
|
1344 | 2116 |
Display *dpy = myDpy; |
1209 | 2117 |
|
1344 | 2118 |
BEGIN_INTERRUPTSBLOCKED |
2119 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2120 |
(char *)_stringVal(colorName), &color)) { |
|
2121 |
/* |
|
2122 |
* have to compensate for an error in X ?, which does not scale |
|
2123 |
* colors correctly if lesser than 16bits are valid in a color, |
|
2124 |
* (for example, color white on a 4bitsPerRGB server will return |
|
2125 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
2126 |
*/ |
|
2127 |
bits = __intVal(__INST(bitsPerRGB)); |
|
2128 |
scale = (1<<bits) - 1; |
|
2129 |
shift = 16 - bits; |
|
2130 |
||
2131 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
|
2132 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
|
2133 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
|
2134 |
r = __MKSMALLINT(sr); |
|
2135 |
g = __MKSMALLINT(sg); |
|
2136 |
b = __MKSMALLINT(sb); |
|
2137 |
} |
|
2138 |
END_INTERRUPTSBLOCKED |
|
295 | 2139 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2140 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2141 |
^ aBlock value:r value:g value:b |
295 | 2142 |
! |
2143 |
||
2144 |
listOfAvailableColors |
|
2145 |
"return a list of all available colornames. |
|
2146 |
This should not be used, since colornames are very |
|
2147 |
display-specific (here X-specific)." |
|
2148 |
||
2149 |
|aStream list line index colorName| |
|
2150 |
||
2151 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2152 |
aStream isNil ifTrue:[^ nil]. |
|
2153 |
list := OrderedCollection new. |
|
2154 |
[aStream atEnd] whileFalse:[ |
|
1344 | 2155 |
line := aStream nextLine. |
2156 |
line notNil ifTrue:[ |
|
2157 |
"skip the r/g/b numbers" |
|
2158 |
index := 1. |
|
2159 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2160 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2161 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2162 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2163 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2164 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2165 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2166 |
colorName := line copyFrom:index. |
|
2167 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2168 |
list add:colorName |
|
2169 |
] |
|
2170 |
] |
|
295 | 2171 |
]. |
2172 |
aStream close. |
|
2173 |
^ list sort |
|
1047 | 2174 |
|
2175 |
" |
|
2176 |
Screen current listOfAvailableColors |
|
2177 |
" |
|
2178 |
||
2179 |
"Modified: 11.9.1996 / 15:26:28 / stefan" |
|
295 | 2180 |
! |
2181 |
||
2182 |
percentToXColorValue:aPercentage |
|
2183 |
"given a color-component value in percent (0..100), return the corresponding |
|
2184 |
x-component value (0..65k) as an integer" |
|
2185 |
||
2186 |
%{ /* NOCONTEXT */ |
|
2187 |
||
2188 |
if (__isSmallInteger(aPercentage)) { |
|
1344 | 2189 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2190 |
} |
2191 |
if (__isFloat(aPercentage)) { |
|
1344 | 2192 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2193 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2194 |
%}. |
295 | 2195 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2196 |
! |
2197 |
||
892 | 2198 |
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
|
2199 |
"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
|
2200 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2201 |
|
2202 |
%{ /* NOCONTEXT */ |
|
2203 |
||
2204 |
char *colorname; |
|
2205 |
XColor color; |
|
555 | 2206 |
int screen = __intVal(__INST(screen)); |
0 | 2207 |
int r, g, b; |
2208 |
int ok = 1; |
|
2209 |
||
892 | 2210 |
if (__isSmallInteger(sred)) |
1344 | 2211 |
r = __intVal(sred); |
0 | 2212 |
else ok = 0; |
2213 |
||
892 | 2214 |
if (__isSmallInteger(sgreen)) |
1344 | 2215 |
g = __intVal(sgreen); |
0 | 2216 |
else ok = 0; |
2217 |
||
892 | 2218 |
if (__isSmallInteger(sblue)) |
1344 | 2219 |
b = __intVal(sblue); |
0 | 2220 |
else ok = 0; |
2221 |
||
1209 | 2222 |
if (ISCONNECTED |
2223 |
&& __isSmallInteger(index) && ok) { |
|
1344 | 2224 |
Display *dpy = myDpy; |
2225 |
||
2226 |
color.pixel = __intVal(index); |
|
2227 |
color.red = r; |
|
2228 |
color.green = g; |
|
2229 |
color.blue = b; |
|
2230 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2231 |
||
2232 |
BEGIN_INTERRUPTSBLOCKED |
|
2233 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2234 |
END_INTERRUPTSBLOCKED |
|
2235 |
RETURN ( self ); |
|
0 | 2236 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2237 |
%}. |
0 | 2238 |
self primitiveFailed |
295 | 2239 |
! ! |
2240 |
||
2241 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2242 |
||
2243 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2244 |
"change a cursors colors" |
|
2245 |
||
2246 |
|fgR fgG fgB bgR bgG bgB| |
|
2247 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2248 |
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
|
2249 |
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
|
2250 |
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
|
2251 |
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
|
2252 |
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
|
2253 |
bgB := bgColor scaledBlue. |
0 | 2254 |
%{ |
295 | 2255 |
XColor fgcolor, bgcolor; |
2256 |
||
1209 | 2257 |
if (ISCONNECTED |
2258 |
&& __isExternalAddress(aCursorId) |
|
295 | 2259 |
&& __bothSmallInteger(fgG, fgB) |
2260 |
&& __bothSmallInteger(bgR, bgG) |
|
2261 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2262 |
||
1344 | 2263 |
fgcolor.red = __intVal(fgR); |
2264 |
fgcolor.green= __intVal(fgG); |
|
2265 |
fgcolor.blue = __intVal(fgB); |
|
2266 |
bgcolor.red = __intVal(bgR); |
|
2267 |
bgcolor.green= __intVal(bgG); |
|
2268 |
bgcolor.blue = __intVal(bgB); |
|
2269 |
BEGIN_INTERRUPTSBLOCKED |
|
2270 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
|
2271 |
END_INTERRUPTSBLOCKED |
|
2272 |
RETURN ( self ); |
|
72 | 2273 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2274 |
%}. |
0 | 2275 |
self primitiveFailed |
70 | 2276 |
! |
2277 |
||
295 | 2278 |
createCursorShape:aShape |
974 | 2279 |
"create a cursor given a shape-symbol. This only works |
2280 |
for a few standard cursors, and returns nil if no such cursor exists. |
|
2281 |
Always care for a fallBack, in case of a nil return." |
|
295 | 2282 |
|
2283 |
|number id| |
|
2284 |
||
2285 |
displayId isNil ifTrue:[ |
|
1344 | 2286 |
self primitiveFailed. |
2287 |
^ nil |
|
295 | 2288 |
]. |
2289 |
number := self shapeNumberFromSymbol:aShape. |
|
2290 |
%{ |
|
2291 |
Cursor newCursor; |
|
2292 |
||
1209 | 2293 |
if (ISCONNECTED |
2294 |
&& __isSmallInteger(number)) { |
|
1344 | 2295 |
BEGIN_INTERRUPTSBLOCKED |
2296 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2297 |
#ifdef COUNT_RESOURCES |
1344 | 2298 |
if (newCursor) |
2299 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2300 |
#endif |
1344 | 2301 |
END_INTERRUPTSBLOCKED |
2302 |
if (newCursor != (Cursor)0) { |
|
2303 |
id = __MKOBJ(newCursor); |
|
2304 |
} |
|
0 | 2305 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2306 |
%}. |
295 | 2307 |
^ id |
2308 |
! |
|
2309 |
||
974 | 2310 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h |
295 | 2311 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
2312 |
||
2313 |
|id sourceId maskId| |
|
2314 |
||
2315 |
displayId isNil ifTrue:[ |
|
1344 | 2316 |
self primitiveFailed. |
2317 |
^ nil |
|
295 | 2318 |
]. |
2319 |
sourceId := sourceForm id. |
|
2320 |
maskId := maskForm id. |
|
2321 |
%{ |
|
2322 |
Cursor newCursor; |
|
2323 |
XColor fgColor, bgColor; |
|
2324 |
||
1209 | 2325 |
if (ISCONNECTED |
2326 |
&& __isExternalAddress(sourceId) |
|
295 | 2327 |
&& __isExternalAddress(maskId) |
2328 |
&& __bothSmallInteger(hx, hy)) { |
|
1344 | 2329 |
fgColor.red = 0; /* fg is black */ |
2330 |
fgColor.green = 0; |
|
2331 |
fgColor.blue = 0; |
|
2332 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2333 |
bgColor.green = 0xFFFF; |
|
2334 |
bgColor.blue = 0xFFFF; |
|
2335 |
||
2336 |
BEGIN_INTERRUPTSBLOCKED |
|
2337 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2338 |
_PixmapVal(sourceId), |
|
2339 |
_PixmapVal(maskId), |
|
2340 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2341 |
#ifdef COUNT_RESOURCES |
1344 | 2342 |
if (newCursor) |
2343 |
__cnt_cursor++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2344 |
#endif |
1344 | 2345 |
END_INTERRUPTSBLOCKED |
2346 |
if (newCursor != (Cursor)0) { |
|
2347 |
id = __MKOBJ(newCursor); |
|
2348 |
} |
|
0 | 2349 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2350 |
%}. |
295 | 2351 |
^ id |
2352 |
! |
|
2353 |
||
2354 |
destroyCursor:aCursorId |
|
974 | 2355 |
"release a cursor - frees any device resources" |
0 | 2356 |
|
2357 |
%{ /* NOCONTEXT */ |
|
2358 |
||
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2359 |
if (! ISCONNECTED) { |
1344 | 2360 |
RETURN ( self ); |
1211
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2361 |
} |
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2362 |
|
06d63d128bde
allow destroy & free methods to be called even if unconnected
Claus Gittinger <cg@exept.de>
parents:
1210
diff
changeset
|
2363 |
if (__isExternalAddress(aCursorId)) { |
1344 | 2364 |
Cursor curs = _CursorVal(aCursorId); |
2365 |
||
2366 |
if (curs) { |
|
2367 |
BEGIN_INTERRUPTSBLOCKED |
|
2368 |
XFreeCursor(myDpy, curs); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2369 |
#ifdef COUNT_RESOURCES |
1344 | 2370 |
__cnt_cursor--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
2371 |
#endif |
1344 | 2372 |
END_INTERRUPTSBLOCKED |
2373 |
} |
|
2374 |
RETURN ( self ); |
|
0 | 2375 |
} |
974 | 2376 |
%}. |
0 | 2377 |
self primitiveFailed |
295 | 2378 |
! |
2379 |
||
974 | 2380 |
needDeviceFormsForCursor |
2381 |
^ true |
|
2382 |
! |
|
2383 |
||
295 | 2384 |
shapeNumberFromSymbol:shape |
974 | 2385 |
"given a shape-symbol, return the corresponding cursor-number, |
2386 |
or nil if no such standard cursor exists." |
|
295 | 2387 |
|
2388 |
"this is pure X-knowlegde - but you may easily add more" |
|
2389 |
||
2390 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2391 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2392 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2393 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2394 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2395 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2396 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2397 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2398 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2399 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2400 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2401 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2402 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2403 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2404 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2405 |
((shape == #origin) |
|
2406 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2407 |
((shape == #corner) |
|
2408 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2409 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2410 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2411 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2412 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2413 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
1183 | 2414 |
|
2415 |
"/ ('XWorkstation [info]: invalid cursorShape:' , shape printString) infoPrintNL. |
|
974 | 2416 |
^ nil |
0 | 2417 |
! ! |
2418 |
||
2419 |
!XWorkstation methodsFor:'drawing'! |
|
2420 |
||
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2421 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2422 |
"do a bit-blt; copy bits from the rectangle defined by |
2423 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2424 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2425 |
argument is not integer." |
|
0 | 2426 |
|
2427 |
%{ /* NOCONTEXT */ |
|
2428 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2429 |
GC gc; |
0 | 2430 |
Drawable source, dest; |
2431 |
||
1209 | 2432 |
if (ISCONNECTED |
2433 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2434 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2435 |
&& __isExternalAddress(destId) |
97 | 2436 |
&& __bothSmallInteger(w, h) |
2437 |
&& __bothSmallInteger(srcX, srcY) |
|
2438 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2439 |
gc = _GCVal(dstGCId); |
2440 |
source = (Drawable) _WindowVal(sourceId); |
|
2441 |
dest = (Drawable) _WindowVal(destId); |
|
2442 |
XCopyArea(myDpy, source, dest, gc, |
|
2443 |
__intVal(srcX), __intVal(srcY), |
|
2444 |
__intVal(w), __intVal(h), |
|
2445 |
__intVal(dstX), __intVal(dstY)); |
|
2446 |
RETURN ( self ); |
|
0 | 2447 |
} |
118 | 2448 |
%}. |
2449 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2450 |
or any non integer coordinate" |
|
2451 |
||
0 | 2452 |
self primitiveFailed |
2453 |
! |
|
2454 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2455 |
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
|
2456 |
"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
|
2457 |
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
|
2458 |
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
|
2459 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2460 |
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
|
2461 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2462 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2463 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2464 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2465 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2466 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2467 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2468 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2469 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2470 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2471 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2472 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2473 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2474 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2475 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2476 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2477 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2478 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2479 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2480 |
XCopyArea(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2481 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2482 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2483 |
__intVal(dstX), __intVal(dstY)); |
1344 | 2484 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2485 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2486 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2487 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2488 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2489 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2490 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2491 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2492 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2493 |
|
1030
ca9d23090688
pass srcGCId to bit-blitters (req'd on WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1025
diff
changeset
|
2494 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
118 | 2495 |
"do a bit-blt, but only copy the low-bit plane; |
2496 |
copy bits from the rectangle defined by |
|
2497 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2498 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2499 |
argument is not integer." |
|
0 | 2500 |
|
2501 |
%{ /* NOCONTEXT */ |
|
2502 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2503 |
GC gc; |
0 | 2504 |
Drawable source, dest; |
2505 |
||
1209 | 2506 |
if (ISCONNECTED |
2507 |
&& __isExternalAddress(dstGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2508 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2509 |
&& __isExternalAddress(destId) |
97 | 2510 |
&& __bothSmallInteger(w, h) |
2511 |
&& __bothSmallInteger(srcX, srcY) |
|
2512 |
&& __bothSmallInteger(dstX, dstY)) { |
|
1344 | 2513 |
gc = _GCVal(dstGCId); |
2514 |
source = (Drawable) _WindowVal(sourceId); |
|
2515 |
dest = (Drawable) _WindowVal(destId); |
|
2516 |
XCopyPlane(myDpy, source, dest, gc, |
|
2517 |
__intVal(srcX), __intVal(srcY), |
|
2518 |
__intVal(w), __intVal(h), |
|
2519 |
__intVal(dstX), __intVal(dstY), 1); |
|
2520 |
RETURN ( self ); |
|
0 | 2521 |
} |
118 | 2522 |
%}. |
2523 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2524 |
or any non integer coordinate" |
|
2525 |
||
0 | 2526 |
self primitiveFailed |
2527 |
! |
|
2528 |
||
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2529 |
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
|
2530 |
"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
|
2531 |
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
|
2532 |
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
|
2533 |
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
|
2534 |
argument is not integer. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2535 |
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
|
2536 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2537 |
%{ /* NOCONTEXT */ |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2538 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2539 |
GC gc; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2540 |
Drawable source, dest; |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2541 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2542 |
if (ISCONNECTED |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2543 |
&& __isExternalAddress(dstGCId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2544 |
&& __isExternalAddress(sourceId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2545 |
&& __isExternalAddress(destId) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2546 |
&& __bothSmallInteger(w, h) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2547 |
&& __bothSmallInteger(srcX, srcY) |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2548 |
&& __bothSmallInteger(dstX, dstY)) { |
1344 | 2549 |
Display *dpy = myDpy; |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2550 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2551 |
gc = _GCVal(dstGCId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2552 |
source = (Drawable) _WindowVal(sourceId); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2553 |
dest = (Drawable) _WindowVal(destId); |
1344 | 2554 |
XSetGraphicsExposures(dpy, gc, 0); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2555 |
XCopyPlane(dpy, source, dest, gc, |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2556 |
__intVal(srcX), __intVal(srcY), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2557 |
__intVal(w), __intVal(h), |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2558 |
__intVal(dstX), __intVal(dstY), 1); |
1344 | 2559 |
XSetGraphicsExposures(dpy, gc, 1); |
1246
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2560 |
RETURN ( self ); |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2561 |
} |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2562 |
%}. |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2563 |
"badGC, bad sourceDrawableId or destDrawableID |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2564 |
or any non integer coordinate" |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2565 |
|
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2566 |
self primitiveFailed |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2567 |
! |
f8835fc41467
added copy*FromPixmapId:* - which do not generate graphics exposures
Claus Gittinger <cg@exept.de>
parents:
1227
diff
changeset
|
2568 |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2569 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2570 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2571 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2572 |
|
2573 |
%{ /* NOCONTEXT */ |
|
2574 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2575 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2576 |
Window win; |
0 | 2577 |
int w, h, angle1, angle2; |
2578 |
double f; |
|
2579 |
||
97 | 2580 |
if (__isSmallInteger(startAngle)) |
1344 | 2581 |
angle1 = __intVal(startAngle) * 64; |
36 | 2582 |
else if (__isFloat(startAngle)) { |
1344 | 2583 |
f = __floatVal(startAngle); |
2584 |
angle1 = f * 64; |
|
0 | 2585 |
} |
97 | 2586 |
if (__isSmallInteger(angle)) |
1344 | 2587 |
angle2 = __intVal(angle) * 64; |
36 | 2588 |
else if (__isFloat(angle)) { |
1344 | 2589 |
f = __floatVal(angle); |
2590 |
angle2 = f * 64; |
|
0 | 2591 |
} |
1209 | 2592 |
if (ISCONNECTED |
2593 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2594 |
&& __isExternalAddress(aDrawableId) |
97 | 2595 |
&& __bothSmallInteger(x, y) |
2596 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2597 |
win = _WindowVal(aDrawableId); |
2598 |
gc = _GCVal(aGCId); |
|
2599 |
w = __intVal(width); |
|
2600 |
h = __intVal(height); |
|
2601 |
/* |
|
2602 |
* need this check here: some servers simply dump core with bad args |
|
2603 |
*/ |
|
2604 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2605 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2606 |
w, h, angle1, angle2); |
|
2607 |
} |
|
2608 |
RETURN ( self ); |
|
0 | 2609 |
} |
73 | 2610 |
%}. |
2611 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2612 |
self primitiveFailed |
2613 |
! |
|
2614 |
||
295 | 2615 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2616 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2617 |
||
2618 |
%{ /* NOCONTEXT */ |
|
2619 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2620 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2621 |
Window win; |
295 | 2622 |
|
1209 | 2623 |
if (ISCONNECTED |
2624 |
&& __isExternalAddress(aGCId) |
|
295 | 2625 |
&& __isExternalAddress(aDrawableId) |
2626 |
&& __bothSmallInteger(x0, y0) |
|
2627 |
&& __bothSmallInteger(x1, y1)) { |
|
1344 | 2628 |
gc = _GCVal(aGCId); |
2629 |
win = _WindowVal(aDrawableId); |
|
2630 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
|
2631 |
__intVal(x1), __intVal(y1)); |
|
2632 |
RETURN ( self ); |
|
295 | 2633 |
} |
2634 |
%}. |
|
2635 |
"badGC, badDrawable or coordinates not integer" |
|
2636 |
self primitiveFailed |
|
2637 |
! |
|
2638 |
||
2639 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2640 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2641 |
||
2642 |
%{ /* NOCONTEXT */ |
|
2643 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2644 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2645 |
Window win; |
295 | 2646 |
|
1209 | 2647 |
if (ISCONNECTED |
2648 |
&& __isExternalAddress(aGCId) |
|
295 | 2649 |
&& __isExternalAddress(aDrawableId) |
2650 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2651 |
gc = _GCVal(aGCId); |
2652 |
win = _WindowVal(aDrawableId); |
|
2653 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
|
2654 |
RETURN ( self ); |
|
295 | 2655 |
} |
2656 |
%}. |
|
2657 |
"badGC, badDrawable or x/y not integer" |
|
2658 |
self primitiveFailed |
|
2659 |
! |
|
2660 |
||
2661 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2662 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2663 |
define the polygon. |
|
2664 |
If any coordinate is not integer, an error is triggered." |
|
2665 |
||
2666 |
|numberOfPoints newPoints| |
|
2667 |
||
2668 |
numberOfPoints := aPolygon size. |
|
2669 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2670 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2671 |
Window win; |
295 | 2672 |
OBJ point, x, y; |
2673 |
int i, num; |
|
2674 |
XPoint *points; |
|
2675 |
XPoint qPoints[100]; |
|
377 | 2676 |
int mustFree = 0; |
295 | 2677 |
|
1209 | 2678 |
if (ISCONNECTED |
2679 |
&& __isExternalAddress(aGCId) |
|
295 | 2680 |
&& __isExternalAddress(aDrawableId) |
2681 |
&& __isSmallInteger(numberOfPoints)) { |
|
1344 | 2682 |
gc = _GCVal(aGCId); |
2683 |
win = _WindowVal(aDrawableId); |
|
2684 |
num = __intVal(numberOfPoints); |
|
2685 |
/* |
|
2686 |
* avoid a (slow) malloc, if the number of points is small |
|
2687 |
*/ |
|
2688 |
if (num > 100) { |
|
2689 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2690 |
if (! points) goto fail; |
|
2691 |
mustFree = 1; |
|
2692 |
} else |
|
2693 |
points = qPoints; |
|
2694 |
||
2695 |
for (i=0; i<num; i++) { |
|
2696 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2697 |
if (! __isPoint(point)) goto fail; |
|
2698 |
x = _point_X(point); |
|
2699 |
y = _point_Y(point); |
|
2700 |
if (! __bothSmallInteger(x, y)) |
|
2701 |
goto fail; |
|
2702 |
points[i].x = __intVal(x); |
|
2703 |
points[i].y = __intVal(y); |
|
2704 |
} |
|
2705 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
2706 |
if (mustFree) |
|
2707 |
free(points); |
|
2708 |
RETURN ( self ); |
|
295 | 2709 |
} |
2710 |
fail: ; |
|
377 | 2711 |
if (mustFree) |
1344 | 2712 |
free(points); |
295 | 2713 |
%}. |
2714 |
"badGC, badDrawable or coordinates not integer" |
|
2715 |
self primitiveFailed |
|
2716 |
! |
|
2717 |
||
2718 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2719 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2720 |
||
2721 |
%{ /* NOCONTEXT */ |
|
2722 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2723 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2724 |
Window win; |
295 | 2725 |
int w, h; |
2726 |
||
1209 | 2727 |
if (ISCONNECTED |
2728 |
&& __isExternalAddress(aGCId) |
|
295 | 2729 |
&& __isExternalAddress(aDrawableId) |
2730 |
&& __bothSmallInteger(x, y) |
|
2731 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 2732 |
gc = _GCVal(aGCId); |
2733 |
win = _WindowVal(aDrawableId); |
|
2734 |
w = __intVal(width); |
|
2735 |
h = __intVal(height); |
|
2736 |
/* |
|
2737 |
* need this check here: some servers simply dump core with bad args |
|
2738 |
*/ |
|
2739 |
if ((w >= 0) && (h >= 0)) { |
|
2740 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
|
2741 |
} |
|
2742 |
RETURN ( self ); |
|
295 | 2743 |
} |
2744 |
%}. |
|
2745 |
"badGC, badDrawable or coordinates not integer" |
|
2746 |
self primitiveFailed |
|
2747 |
! |
|
2748 |
||
2749 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2750 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2751 |
foreground and background characters. |
|
2752 |
If the coordinates are not integers, an error is triggered." |
|
2753 |
||
2754 |
%{ /* NOCONTEXT */ |
|
2755 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2756 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2757 |
Window win; |
295 | 2758 |
unsigned char *cp; |
2759 |
OBJ cls; |
|
2760 |
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
|
2761 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2762 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2763 |
int nInstBytes; |
295 | 2764 |
|
1209 | 2765 |
if (ISCONNECTED |
2766 |
&& __isExternalAddress(aGCId) |
|
295 | 2767 |
&& __isExternalAddress(aDrawableId) |
2768 |
&& __isNonNilObject(aString) |
|
2769 |
&& __bothSmallInteger(index1, index2) |
|
2770 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2771 |
gc = _GCVal(aGCId); |
2772 |
win = _WindowVal(aDrawableId); |
|
2773 |
cls = __qClass(aString); |
|
2774 |
||
2775 |
i1 = __intVal(index1) - 1; |
|
2776 |
if (i1 >= 0) { |
|
2777 |
i2 = __intVal(index2) - 1; |
|
2778 |
if (i2 < i1) { |
|
2779 |
RETURN (self); |
|
2780 |
} |
|
2781 |
||
2782 |
cp = _stringVal(aString); |
|
2783 |
l = i2 - i1 + 1; |
|
2784 |
||
2785 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2786 |
n = _stringSize(aString); |
|
2787 |
if (i2 < n) { |
|
2788 |
cp += i1; |
|
2789 |
if (l > 1000) l = 1000; |
|
2790 |
if (opaque == true) |
|
2791 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2792 |
else |
|
2793 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2794 |
RETURN ( self ); |
|
2795 |
} |
|
2796 |
} |
|
2797 |
||
2798 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2799 |
cp += nInstBytes; |
|
2800 |
||
2801 |
if (__isBytes(aString)) { |
|
2802 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2803 |
||
2804 |
if (i2 < n) { |
|
2805 |
cp += i1; |
|
2806 |
if (l > 1000) l = 1000; |
|
2807 |
if (opaque == true) |
|
2808 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2809 |
else |
|
2810 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2811 |
RETURN ( self ); |
|
2812 |
} |
|
2813 |
} |
|
2814 |
||
2815 |
/* TWOBYTESTRINGS */ |
|
2816 |
if (__isWords(aString)) { |
|
2817 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2818 |
||
2819 |
if (i2 < n) { |
|
2820 |
union { |
|
2821 |
char b[2]; |
|
2822 |
unsigned short s; |
|
2823 |
} u; |
|
2824 |
int i; |
|
2825 |
XChar2b *cp2 = (XChar2b *)0; |
|
2826 |
int mustFree = 0; |
|
2827 |
||
2828 |
cp += (i1 * 2); |
|
2829 |
if (l > 1000) l = 1000; |
|
2830 |
||
2831 |
/* |
|
2832 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2833 |
* X expects them MSB first |
|
2834 |
* convert as required |
|
2835 |
*/ |
|
2836 |
||
2837 |
u.s = 0x1234; |
|
2838 |
if (u.b[0] != 0x12) { |
|
2839 |
if (l <= NLOCALBUFFER) { |
|
2840 |
cp2 = xlatebuffer; |
|
2841 |
} else { |
|
2842 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2843 |
mustFree = 1; |
|
2844 |
} |
|
2845 |
for (i=0; i<l; i++) { |
|
2846 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2847 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2848 |
} |
|
2849 |
cp = (char *) cp2; |
|
2850 |
} |
|
2851 |
||
2852 |
if (opaque == true) |
|
2853 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2854 |
else |
|
2855 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2856 |
||
2857 |
if (mustFree) { |
|
2858 |
free(cp2); |
|
2859 |
} |
|
2860 |
||
2861 |
RETURN ( self ); |
|
2862 |
} |
|
2863 |
} |
|
2864 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2865 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2866 |
#undef NLOCALBUFFER |
295 | 2867 |
%}. |
2868 |
"x/y not integer, badGC or drawable, or not a string" |
|
2869 |
self primitiveFailed |
|
2870 |
! |
|
2871 |
||
2872 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2873 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2874 |
foreground and background characters. |
|
2875 |
If the coordinates are not integers, an error is triggered." |
|
2876 |
||
2877 |
%{ /* NOCONTEXT */ |
|
2878 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2879 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2880 |
Window win; |
295 | 2881 |
unsigned char *cp; |
2882 |
int n; |
|
2883 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2884 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2885 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2886 |
int nInstBytes; |
295 | 2887 |
|
1209 | 2888 |
if (ISCONNECTED |
2889 |
&& __isExternalAddress(aGCId) |
|
295 | 2890 |
&& __isExternalAddress(aDrawableId) |
2891 |
&& __isNonNilObject(aString) |
|
2892 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 2893 |
gc = _GCVal(aGCId); |
2894 |
win = _WindowVal(aDrawableId); |
|
2895 |
cls = __qClass(aString); |
|
2896 |
||
2897 |
cp = _stringVal(aString); |
|
2898 |
||
2899 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2900 |
n = _stringSize(aString); |
|
2901 |
if (n > 1000) n = 1000; |
|
2902 |
if (opaque == true) |
|
2903 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2904 |
else |
|
2905 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2906 |
RETURN ( self ); |
|
2907 |
} |
|
2908 |
||
2909 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2910 |
cp += nInstBytes; |
|
2911 |
||
2912 |
if (__isBytes(aString)) { |
|
2913 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2914 |
||
2915 |
if (n > 1000) n = 1000; |
|
2916 |
if (opaque == true) |
|
2917 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2918 |
else |
|
2919 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2920 |
RETURN ( self ); |
|
2921 |
} |
|
2922 |
||
2923 |
/* TWOBYTESTRINGS */ |
|
2924 |
if (__isWords(aString)) { |
|
2925 |
union { |
|
2926 |
char b[2]; |
|
2927 |
unsigned short s; |
|
2928 |
} u; |
|
2929 |
int i; |
|
2930 |
XChar2b *cp2; |
|
2931 |
int mustFree = 0; |
|
2932 |
||
2933 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2934 |
if (n > 1000) n = 1000; |
|
2935 |
||
2936 |
/* |
|
2937 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2938 |
* X expects them MSB first |
|
2939 |
* convert as required |
|
2940 |
*/ |
|
2941 |
||
2942 |
u.s = 0x1234; |
|
2943 |
if (u.b[0] != 0x12) { |
|
2944 |
if (n <= NLOCALBUFFER) { |
|
2945 |
cp2 = xlatebuffer; |
|
2946 |
} else { |
|
2947 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2948 |
mustFree = 1; |
|
2949 |
} |
|
2950 |
||
2951 |
for (i=0; i<n; i++) { |
|
2952 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2953 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2954 |
} |
|
2955 |
cp = (char *) cp2; |
|
2956 |
} |
|
2957 |
||
2958 |
if (opaque == true) |
|
2959 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2960 |
else |
|
2961 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2962 |
||
2963 |
||
2964 |
if (mustFree) { |
|
2965 |
free(cp2); |
|
2966 |
} |
|
2967 |
||
2968 |
RETURN ( self ); |
|
2969 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2970 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2971 |
#undef NLOCALBUFFER |
295 | 2972 |
%}. |
2973 |
"x/y not integer, badGC or drawable, or not a string" |
|
2974 |
self primitiveFailed |
|
2975 |
! |
|
2976 |
||
2977 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 2978 |
width:imageWidth height:imageHeight |
2979 |
x:srcx y:srcy |
|
2980 |
into:aDrawableId |
|
2981 |
x:dstx y:dsty |
|
2982 |
width:w height:h |
|
2983 |
with:aGCId |
|
295 | 2984 |
|
2985 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2986 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2987 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2988 |
depth and pixel-units to be different. |
|
2989 |
It has to be checked elsewhere, that the server can do it with the given |
|
2990 |
depth - otherwise, primitive failure will be signalled. |
|
2991 |
Also it is assumed, that the colormap is setup correctly and the |
|
2992 |
colors are allocated - otherwise the colors may be wrong." |
|
2993 |
||
2994 |
" |
|
2995 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2996 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2997 |
" |
|
2998 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
1344 | 2999 |
width:imageWidth height:imageHeight |
3000 |
x:srcx y:srcy |
|
3001 |
into:aDrawableId |
|
3002 |
x:dstx y:dsty |
|
3003 |
width:w height:h |
|
3004 |
with:aGCId) |
|
295 | 3005 |
ifFalse:[ |
1344 | 3006 |
" |
3007 |
also happens, if a segmentation violation occurs in the |
|
3008 |
XPutImage ... |
|
3009 |
" |
|
3010 |
self primitiveFailed |
|
295 | 3011 |
]. |
3012 |
! |
|
3013 |
||
3014 |
drawBits:imageBits depth:imageDepth |
|
1344 | 3015 |
width:imageWidth height:imageHeight |
3016 |
x:srcx y:srcy |
|
3017 |
into:aDrawableId |
|
3018 |
x:dstx y:dsty |
|
3019 |
width:w height:h |
|
3020 |
with:aGCId |
|
295 | 3021 |
|
3022 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3023 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3024 |
Individual source pixels must have imageDepth bits. |
|
3025 |
It has to be checked elsewhere, that the server can do it with the given |
|
3026 |
depth - otherwise, primitive failure will be signalled. |
|
3027 |
Also it is assumed, that the colormap is setup correctly and the |
|
3028 |
colors are allocated - otherwise the colors may be wrong." |
|
3029 |
||
3030 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
1344 | 3031 |
width:imageWidth height:imageHeight |
3032 |
x:srcx y:srcy |
|
3033 |
into:aDrawableId |
|
3034 |
x:dstx y:dsty |
|
3035 |
width:w height:h |
|
3036 |
with:aGCId |
|
295 | 3037 |
|
3038 |
! |
|
3039 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
3040 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
1344 | 3041 |
in:aDrawableId with:aGCId |
90 | 3042 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
3043 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 3044 |
|
3045 |
%{ /* NOCONTEXT */ |
|
3046 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3047 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3048 |
Window win; |
0 | 3049 |
int w, h, angle1, angle2; |
3050 |
double f; |
|
3051 |
||
97 | 3052 |
if (__isSmallInteger(startAngle)) |
1344 | 3053 |
angle1 = __intVal(startAngle) * 64; |
36 | 3054 |
else if (__isFloat(startAngle)) { |
1344 | 3055 |
f = __floatVal(startAngle); |
3056 |
angle1 = f * 64; |
|
0 | 3057 |
} |
97 | 3058 |
if (__isSmallInteger(angle)) |
1344 | 3059 |
angle2 = __intVal(angle) * 64; |
36 | 3060 |
else if (__isFloat(angle)) { |
1344 | 3061 |
f = __floatVal(angle); |
3062 |
angle2 = f * 64; |
|
0 | 3063 |
} |
1209 | 3064 |
if (ISCONNECTED |
3065 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3066 |
&& __isExternalAddress(aDrawableId) |
97 | 3067 |
&& __bothSmallInteger(x, y) |
3068 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3069 |
gc = _GCVal(aGCId); |
3070 |
win = _WindowVal(aDrawableId); |
|
3071 |
w = __intVal(width); |
|
3072 |
h = __intVal(height); |
|
3073 |
/* |
|
3074 |
* need this check here: some servers simply dump core with bad args |
|
3075 |
*/ |
|
3076 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
3077 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
3078 |
w, h, angle1, angle2); |
|
3079 |
} |
|
3080 |
RETURN ( self ); |
|
0 | 3081 |
} |
73 | 3082 |
%}. |
3083 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3084 |
self primitiveFailed |
3085 |
! |
|
3086 |
||
3087 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 3088 |
"fill a polygon given by its points. |
3089 |
If any coordinate is not integer, an error is triggered." |
|
73 | 3090 |
|
3091 |
|numberOfPoints| |
|
0 | 3092 |
|
3093 |
numberOfPoints := aPolygon size. |
|
3094 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3095 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3096 |
Window win; |
73 | 3097 |
OBJ point, x, y; |
3098 |
int i, num; |
|
3099 |
XPoint *points; |
|
3100 |
XPoint qPoints[100]; |
|
377 | 3101 |
int mustFree = 0; |
73 | 3102 |
|
1209 | 3103 |
if (ISCONNECTED |
3104 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3105 |
&& __isExternalAddress(aDrawableId) |
97 | 3106 |
&& __isSmallInteger(numberOfPoints)) { |
1344 | 3107 |
gc = _GCVal(aGCId); |
3108 |
win = _WindowVal(aDrawableId); |
|
3109 |
num = __intVal(numberOfPoints); |
|
3110 |
if (num < 3) { |
|
3111 |
RETURN ( self ); |
|
3112 |
} |
|
3113 |
/* |
|
3114 |
* avoid (slow) malloc, if not many points |
|
3115 |
*/ |
|
3116 |
if (num > 100) { |
|
3117 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
|
3118 |
if (! points) goto fail; |
|
3119 |
mustFree = 1; |
|
3120 |
} else |
|
3121 |
points = qPoints; |
|
3122 |
for (i=0; i<num; i++) { |
|
3123 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
3124 |
if (! __isPoint(point)) goto fail; |
|
3125 |
x = _point_X(point); |
|
3126 |
y = _point_Y(point); |
|
3127 |
if (! __bothSmallInteger(x, y)) |
|
3128 |
goto fail; |
|
3129 |
points[i].x = __intVal(x); |
|
3130 |
points[i].y = __intVal(y); |
|
3131 |
} |
|
3132 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
3133 |
if (mustFree) |
|
3134 |
free(points); |
|
3135 |
RETURN ( self ); |
|
377 | 3136 |
|
0 | 3137 |
fail: ; |
1344 | 3138 |
if (mustFree) |
3139 |
free(points); |
|
0 | 3140 |
} |
73 | 3141 |
%}. |
3142 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 3143 |
self primitiveFailed |
3144 |
! |
|
3145 |
||
295 | 3146 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3147 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
3148 |
||
3149 |
%{ /* NOCONTEXT */ |
|
3150 |
||
3151 |
int w, h; |
|
3152 |
||
1209 | 3153 |
if (ISCONNECTED |
3154 |
&& __isExternalAddress(aGCId) |
|
295 | 3155 |
&& __isExternalAddress(aDrawableId) |
3156 |
&& __bothSmallInteger(x, y) |
|
3157 |
&& __bothSmallInteger(width, height)) { |
|
1344 | 3158 |
w = __intVal(width); |
3159 |
h = __intVal(height); |
|
3160 |
/* |
|
3161 |
* need this check here: some servers simply dump core with bad args |
|
3162 |
*/ |
|
3163 |
if ((w >= 0) && (h >= 0)) { |
|
3164 |
XFillRectangle(myDpy, |
|
3165 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
3166 |
__intVal(x), __intVal(y), w, h); |
|
3167 |
} |
|
3168 |
RETURN ( self ); |
|
295 | 3169 |
} |
3170 |
%}. |
|
3171 |
"badGC, badDrawable or coordinates not integer" |
|
3172 |
self primitiveFailed |
|
43 | 3173 |
! |
3174 |
||
3175 |
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 |
|
0 | 3182 |
|
132 | 3183 |
"since XPutImage may allocate huge amount of stack space |
3184 |
(some implementations use alloca), this must run with unlimited stack." |
|
3185 |
||
12 | 3186 |
%{ /* UNLIMITEDSTACK */ |
0 | 3187 |
|
43 | 3188 |
/* |
3189 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3190 |
* XPutImage |
|
3191 |
*/ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3192 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3193 |
Window win; |
43 | 3194 |
XImage image; |
377 | 3195 |
int imgWdth; |
43 | 3196 |
|
1209 | 3197 |
if (ISCONNECTED |
3198 |
&& __isExternalAddress(aGCId) |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3199 |
&& __isExternalAddress(aDrawableId) |
97 | 3200 |
&& __bothSmallInteger(srcx, srcy) |
3201 |
&& __bothSmallInteger(dstx, dsty) |
|
3202 |
&& __bothSmallInteger(w, h) |
|
3203 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3204 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3205 |
&& __isByteArray(imageBits)) { |
1344 | 3206 |
Display *dpy = myDpy; |
3207 |
||
3208 |
gc = _GCVal(aGCId); |
|
3209 |
win = _WindowVal(aDrawableId); |
|
3210 |
if (! gc || !win) |
|
3211 |
goto fail; |
|
46 | 3212 |
#ifdef ARGDEBUG |
1344 | 3213 |
printf("args ok\n"); |
46 | 3214 |
#endif |
1344 | 3215 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3216 |
image.width = imgWdth = __intVal(imageWidth); |
|
3217 |
image.height = __intVal(imageHeight); |
|
3218 |
image.xoffset = 0; |
|
3219 |
image.format = ZPixmap; |
|
3220 |
image.byte_order = MSBFirst; |
|
3221 |
image.bitmap_unit = 8; |
|
3222 |
image.bitmap_bit_order = MSBFirst; |
|
3223 |
image.bitmap_pad = 8; |
|
3224 |
image.depth = __intVal(imageDepth); |
|
3225 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
3226 |
switch (image.bits_per_pixel) { |
|
3227 |
case 1: |
|
3228 |
image.bytes_per_line = (imgWdth + 7) / 8; |
|
3229 |
break; |
|
3230 |
case 2: |
|
3231 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
|
3232 |
break; |
|
3233 |
case 4: |
|
3234 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
|
3235 |
break; |
|
3236 |
case 8: |
|
3237 |
image.bytes_per_line = imgWdth; |
|
3238 |
break; |
|
3239 |
case 16: |
|
3240 |
image.bytes_per_line = imgWdth*2; |
|
3241 |
break; |
|
3242 |
case 24: |
|
3243 |
image.bytes_per_line = imgWdth*3; |
|
3244 |
break; |
|
3245 |
case 32: |
|
3246 |
image.bytes_per_line = imgWdth*4; |
|
3247 |
break; |
|
3248 |
default: |
|
46 | 3249 |
#ifdef ARGDEBUG |
1344 | 3250 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3251 |
#endif |
1344 | 3252 |
goto fail; |
3253 |
} |
|
3254 |
image.red_mask = 0xFFFF; |
|
3255 |
image.green_mask = 0xFFFF; |
|
3256 |
image.blue_mask = 0xFFFF; |
|
3257 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
|
3258 |
__intVal(dstx), __intVal(dsty), |
|
3259 |
__intVal(w), __intVal(h)); |
|
3260 |
RETURN ( true ); |
|
43 | 3261 |
} |
46 | 3262 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3263 |
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
|
3264 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3265 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3266 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3267 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3268 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3269 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3270 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3271 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3272 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3273 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3274 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3275 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3276 |
#endif |
3277 |
||
0 | 3278 |
fail: ; |
3279 |
%} |
|
3280 |
. |
|
12 | 3281 |
^ false |
0 | 3282 |
! ! |
3283 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3284 |
!XWorkstation methodsFor:'event forwarding'! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3285 |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3286 |
circulateNotifyView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3287 |
"sent, when the stacking order changes. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3288 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3289 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3290 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3291 |
|
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3292 |
circulateRequestView:aView |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3293 |
"sent, when the stacking order is about to change. |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3294 |
ignored for now." |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3295 |
! |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3296 |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3297 |
colorMapChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3298 |
"sent, when another colormap is installed. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3299 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3300 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3301 |
aView colorMapChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3302 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3303 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3304 |
configureRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3305 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3306 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3307 |
"/ aView configureRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3308 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3309 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3310 |
createdView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3311 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3312 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3313 |
"/ aView created |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3314 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3315 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3316 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3317 |
mapRequestView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3318 |
"ignored for now" |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3319 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3320 |
"/ aView mapRequest |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3321 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3322 |
|
1344 | 3323 |
|
3324 |
reparentedView:aView |
|
3325 |
"ignored for now" |
|
3326 |
||
3327 |
"/ aView reparented |
|
3328 |
! |
|
3329 |
||
3330 |
gravityNotifyView:aView |
|
3331 |
"ignored for now" |
|
3332 |
||
3333 |
"/ aView gravityNotify |
|
3334 |
! |
|
3335 |
||
3336 |
resizeRequestView:aView |
|
3337 |
"ignored for now" |
|
3338 |
||
3339 |
"/ aView resizeRequest |
|
3340 |
! |
|
3341 |
||
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3342 |
propertyChangeView:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3343 |
"sent when an X property changes. |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3344 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3345 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3346 |
aView propertyChange |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3347 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3348 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3349 |
selectionClear:selectionID view:aView |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3350 |
"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
|
3351 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3352 |
|
1344 | 3353 |
"/ |
3354 |
"/ workaround a bug in olvwm: it clears selections |
|
3355 |
"/ on window raise. |
|
3356 |
"/ In this case, keep my last own selection. |
|
3357 |
"/ |
|
3358 |
||
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3359 |
self setLastCopyBuffer:(self getCopyBuffer). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3360 |
self setCopyBuffer:nil |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3361 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3362 |
"/ noone is interrested in that ... |
1344 | 3363 |
"/ aView selectionClear:selectionID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3364 |
! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3365 |
|
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3366 |
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
|
3367 |
"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
|
3368 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3369 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3370 |
|s sensor| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3371 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3372 |
propertyID == 0 ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3373 |
"invalid olvwm behavior" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3374 |
s := self getLastCopyBuffer |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3375 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3376 |
targetID == self atomIDOfSTRING ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3377 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3378 |
a returned string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3379 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3380 |
s := self getTextProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3381 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3382 |
(s endsWith:Character cr) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3383 |
s := s asStringCollection copyWith:'' |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3384 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3385 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3386 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3387 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3388 |
a returned object |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3389 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3390 |
s := self getObjectProperty:propertyID from:requestorID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3391 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3392 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3393 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3394 |
s notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3395 |
(sensor := aView sensor) notNil ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3396 |
sensor pasteFromClipBoard:s view:aView |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3397 |
] ifFalse:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3398 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3399 |
if there is no sensor ... |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3400 |
" |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3401 |
aView pasteFromClipBoard:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3402 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3403 |
] |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3404 |
! |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3405 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3406 |
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
|
3407 |
"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
|
3408 |
This is a very X-specific mechanism." |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3409 |
|
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3410 |
|o s stream| |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3411 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3412 |
targetID == (self atomIDOfLENGTH) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3413 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3414 |
"/ 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
|
3415 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3416 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3417 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3418 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3419 |
setLengthProperty:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3420 |
value:s size |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3421 |
for:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3422 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3423 |
sendSelectionNotifySelection:selectionID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3424 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3425 |
target:targetID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3426 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3427 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3428 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3429 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3430 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3431 |
(targetID == self atomIDOfSTRING or:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3432 |
targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3433 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3434 |
"/ the other view wants the selection as string |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3435 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3436 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3437 |
s := self selectionAsString. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3438 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3439 |
sendSelection:s |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3440 |
property:propertyID |
1345 | 3441 |
target:targetID |
1341
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3442 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3443 |
to:windowID. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3444 |
^ self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3445 |
]. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3446 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3447 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3448 |
"/ send the seletion in binaryStore format |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3449 |
"/ (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
|
3450 |
"/ |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3451 |
o := self getCopyBuffer. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3452 |
stream := WriteStream on:(ByteArray new:200). |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3453 |
o storeBinaryOn:stream. |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3454 |
|
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3455 |
self |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3456 |
sendSelection:(stream contents) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3457 |
property:propertyID |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3458 |
target:(self atomIDOf:'ST_OBJECT' create:true) |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3459 |
from:aView id |
026bdf39f4ea
pasteFromClipboard goes via the sensor,
Claus Gittinger <cg@exept.de>
parents:
1339
diff
changeset
|
3460 |
to:windowID |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3461 |
! ! |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3462 |
|
86 | 3463 |
!XWorkstation methodsFor:'event handling'! |
0 | 3464 |
|
3465 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3466 |
"central event handling method: |
|
54 | 3467 |
get next event and send appropriate message to the sensor or view. |
0 | 3468 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3469 |
otherwise only events for the view with given id are processed. |
3470 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3471 |
handled." |
|
3472 |
||
54 | 3473 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
1344 | 3474 |
AbortSignal catch:[ |
3475 |
self dispatchLastEvent. |
|
3476 |
] |
|
54 | 3477 |
]. |
12 | 3478 |
! |
3479 |
||
295 | 3480 |
dispatchExposeEventFor:aViewIdOrNil |
3481 |
"get next expose event and send appropriate message to the sensor or view. |
|
3482 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3483 |
otherwise only events for the view with given id are processed." |
|
3484 |
||
3485 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3486 |
! |
3487 |
||
3488 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3489 |
|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
|
3490 |
eventType| |
12 | 3491 |
|
3492 |
%{ /* STACK: 8000 */ |
|
3493 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3494 |
|
1209 | 3495 |
Display *dpy; |
135 | 3496 |
OBJ eB; |
3497 |
XEvent *ev; |
|
3498 |
||
3499 |
# define ae ((XAnyEvent *)ev) |
|
3500 |
# define ee ((XExposeEvent *)ev) |
|
3501 |
# define ke ((XKeyPressedEvent *)ev) |
|
3502 |
# define be ((XButtonPressedEvent *)ev) |
|
3503 |
# define ce ((XConfigureEvent *)ev) |
|
3504 |
# define me ((XMotionEvent *)ev) |
|
3505 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3506 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3507 |
# define de ((XDestroyWindowEvent *)ev) |
|
3508 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3509 |
# define mape ((XMappingEvent *)ev) |
135 | 3510 |
|
0 | 3511 |
KeySym keySym; |
3512 |
unsigned char buffer[10]; |
|
3513 |
int i, nchars; |
|
3514 |
char *keySymString; |
|
3515 |
char keySymStringBuffer[32]; |
|
3516 |
unsigned nextMultiClickTime; |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3517 |
OBJ upDown, t; |
115 | 3518 |
|
3519 |
struct inlineCache *ipS; |
|
0 | 3520 |
static struct inlineCache vid = _ILC1; |
12 | 3521 |
|
3522 |
static struct inlineCache expS = _ILC5; |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1246
diff
changeset
|
3523 |
static struct inlineCache gexpS = _ILC6; |
12 | 3524 |
static struct inlineCache nexpS = _ILC1; |
3525 |
static struct inlineCache motS = _ILC4; |
|
3526 |
static struct inlineCache bpS = _ILC4; |
|
3527 |
static struct inlineCache bmpS = _ILC4; |
|
3528 |
static struct inlineCache bspS = _ILC4; |
|
3529 |
static struct inlineCache brS = _ILC4; |
|
3530 |
static struct inlineCache focInS = _ILC1; |
|
3531 |
static struct inlineCache focOutS = _ILC1; |
|
3532 |
static struct inlineCache peS = _ILC4; |
|
3533 |
static struct inlineCache plS = _ILC2; |
|
54 | 3534 |
static struct inlineCache termS = _ILC1; |
3535 |
static struct inlineCache savtermS = _ILC1; |
|
3536 |
static struct inlineCache destrS = _ILC1; |
|
3537 |
static struct inlineCache unmapS = _ILC1; |
|
3538 |
static struct inlineCache mapS = _ILC1; |
|
3539 |
static struct inlineCache confS = _ILC5; |
|
70 | 3540 |
static struct inlineCache coveredS = _ILC2; |
12 | 3541 |
|
3542 |
static struct inlineCache keymap = _ILC0; |
|
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3543 |
static struct inlineCache created = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3544 |
static struct inlineCache mapReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3545 |
static struct inlineCache repar = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3546 |
static struct inlineCache confReq = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3547 |
static struct inlineCache resReq = _ILC1; |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3548 |
static struct inlineCache circReq = _ILC1; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3549 |
static struct inlineCache circNotify = _ILC1; |
1338
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3550 |
static struct inlineCache gravNotify = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3551 |
static struct inlineCache prop = _ILC1; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3552 |
static struct inlineCache selClear = _ILC2; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3553 |
static struct inlineCache selReq = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3554 |
static struct inlineCache selNotify = _ILC5; |
8df6dbb44883
no more direct messages to the view
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
3555 |
static struct inlineCache colormap = _ILC1; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3556 |
static struct inlineCache mapping = _ILC2; |
70 | 3557 |
static struct inlineCache vis = _ILC1; |
12 | 3558 |
|
3559 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3560 |
static struct inlineCache skrS = _ILC4; |
12 | 3561 |
|
1209 | 3562 |
if (! ISCONNECTED) { |
1344 | 3563 |
RETURN (false); |
1209 | 3564 |
} |
3565 |
||
3566 |
dpy = myDpy; |
|
3567 |
||
1210 | 3568 |
eB = __INST(eventBuffer); |
3569 |
||
135 | 3570 |
if (__isByteArray(eB)) { |
1344 | 3571 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3572 |
} else { |
1344 | 3573 |
printf("DISPLAY: no eventBuffer\n"); |
3574 |
RETURN (false); |
|
135 | 3575 |
} |
3576 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3577 |
windowID = __MKOBJ(ae->window); |
1065
fdc5b9059d82
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1062
diff
changeset
|
3578 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, windowID); |
12 | 3579 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3580 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
1344 | 3581 |
RETURN (nil); |
12 | 3582 |
} |
3583 |
||
3584 |
/* |
|
3585 |
* key, button and pointer events are sent to the sensor, |
|
3586 |
* or (if there is none) to the delegate. |
|
3587 |
* or (if there is none) to the view. |
|
26 | 3588 |
* |
3589 |
* expose events are sent to the sensor, |
|
3590 |
* or (if there is none) to the view |
|
3591 |
* |
|
12 | 3592 |
* sensor and delegate get view as additional argument |
115 | 3593 |
* all of this has been taken out of here to corresponding methods |
3594 |
* in DeviceWorkstation. |
|
12 | 3595 |
*/ |
90 | 3596 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3597 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3598 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3599 |
#endif |
135 | 3600 |
switch (ev->type) { |
1344 | 3601 |
case KeyRelease: |
3602 |
symS = @symbol(keyRelease:x:y:view:); |
|
3603 |
ipS = &skrS; |
|
3604 |
upDown = false; |
|
3605 |
goto keyPressAndRelease; |
|
3606 |
||
3607 |
case KeyPress: |
|
3608 |
symS = @symbol(keyPress:x:y:view:); |
|
3609 |
ipS = &skpS; |
|
3610 |
upDown = true; |
|
3611 |
/* FALL INTO */ |
|
3612 |
||
3613 |
keyPressAndRelease: |
|
3614 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
|
3615 |
__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
|
3616 |
#ifdef OLD |
1344 | 3617 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3618 |
__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
|
3619 |
#else |
1344 | 3620 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3621 |
__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
|
3622 |
#endif |
1344 | 3623 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3624 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
3625 |
||
3626 |
arg = nil; |
|
3627 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3628 |
if (nchars |
|
3629 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3630 |
|| (buffer[0] >= 0x80))) { |
|
3631 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3632 |
keySymString = NULL; |
|
3633 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3634 |
#ifdef OLD |
1344 | 3635 |
switch (keySym) { |
3636 |
case XK_Control_L: |
|
3637 |
case XK_Control_R: |
|
3638 |
__INST(ctrlDown) = upDown; |
|
3639 |
break; |
|
3640 |
case XK_Shift_L: |
|
3641 |
case XK_Shift_R: |
|
3642 |
__INST(shiftDown) = upDown; |
|
3643 |
break; |
|
3644 |
case XK_Meta_L: |
|
3645 |
case XK_Meta_R: |
|
3646 |
__INST(metaDown) = upDown; |
|
3647 |
break; |
|
3648 |
case XK_Alt_L: |
|
3649 |
case XK_Alt_R: |
|
3650 |
__INST(altDown) = upDown; |
|
3651 |
break; |
|
3652 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3653 |
#endif |
150 | 3654 |
|
1344 | 3655 |
keySymString = XKeysymToString(keySym); |
3656 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3657 |
#ifdef OLD |
1344 | 3658 |
if (keySymString[0] == 'D') { |
3659 |
/* |
|
3660 |
* remove underscore, dont want it in symbols |
|
3661 |
*/ |
|
3662 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3663 |
keySymString = "DeleteLine"; |
|
3664 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3665 |
keySymString = "DeleteWord"; |
|
3666 |
} |
|
3667 |
} |
|
3668 |
/* |
|
3669 |
* make names compatible |
|
3670 |
*/ |
|
3671 |
if (strcmp(keySymString, "Down") == 0) { |
|
3672 |
keySymString = "CursorDown"; |
|
3673 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3674 |
keySymString = "CursorUp"; |
|
3675 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3676 |
keySymString = "CursorLeft"; |
|
3677 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3678 |
keySymString = "CursorRight"; |
|
3679 |
} |
|
3680 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3681 |
#else |
1344 | 3682 |
__PROTECT__(theView); |
3683 |
arg = __MKSTRING(keySymString); |
|
3684 |
__UNPROTECT__(theView); |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3685 |
#endif |
1344 | 3686 |
} |
3687 |
} |
|
3688 |
||
3689 |
if (arg == nil) { |
|
3690 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3691 |
break; |
|
3692 |
} |
|
3693 |
||
3694 |
(*(*ipS).ilc_func)(self, symS, nil, ipS, |
|
3695 |
arg, |
|
3696 |
__MKSMALLINT(ke->x), |
|
3697 |
__MKSMALLINT(ke->y), |
|
3698 |
theView); |
|
3699 |
break; |
|
3700 |
||
3701 |
case ButtonPress: |
|
3702 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
|
3703 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3704 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3705 |
||
3706 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3707 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
3708 |
else |
|
3709 |
nextMultiClickTime = 0; |
|
3710 |
||
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3711 |
|
1344 | 3712 |
if ((t = __INST(multiClickTime)) != nil) { |
3713 |
int _multiClickTime; |
|
3714 |
||
3715 |
_multiClickTime = __longIntVal(t); |
|
3716 |
if (be->time < _multiClickTime) { |
|
3717 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
|
3718 |
||
3719 |
ipS = &bmpS; |
|
3720 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3721 |
goto sendButtonEvent; |
|
3722 |
break; |
|
3723 |
} |
|
3724 |
} |
|
3725 |
__INST(multiClickTime) = t = __MKUINT(nextMultiClickTime); __STORE(self, t); |
|
1223
09d8118c8031
keep nextMultiClickTime on a per-display basis
Claus Gittinger <cg@exept.de>
parents:
1214
diff
changeset
|
3726 |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
3727 |
#ifdef NO_LONGER |
1344 | 3728 |
if (be->state & ShiftMask) { |
3729 |
ipS = &bspS; |
|
3730 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3731 |
goto sendButtonEvent; |
|
3732 |
} |
|
1010
b8576573e6aa
no longer send buttonShiftPress messages (has to be done in the
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
3733 |
#endif |
1344 | 3734 |
ipS = &bpS; |
3735 |
symS = @symbol(buttonPress:x:y:view:); |
|
3736 |
goto sendButtonEvent; |
|
3737 |
||
3738 |
/* NOT REACHED */ |
|
3739 |
||
3740 |
case ButtonRelease: |
|
3741 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
|
3742 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3743 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3744 |
ipS = &brS; |
|
3745 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3746 |
/* fall into */ |
|
3747 |
||
3748 |
sendButtonEvent: |
|
3749 |
butt = __MKSMALLINT(be->button); |
|
12 | 3750 |
#ifdef NOTDEF |
1344 | 3751 |
/* |
3752 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3753 |
*/ |
|
3754 |
if (__INST(metaDown) == true) |
|
3755 |
butt = __MKSMALLINT(2); |
|
3756 |
else |
|
0 | 3757 |
#endif |
1344 | 3758 |
butt = __AT_(__INST(buttonTranslation), butt); |
3759 |
||
3760 |
||
3761 |
(*(*ipS).ilc_func)(self, |
|
3762 |
symS, nil, ipS, |
|
3763 |
butt, |
|
3764 |
__MKSMALLINT(ke->x), |
|
3765 |
__MKSMALLINT(ke->y), |
|
3766 |
theView); |
|
3767 |
break; |
|
3768 |
||
3769 |
case MotionNotify: |
|
3770 |
if (__INST(motionEventCompression) != false) { |
|
3771 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
|
3772 |
} |
|
3773 |
||
3774 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
|
3775 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3776 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3777 |
#ifdef OLD |
1344 | 3778 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3779 |
__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
|
3780 |
#else |
1344 | 3781 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3782 |
__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
|
3783 |
#endif |
1344 | 3784 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3785 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
3786 |
||
3787 |
(*motS.ilc_func)(self, |
|
3788 |
@symbol(buttonMotion:x:y:view:), nil, &motS, |
|
3789 |
__MKSMALLINT(me->state), |
|
3790 |
__MKSMALLINT(me->x), |
|
3791 |
__MKSMALLINT(me->y), |
|
3792 |
theView); |
|
3793 |
break; |
|
3794 |
||
3795 |
case FocusIn: |
|
3796 |
(*focInS.ilc_func)(self, |
|
3797 |
@symbol(focusInView:), nil, &focInS, |
|
3798 |
theView); |
|
3799 |
break; |
|
3800 |
||
3801 |
case FocusOut: |
|
3802 |
(*focOutS.ilc_func)(self, |
|
3803 |
@symbol(focusOutView:), nil, &focOutS, |
|
3804 |
theView); |
|
3805 |
break; |
|
3806 |
||
3807 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3808 |
#ifdef OLD |
1344 | 3809 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3810 |
__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
|
3811 |
#else |
1344 | 3812 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3813 |
__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
|
3814 |
#endif |
1344 | 3815 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3816 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
3817 |
||
3818 |
(*peS.ilc_func)(self, |
|
3819 |
@symbol(pointerEnter:x:y:view:), nil, &peS, |
|
3820 |
__MKSMALLINT(ewe->state), |
|
3821 |
__MKSMALLINT(ewe->x), |
|
3822 |
__MKSMALLINT(ewe->y), |
|
3823 |
theView); |
|
3824 |
break; |
|
3825 |
||
3826 |
case LeaveNotify: |
|
3827 |
(*plS.ilc_func)(self, |
|
3828 |
@symbol(pointerLeave:view:), nil, &plS, |
|
3829 |
__MKSMALLINT(lwe->state), |
|
3830 |
theView); |
|
3831 |
break; |
|
3832 |
||
3833 |
case GraphicsExpose: |
|
3834 |
(*gexpS.ilc_func)(self, |
|
3835 |
@symbol(graphicsExposeX:y:width:height:final:view:), nil, &gexpS, |
|
3836 |
__MKSMALLINT(ee->x), |
|
3837 |
__MKSMALLINT(ee->y), |
|
3838 |
__MKSMALLINT(ee->width), |
|
3839 |
__MKSMALLINT(ee->height), |
|
3840 |
ee->count == 0 ? true : false, |
|
3841 |
theView); |
|
3842 |
||
3843 |
if (ee->count != 0) { |
|
3844 |
break; |
|
3845 |
} |
|
3846 |
/* fall into */ |
|
3847 |
||
3848 |
case NoExpose: |
|
3849 |
(*nexpS.ilc_func)(self, |
|
3850 |
@symbol(noExposeView:), nil, &nexpS, |
|
3851 |
theView); |
|
3852 |
break; |
|
3853 |
||
3854 |
case Expose: |
|
3855 |
(*expS.ilc_func)(self, |
|
3856 |
@symbol(exposeX:y:width:height:view:), nil, &expS, |
|
3857 |
__MKSMALLINT(ee->x), |
|
3858 |
__MKSMALLINT(ee->y), |
|
3859 |
__MKSMALLINT(ee->width), |
|
3860 |
__MKSMALLINT(ee->height), |
|
3861 |
theView); |
|
3862 |
break; |
|
3863 |
||
3864 |
case ConfigureNotify: |
|
3865 |
if (ce->above != None) { |
|
3866 |
siblingID = __MKOBJ(ce->above); |
|
3867 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:), nil, &vid, siblingID); |
|
3868 |
} |
|
3869 |
||
3870 |
(*confS.ilc_func)(self, |
|
3871 |
@symbol(configureX:y:width:height:view:), nil, &confS, |
|
3872 |
__MKSMALLINT(ce->x), |
|
3873 |
__MKSMALLINT(ce->y), |
|
3874 |
__MKSMALLINT(ce->width), |
|
3875 |
__MKSMALLINT(ce->height), |
|
3876 |
theView); |
|
3877 |
if (sibling != nil) { |
|
3878 |
(*coveredS.ilc_func)(self, |
|
3879 |
@symbol(coveredBy:view:), nil, &coveredS, |
|
3880 |
theView, |
|
3881 |
sibling); |
|
3882 |
} |
|
3883 |
break; |
|
3884 |
||
3885 |
case ClientMessage: |
|
3886 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
|
3887 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3888 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
3889 |
(*termS.ilc_func)(self, |
|
3890 |
@symbol(terminateView:), nil, &termS, theView); |
|
3891 |
break; |
|
3892 |
} |
|
3893 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
|
3894 |
(*savtermS.ilc_func)(self, |
|
3895 |
@symbol(saveAndTerminateView:) |
|
3896 |
, nil, &savtermS, theView); |
|
3897 |
break; |
|
3898 |
} |
|
3899 |
} |
|
3900 |
break; |
|
3901 |
||
3902 |
case DestroyNotify: |
|
3903 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
|
3904 |
, nil, &destrS, theView); |
|
3905 |
break; |
|
3906 |
||
3907 |
case UnmapNotify: |
|
3908 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
|
3909 |
, nil, &unmapS, theView); |
|
3910 |
break; |
|
3911 |
||
3912 |
case MapNotify: |
|
3913 |
(*mapS.ilc_func)(self, |
|
3914 |
@symbol(mappedView:) |
|
3915 |
, nil, &mapS, theView); |
|
3916 |
break; |
|
3917 |
||
3918 |
case KeymapNotify: |
|
3919 |
(*keymap.ilc_func)(theView, |
|
3920 |
@symbol(keyMapChange) |
|
3921 |
, nil, &keymap); |
|
3922 |
break; |
|
3923 |
||
3924 |
case VisibilityNotify: |
|
3925 |
switch (ve->state) { |
|
3926 |
case VisibilityUnobscured: |
|
3927 |
arg = @symbol(unobscured); |
|
3928 |
break; |
|
3929 |
case VisibilityPartiallyObscured: |
|
3930 |
arg = @symbol(partiallyObscured); |
|
3931 |
break; |
|
3932 |
case VisibilityFullyObscured: |
|
3933 |
arg = @symbol(fullyObscured); |
|
3934 |
break; |
|
3935 |
} |
|
3936 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:), nil, &vis, arg); |
|
3937 |
break; |
|
3938 |
||
3939 |
case CreateNotify: |
|
3940 |
(*created.ilc_func)(self, @symbol(createdView:), nil, &created, theView); |
|
3941 |
break; |
|
3942 |
||
3943 |
case MapRequest: |
|
3944 |
(*mapReq.ilc_func)(self, @symbol(mapRequestView:), nil, &mapReq, theView); |
|
3945 |
break; |
|
3946 |
||
3947 |
case ReparentNotify: |
|
3948 |
(*repar.ilc_func)(self, @symbol(reparentedView:), nil, &repar, theView); |
|
3949 |
break; |
|
3950 |
||
3951 |
case ConfigureRequest: |
|
3952 |
(*confReq.ilc_func)(self, @symbol(configureRequestView:), nil, &confReq, theView); |
|
3953 |
break; |
|
3954 |
||
3955 |
case GravityNotify: |
|
3956 |
(*gravNotify.ilc_func)(self, @symbol(gravityNotifyView:), nil, &resReq, theView); |
|
3957 |
break; |
|
3958 |
||
3959 |
case ResizeRequest: |
|
3960 |
(*resReq.ilc_func)(self, @symbol(resizeRequestView:), nil, &resReq, theView); |
|
3961 |
break; |
|
3962 |
||
3963 |
case CirculateNotify: |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3964 |
(*circNotify.ilc_func)(self, @symbol(circulateNotifyView:), nil, &circNotify, theView); |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3965 |
break; |
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3966 |
|
1344 | 3967 |
case CirculateRequest: |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
3968 |
(*circReq.ilc_func)(self, @symbol(circulateRequestView:), nil, &circReq, theView); |
1344 | 3969 |
break; |
3970 |
||
3971 |
case PropertyNotify: |
|
3972 |
(*prop.ilc_func)(self, |
|
3973 |
@symbol(propertyChangeView) |
|
3974 |
, nil, &prop, |
|
3975 |
theView); |
|
3976 |
break; |
|
3977 |
||
3978 |
case SelectionClear: |
|
3979 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
|
3980 |
(*selClear.ilc_func)(self, |
|
3981 |
@symbol(selectionClear:view:) |
|
3982 |
, nil, &selClear, |
|
3983 |
selectionID, |
|
3984 |
theView); |
|
3985 |
break; |
|
3986 |
||
3987 |
case SelectionNotify: |
|
3988 |
/* |
|
3989 |
* returned selection value (answer from SelectionRequest) |
|
3990 |
*/ |
|
3991 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
|
3992 |
ev->xselection.property, ev->xselection.target, |
|
3993 |
ev->xselection.selection, ev->xselection.requestor)); |
|
3994 |
||
3995 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
|
3996 |
targetID = __MKATOMOBJ(ev->xselection.target); |
|
3997 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
|
3998 |
requestorID = __MKOBJ(ev->xselection.requestor); |
|
3999 |
(*selNotify.ilc_func)(self, |
|
4000 |
@symbol(selectionNotify:target:selection:from:view:) |
|
4001 |
, nil, &selNotify, |
|
4002 |
propertyID, targetID, selectionID, requestorID, |
|
4003 |
theView); |
|
4004 |
break; |
|
4005 |
||
4006 |
case SelectionRequest: |
|
4007 |
/* |
|
4008 |
* someone wants the selection |
|
4009 |
*/ |
|
4010 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
4011 |
ev->xselectionrequest.property, |
|
4012 |
ev->xselectionrequest.target, |
|
4013 |
ev->xselectionrequest.selection, |
|
4014 |
ev->xselectionrequest.requestor)); |
|
4015 |
||
4016 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
|
4017 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
|
4018 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
|
4019 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
|
4020 |
(*selReq.ilc_func)(self, |
|
1345 | 4021 |
@symbol(selectionRequest:target:selection:from:view:) |
1344 | 4022 |
, nil, &selReq, |
4023 |
propertyID, targetID, selectionID, requestorID, |
|
4024 |
theView); |
|
4025 |
break; |
|
4026 |
||
4027 |
case ColormapNotify: |
|
4028 |
(*colormap.ilc_func)(self, |
|
4029 |
@symbol(colorMapChangeView:) |
|
4030 |
, nil, &colormap, |
|
4031 |
theView); |
|
4032 |
break; |
|
4033 |
||
4034 |
case MappingNotify: |
|
4035 |
switch(mape->request) { |
|
4036 |
case MappingModifier: |
|
4037 |
arg = @symbol(mappingModifier); |
|
4038 |
break; |
|
4039 |
case MappingKeyboard: |
|
4040 |
arg = @symbol(mappingKeyboard); |
|
4041 |
break; |
|
4042 |
case MappingPointer: |
|
4043 |
arg = @symbol(mappingPointer); |
|
4044 |
break; |
|
4045 |
default: |
|
4046 |
arg = nil; |
|
4047 |
break; |
|
4048 |
} |
|
4049 |
(*mapping.ilc_func)(self, |
|
4050 |
@symbol(mappingChanged:event:) |
|
4051 |
, nil, &mapping, arg, eB); |
|
4052 |
break; |
|
0 | 4053 |
} |
135 | 4054 |
#undef ae |
0 | 4055 |
#undef ee |
4056 |
#undef ke |
|
4057 |
#undef be |
|
4058 |
#undef ce |
|
4059 |
#undef me |
|
4060 |
#undef ewe |
|
4061 |
#undef lwe |
|
4062 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4063 |
#undef mape |
0 | 4064 |
%} |
4065 |
. |
|
4066 |
^ true |
|
4067 |
! |
|
4068 |
||
1344 | 4069 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4070 |
"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
|
4071 |
(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
|
4072 |
This code is somewhat special, since X has a concept of graphic |
295 | 4073 |
expose events (which are sent after a bitblt). After such a bitblt, |
4074 |
we only handle exposes until the graphicsExpose arrives. |
|
4075 |
Other systems may not need such a kludge" |
|
4076 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4077 |
"interested in exposes only ?" |
295 | 4078 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4079 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
4080 |
self dispatchExposeEventFor:dispatchingExpose |
|
4081 |
]. |
|
4082 |
^ self |
|
295 | 4083 |
]. |
4084 |
||
4085 |
"no, general dispatch" |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4086 |
[self eventPendingWithSync:false] whileTrue:[ |
1344 | 4087 |
self dispatchEventFor:nil withMask:nil |
295 | 4088 |
] |
4089 |
! |
|
4090 |
||
1344 | 4091 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
81 | 4092 |
"dispose (throw away) specific events. If aWindowId is nil, |
4093 |
events matching the mask are thrown away regardless of which |
|
4094 |
view they are for. Otherwise, only matching events for that |
|
4095 |
view are flushed." |
|
0 | 4096 |
|
4097 |
%{ /* NOCONTEXT */ |
|
4098 |
||
4099 |
XEvent ev; |
|
4100 |
Window win; |
|
4101 |
||
1209 | 4102 |
if (ISCONNECTED |
4103 |
&& __isSmallInteger(aMask)) { |
|
1344 | 4104 |
Display *dpy = myDpy; |
4105 |
||
4106 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4107 |
win = _WindowVal(aWindowIdOrNil); |
|
4108 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
|
4109 |
} else { |
|
4110 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
|
4111 |
} |
|
4112 |
RETURN ( self ); |
|
0 | 4113 |
} |
4114 |
%} |
|
4115 |
. |
|
4116 |
self primitiveFailed |
|
4117 |
! |
|
4118 |
||
1344 | 4119 |
eventMaskFor:anEventSymbol |
295 | 4120 |
"return the eventMask bit-constant corresponding to an event symbol" |
4121 |
||
4122 |
%{ /* NOCONTEXT */ |
|
4123 |
||
4124 |
int m = 0; |
|
4125 |
||
4126 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
4127 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
4128 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
4129 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
4130 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
4131 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
4132 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
4133 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
4134 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
4135 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
4136 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
4137 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
4138 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
4139 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
4140 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
4141 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
4142 |
RETURN (__MKSMALLINT(m)); |
295 | 4143 |
%} |
4144 |
! |
|
4145 |
||
1344 | 4146 |
eventPending |
310 | 4147 |
"return true, if any event is pending. |
4148 |
This looks for both the internal queue and the display connection." |
|
12 | 4149 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4150 |
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
|
4151 |
|
12 | 4152 |
dispatchingExpose notNil ifTrue:[ |
1344 | 4153 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 4154 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4155 |
^ self eventPendingWithSync:false |
0 | 4156 |
! |
4157 |
||
1344 | 4158 |
eventPending:anEventSymbol for:aWindowIdOrNil |
295 | 4159 |
"return true, if a specific event is pending" |
4160 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4161 |
^ 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
|
4162 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
4163 |
|
1344 | 4164 |
eventPendingWithSync:doSync |
7 | 4165 |
"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
|
4166 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 4167 |
before checking." |
0 | 4168 |
|
12 | 4169 |
%{ /* UNLIMITEDSTACK */ |
0 | 4170 |
|
150 | 4171 |
if (ISCONNECTED) { |
1344 | 4172 |
Display *dpy = myDpy; |
4173 |
||
4174 |
if (doSync == true) { |
|
4175 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4176 |
} |
|
4177 |
if (XPending(dpy)) { |
|
4178 |
RETURN (true); |
|
4179 |
} |
|
150 | 4180 |
} |
4181 |
RETURN ( false ); |
|
0 | 4182 |
%} |
4183 |
! |
|
4184 |
||
1344 | 4185 |
eventQueued |
341 | 4186 |
"return true, if any event is queued" |
4187 |
||
4188 |
dispatchingExpose notNil ifTrue:[ |
|
1344 | 4189 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 4190 |
]. |
4191 |
^ self eventQueuedAlready |
|
4192 |
||
4193 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
4194 |
! |
|
4195 |
||
1344 | 4196 |
eventQueuedAlready |
341 | 4197 |
"return true, if any event is queued internally. |
4198 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
4199 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
4200 |
the display connection)." |
|
4201 |
||
4202 |
%{ /* UNLIMITEDSTACK */ |
|
4203 |
||
4204 |
if (ISCONNECTED) { |
|
1344 | 4205 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
4206 |
RETURN (true); |
|
4207 |
} |
|
341 | 4208 |
} |
4209 |
RETURN ( false ); |
|
4210 |
%} |
|
4211 |
! |
|
4212 |
||
1344 | 4213 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 4214 |
"return true, if any of the masked events is pending" |
4215 |
||
4216 |
%{ /* UNLIMITEDSTACK */ |
|
4217 |
||
4218 |
XEvent ev; |
|
4219 |
Window win; |
|
4220 |
int thereIsOne; |
|
4221 |
||
4222 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
1344 | 4223 |
Display *dpy = myDpy; |
4224 |
||
4225 |
if (doSync == true) { |
|
4226 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4227 |
} |
|
4228 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4229 |
win = _WindowVal(aWindowIdOrNil); |
|
4230 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
|
4231 |
} else { |
|
4232 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
|
4233 |
} |
|
4234 |
if (thereIsOne) { |
|
4235 |
XPutBackEvent(dpy, &ev); |
|
4236 |
RETURN ( true ); |
|
4237 |
} |
|
295 | 4238 |
} |
4239 |
RETURN ( false ); |
|
4240 |
%} |
|
4241 |
! |
|
4242 |
||
1344 | 4243 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 4244 |
"return true, if any expose event is pending for a specific view, |
4245 |
or any view (if the arg is nil). |
|
4246 |
This is an X specific, only required after a scroll operation." |
|
7 | 4247 |
|
12 | 4248 |
%{ /* UNLIMITEDSTACK */ |
7 | 4249 |
|
4250 |
XEvent ev; |
|
4251 |
Window win; |
|
81 | 4252 |
int thereIsOne; |
4253 |
||
150 | 4254 |
if (ISCONNECTED) { |
1344 | 4255 |
Display *dpy = myDpy; |
4256 |
||
4257 |
if (doSync == true) { |
|
4258 |
XSync(dpy, 0); /* make certain everything is flushed */ |
|
4259 |
} |
|
4260 |
if (__isExternalAddress(aWindowIdOrNil)) { |
|
4261 |
win = _WindowVal(aWindowIdOrNil); |
|
4262 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
4263 |
} else { |
|
4264 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
4265 |
} |
|
4266 |
if (thereIsOne) { |
|
4267 |
XPutBackEvent(dpy, &ev); |
|
4268 |
RETURN ( true ); |
|
4269 |
} |
|
81 | 4270 |
} |
4271 |
RETURN ( false ); |
|
4272 |
%} |
|
4273 |
! |
|
4274 |
||
1344 | 4275 |
getEventFor:aViewIdOrNil withMask:eventMask |
295 | 4276 |
"read next event - put into local eventBuffer. |
4277 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
4278 |
otherwise only events for that specific view will be fetched. |
|
4279 |
Returns true, if there was an event, false otherwise. |
|
4280 |
This method may block - so you better check for pending events |
|
4281 |
before calling for it. |
|
4282 |
||
4283 |
Sorry I had to split dispatch into this fetch method and an extra |
|
4284 |
handle method to allow unlimitedstack here. |
|
4285 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
4286 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
4287 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
4288 |
display connections. |
|
4289 |
" |
|
81 | 4290 |
|
4291 |
%{ /* UNLIMITEDSTACK */ |
|
4292 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4293 |
Display *dpy; |
295 | 4294 |
Window win, wWanted; |
4295 |
int evMask; |
|
4296 |
OBJ eB; |
|
4297 |
XEvent *ev; |
|
4298 |
||
4299 |
if (! ISCONNECTED) { |
|
1344 | 4300 |
RETURN (false); |
295 | 4301 |
} |
4302 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4303 |
dpy = myDpy; |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
4304 |
|
555 | 4305 |
eB = __INST(eventBuffer); |
295 | 4306 |
if (__isByteArray(eB)) { |
1344 | 4307 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 4308 |
} else { |
1344 | 4309 |
printf("DISPLAY: no eventBuffer\n"); |
4310 |
RETURN (false); |
|
295 | 4311 |
} |
4312 |
ev->type = 0; |
|
4313 |
||
4314 |
if (__isSmallInteger(eventMask)) { |
|
1344 | 4315 |
evMask = __intVal(eventMask); |
295 | 4316 |
} else { |
1344 | 4317 |
evMask = ~0; |
295 | 4318 |
} |
4319 |
||
4320 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
1344 | 4321 |
wWanted = _WindowVal(aViewIdOrNil); |
4322 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
4323 |
RETURN ( true ); |
|
4324 |
} |
|
295 | 4325 |
} else { |
1344 | 4326 |
if (evMask == ~0) { |
4327 |
XNextEvent(dpy, ev); |
|
4328 |
RETURN (true); |
|
4329 |
} |
|
4330 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
4331 |
RETURN (true); |
|
4332 |
} |
|
295 | 4333 |
} |
4334 |
%}. |
|
4335 |
^ false |
|
4336 |
! |
|
4337 |
||
1344 | 4338 |
handleAllEvents |
295 | 4339 |
"from now on, handle any kind of event" |
4340 |
||
4341 |
dispatchingExpose := nil |
|
4342 |
! |
|
4343 |
||
1344 | 4344 |
handleExposeOnlyFor:aView |
295 | 4345 |
"from now on, handle expose events only" |
4346 |
||
4347 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4348 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4349 |
|
1344 | 4350 |
mappingChanged:what event:eB |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4351 |
"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
|
4352 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4353 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4354 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
1344 | 4355 |
self refreshKeyboardMapping:eB. |
4356 |
"Maybe some of our modifiers have been changed" |
|
4357 |
self initializeModifierMappings. |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4358 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4359 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
4360 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 4361 |
! |
4362 |
||
1344 | 4363 |
setEventMask:aMask in:aWindowId |
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
4364 |
"tell X that we are only interested in events from aMask, which |
295 | 4365 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
4366 |
||
4367 |
%{ /* NOCONTEXT */ |
|
4368 |
||
4369 |
int mask; |
|
4370 |
||
1209 | 4371 |
if (ISCONNECTED |
4372 |
&& __isExternalAddress(aWindowId) |
|
295 | 4373 |
&& __isSmallInteger(aMask)) { |
1344 | 4374 |
mask = __intVal(aMask); |
295 | 4375 |
|
4376 |
#ifdef OLD |
|
1344 | 4377 |
/* these may not be disabled */ |
4378 |
mask |= ExposureMask | StructureNotifyMask | |
|
4379 |
KeyPressMask | KeyReleaseMask | |
|
4380 |
EnterWindowMask | LeaveWindowMask | |
|
4381 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
295 | 4382 |
#endif |
4383 |
||
1344 | 4384 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
4385 |
RETURN ( self ); |
|
295 | 4386 |
} |
4387 |
%} |
|
4388 |
. |
|
4389 |
self primitiveFailed |
|
4390 |
! |
|
4391 |
||
1344 | 4392 |
startDispatch |
295 | 4393 |
"redefined to clear dispatchingExpose, which is a special X feature" |
4394 |
||
4395 |
dispatching ifTrue:[^ self]. |
|
4396 |
dispatchingExpose := nil. |
|
4397 |
super startDispatch |
|
0 | 4398 |
! ! |
295 | 4399 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4400 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4401 |
|
1344 | 4402 |
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
|
4403 |
"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
|
4404 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4405 |
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
|
4406 |
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
|
4407 |
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
|
4408 |
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
|
4409 |
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
|
4410 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4411 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4412 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4413 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4414 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4415 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4416 |
if (__isSmallInteger(stateMask)) { |
1344 | 4417 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4418 |
} else { |
1344 | 4419 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4420 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4421 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4422 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4423 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4424 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4425 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
1344 | 4426 |
Display *dpy = myDpy; |
4427 |
||
4428 |
XEvent ev; |
|
4429 |
Window target; |
|
4430 |
Status result; |
|
4431 |
KeySym keySym, *syms; |
|
4432 |
int screen = __intVal(__INST(screen)); |
|
4433 |
char s[2]; |
|
4434 |
int nSyms; |
|
4435 |
||
4436 |
if ((typeSymbol == @symbol(keyPress)) |
|
4437 |
|| (typeSymbol == @symbol(keyRelease))) { |
|
4438 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
|
4439 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
|
4440 |
} else { |
|
4441 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
|
4442 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
|
4443 |
s[1] = '\0'; |
|
4444 |
keySym = XStringToKeysym(s); |
|
4445 |
} else { |
|
4446 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
|
4447 |
} |
|
4448 |
} |
|
4449 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
|
4450 |
||
4451 |
if (stateMask == nil) { |
|
4452 |
/* |
|
4453 |
* get the modifier from the keySym |
|
4454 |
*/ |
|
4455 |
nSyms = 0; |
|
4456 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
|
4457 |
if (syms) { |
|
4458 |
int i; |
|
4459 |
||
4460 |
for (i=0; i<nSyms; i++) { |
|
4461 |
if (syms[i] == keySym) { |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4462 |
#ifdef MODIFIERDEBUG |
1344 | 4463 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4464 |
#endif |
1344 | 4465 |
if (i) state = (1 << (i-1)); |
4466 |
break; |
|
4467 |
} |
|
4468 |
} |
|
4469 |
XFree(syms); |
|
4470 |
} |
|
4471 |
} |
|
4472 |
} else { |
|
4473 |
if ((typeSymbol == @symbol(buttonPress)) |
|
4474 |
|| (typeSymbol == @symbol(buttonRelease))) { |
|
4475 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
|
4476 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
|
4477 |
} else { |
|
4478 |
ev.xbutton.button = 1; |
|
4479 |
} |
|
4480 |
} else { |
|
4481 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
|
4482 |
RETURN (false); |
|
4483 |
} |
|
4484 |
} |
|
4485 |
||
4486 |
if (typeSymbol == @symbol(keyPress)) |
|
4487 |
ev.xany.type = KeyPress; |
|
4488 |
else if (typeSymbol == @symbol(keyRelease)) |
|
4489 |
ev.xany.type = KeyRelease; |
|
4490 |
else if (typeSymbol == @symbol(buttonPress)) |
|
4491 |
ev.xany.type = ButtonPress; |
|
4492 |
else if (typeSymbol == @symbol(buttonRelease)) |
|
4493 |
ev.xany.type = ButtonRelease; |
|
4494 |
||
4495 |
if (__isExternalAddress(targetId)) { |
|
4496 |
target = _WindowVal(targetId); |
|
4497 |
} else { |
|
4498 |
target = (Window) __longIntVal(targetId); |
|
4499 |
} |
|
4500 |
ev.xkey.window = target; |
|
4501 |
ev.xkey.same_screen = 1; |
|
4502 |
ev.xkey.subwindow = 0; |
|
4503 |
ev.xkey.root = RootWindow(myDpy, screen); |
|
4504 |
ev.xkey.x = __intVal(xPos); |
|
4505 |
ev.xkey.y = __intVal(yPos); |
|
4506 |
ev.xkey.state = state; |
|
4507 |
ev.xkey.time = CurrentTime; |
|
4508 |
||
4509 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
|
4510 |
if ((result == BadValue) || (result == BadWindow)) { |
|
4511 |
DPRINTF(("bad status\n")); |
|
4512 |
RETURN ( false ) |
|
4513 |
} |
|
4514 |
RETURN (true) |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4515 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4516 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4517 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4518 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4519 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4520 |
|
1344 | 4521 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4522 |
"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
|
4523 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4524 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4525 |
Notice: not all alien views allow this kind of synthetic input; |
1344 | 4526 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4527 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4528 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4529 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4530 |
aCharacterOrString isString ifTrue:[ |
1344 | 4531 |
aCharacterOrString do:[:char | |
4532 |
self simulateKeyboardInput:char inViewId:viewId |
|
4533 |
]. |
|
4534 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4535 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4536 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4537 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4538 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4539 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4540 |
(aCharacterOrString == Character cr) ifTrue:[ |
1344 | 4541 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4542 |
] ifFalse:[ |
1344 | 4543 |
(aCharacterOrString == Character tab) ifTrue:[ |
4544 |
code := #Tab |
|
4545 |
] ifFalse:[ |
|
4546 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4547 |
code := #Escape |
|
4548 |
] |
|
4549 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4550 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4551 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4552 |
control ifTrue:[ |
1344 | 4553 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4554 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4555 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4556 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4557 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4558 |
"/ (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
|
4559 |
"/ 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
|
4560 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4561 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4562 |
code isNumber ifTrue:[ |
1344 | 4563 |
code >= $A asciiValue ifTrue:[ |
4564 |
code <= $Z asciiValue ifTrue:[ |
|
4565 |
state := self shiftMask |
|
4566 |
] |
|
4567 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4568 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4569 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4570 |
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
|
4571 |
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
|
4572 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4573 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4574 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4575 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4576 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4577 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4578 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4579 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4580 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4581 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4582 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4583 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4584 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4585 |
|
295 | 4586 |
!XWorkstation methodsFor:'font stuff'! |
4587 |
||
1344 | 4588 |
createFontFor:aFontName |
295 | 4589 |
"a basic method for X-font allocation; this method allows |
4590 |
any font to be aquired (even those not conforming to |
|
4591 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4592 |
||
4593 |
%{ /* UNLIMITEDSTACK */ |
|
4594 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4595 |
||
4596 |
XFontStruct *newFont; |
|
4597 |
||
4598 |
if (ISCONNECTED) { |
|
1344 | 4599 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
4600 |
BEGIN_INTERRUPTSBLOCKED |
|
4601 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4602 |
#ifdef COUNT_RESOURCES |
1344 | 4603 |
if (newFont) |
4604 |
__cnt_font++; |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
4605 |
#endif |
1344 | 4606 |
END_INTERRUPTSBLOCKED |
4607 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4608 |
} |
|
295 | 4609 |
} |
4610 |
%}. |
|
4611 |
^ nil |
|
4612 |
! |
|
4613 |
||
1344 | 4614 |
decomposeXFontName:aString into:aBlock |
295 | 4615 |
"extract family, face, style and size from an |
4616 |
X-font name |
|
4617 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4618 |
evaluate aBlock with these" |
|
4619 |
||
4620 |
|origin family face style moreStyle skip fheight size |
|
4621 |
resX resY x1 x2 coding start end | |
|
4622 |
||
4623 |
aString isNil ifTrue:[^ false]. |
|
4624 |
(aString startsWith:'-') ifFalse:[ |
|
1344 | 4625 |
" |
4626 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
4627 |
" |
|
4628 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
4629 |
end := aString indexOf:$- startingAt:1. |
|
4630 |
family := aString copyFrom:1 to:(end - 1). |
|
4631 |
start := end + 1. |
|
4632 |
end := aString indexOf:$- startingAt:start. |
|
4633 |
style := aString copyFrom:start to:(end - 1). |
|
4634 |
start := end + 1. |
|
4635 |
size := aString copyFrom:start. |
|
4636 |
size := (Number readFromString:size onError:[^false]). |
|
4637 |
aBlock value:family value:nil value:style value:size value:nil. |
|
4638 |
^ true. |
|
4639 |
]. |
|
4640 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
4641 |
" |
|
4642 |
something like lucidasans-24 |
|
4643 |
" |
|
4644 |
end := aString indexOf:$- startingAt:1. |
|
4645 |
||
4646 |
family := aString copyFrom:1 to:(end - 1). |
|
4647 |
start := end + 1. |
|
4648 |
size := aString copyFrom:start. |
|
4649 |
size := (Number readFromString:size onError:[^false]). |
|
4650 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
4651 |
^ true. |
|
4652 |
]. |
|
4653 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
4654 |
^ true. |
|
295 | 4655 |
]. |
4656 |
||
4657 |
end := aString indexOf:$- startingAt:2. |
|
4658 |
(end == 0) ifTrue:[^ false]. |
|
4659 |
origin := aString copyFrom:2 to:(end - 1). |
|
4660 |
||
4661 |
start := end + 1. |
|
4662 |
end := aString indexOf:$- startingAt:start. |
|
4663 |
(end == 0) ifTrue:[^ false]. |
|
4664 |
family := aString copyFrom:start to:(end - 1). |
|
4665 |
||
4666 |
start := end + 1. |
|
4667 |
end := aString indexOf:$- startingAt:start. |
|
4668 |
(end == 0) ifTrue:[^ false]. |
|
4669 |
face := aString copyFrom:start to:(end - 1). |
|
4670 |
||
4671 |
start := end + 1. |
|
4672 |
end := aString indexOf:$- startingAt:start. |
|
4673 |
(end == 0) ifTrue:[^ false]. |
|
4674 |
style := aString copyFrom:start to:(end - 1). |
|
4675 |
(style = 'o') ifTrue:[ |
|
1344 | 4676 |
style := 'oblique' |
295 | 4677 |
] ifFalse:[ |
1344 | 4678 |
(style = 'i') ifTrue:[ |
4679 |
style := 'italic' |
|
4680 |
] ifFalse:[ |
|
4681 |
(style = 'r') ifTrue:[ |
|
4682 |
style := 'roman' |
|
4683 |
] |
|
4684 |
] |
|
295 | 4685 |
]. |
4686 |
||
4687 |
start := end + 1. |
|
4688 |
end := aString indexOf:$- startingAt:start. |
|
4689 |
(end == 0) ifTrue:[^ false]. |
|
4690 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4691 |
||
4692 |
start := end + 1. |
|
4693 |
end := aString indexOf:$- startingAt:start. |
|
4694 |
(end == 0) ifTrue:[^ false]. |
|
4695 |
skip := aString copyFrom:start to:(end - 1). |
|
4696 |
||
4697 |
start := end + 1. |
|
4698 |
end := aString indexOf:$- startingAt:start. |
|
4699 |
(end == 0) ifTrue:[^ false]. |
|
4700 |
fheight := aString copyFrom:start to:(end - 1). |
|
4701 |
||
4702 |
start := end + 1. |
|
4703 |
end := aString indexOf:$- startingAt:start. |
|
4704 |
(end == 0) ifTrue:[^ false]. |
|
4705 |
size := aString copyFrom:start to:(end - 1). |
|
4706 |
size := (Number readFromString:size) / 10. |
|
4707 |
||
4708 |
start := end + 1. |
|
4709 |
end := aString indexOf:$- startingAt:start. |
|
4710 |
(end == 0) ifTrue:[^ false]. |
|
4711 |
resX := aString copyFrom:start to:(end - 1). |
|
4712 |
||
4713 |
start := end + 1. |
|
4714 |
end := aString indexOf:$- startingAt:start. |
|
4715 |
(end == 0) ifTrue:[^ false]. |
|
4716 |
resY := aString copyFrom:start to:(end - 1). |
|
4717 |
||
4718 |
start := end + 1. |
|
4719 |
end := aString indexOf:$- startingAt:start. |
|
4720 |
(end == 0) ifTrue:[^ false]. |
|
4721 |
x1 := aString copyFrom:start to:(end - 1). |
|
4722 |
||
4723 |
start := end + 1. |
|
4724 |
end := aString indexOf:$- startingAt:start. |
|
4725 |
(end == 0) ifTrue:[^ false]. |
|
4726 |
x2 := aString copyFrom:start to:(end - 1). |
|
4727 |
||
4728 |
start := end + 1. |
|
4729 |
end := aString indexOf:$- startingAt:start. |
|
4730 |
(end == 0) ifTrue:[^ false]. |
|
4731 |
coding := aString copyFrom:start to:(end - 1). |
|
4732 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4733 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
1344 | 4734 |
style := style, '-', moreStyle. |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4735 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4736 |
|
295 | 4737 |
aBlock value:family value:face value:style value:size value:coding. |
4738 |
^ true |
|
4739 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4740 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 4741 |
! |
4742 |
||
1344 | 4743 |
encodingOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4744 |
"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
|
4745 |
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
|
4746 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4747 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4748 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4749 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4750 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4751 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4752 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4753 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4754 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4755 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4756 |
if (ISCONNECTED) { |
1344 | 4757 |
Display *dpy = myDpy; |
4758 |
||
4759 |
registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True); |
|
4760 |
encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True); |
|
4761 |
charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True); |
|
4762 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
4763 |
||
4764 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4765 |
|
1344 | 4766 |
f = _FontVal(aFontId); |
4767 |
if (f) { |
|
4768 |
n = f->n_properties; |
|
4769 |
prop = f->properties; |
|
4770 |
if (prop) { |
|
4771 |
while (n--) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4772 |
#ifdef SUPERDEBUG |
1344 | 4773 |
cp = XGetAtomName(dpy, prop->name); |
4774 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
4775 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4776 |
#endif |
1344 | 4777 |
if (prop->name == XA_FULL_NAME) { |
4778 |
cp = XGetAtomName(dpy, prop->card32); |
|
4779 |
if (cp) { |
|
4780 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4781 |
#ifdef SUPERDEBUG |
1344 | 4782 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4783 |
#endif |
1344 | 4784 |
XFree(cp); |
4785 |
} |
|
4786 |
} else if (prop->name == fontAtom) { |
|
4787 |
cp = XGetAtomName(dpy, prop->card32); |
|
4788 |
if (cp) { |
|
4789 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4790 |
#ifdef SUPERDEBUG |
1344 | 4791 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4792 |
#endif |
1344 | 4793 |
XFree(cp); |
4794 |
} |
|
4795 |
} else if (prop->name == encodingAtom) { |
|
4796 |
cp = XGetAtomName(dpy, prop->card32); |
|
4797 |
if (cp) { |
|
4798 |
encoding = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4799 |
#ifdef SUPERDEBUG |
1344 | 4800 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4801 |
#endif |
1344 | 4802 |
XFree(cp); |
4803 |
} |
|
4804 |
} else if (prop->name == registryAtom) { |
|
4805 |
cp = XGetAtomName(dpy, prop->card32); |
|
4806 |
if (cp) { |
|
4807 |
registry = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4808 |
#ifdef SUPERDEBUG |
1344 | 4809 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4810 |
#endif |
1344 | 4811 |
XFree(cp); |
4812 |
} |
|
4813 |
} else if (prop->name == charSetCollAtom) { |
|
4814 |
cp = XGetAtomName(dpy, prop->card32); |
|
4815 |
if (cp) { |
|
4816 |
charSetCollections = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4817 |
#ifdef SUPERDEBUG |
1344 | 4818 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4819 |
#endif |
1344 | 4820 |
XFree(cp); |
4821 |
} |
|
4822 |
} |
|
4823 |
prop++; |
|
4824 |
} |
|
4825 |
} |
|
4826 |
} |
|
4827 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4828 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4829 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4830 |
^ self |
1344 | 4831 |
extractEncodingFromRegistry:registry |
4832 |
encoding:encoding |
|
4833 |
charSetCollections:charSetCollections |
|
4834 |
! |
|
4835 |
||
4836 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4837 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4838 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4839 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4840 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4841 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
1344 | 4842 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4843 |
] ifFalse:[ |
1344 | 4844 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4845 |
enc := encoding asLowercase asSymbol |
|
4846 |
] ifFalse:[ |
|
4847 |
charSets := charSetCollections. |
|
4848 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
4849 |
charSets := charSets asUppercase asCollectionOfWords. |
|
4850 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
4851 |
enc := #iso8859 |
|
4852 |
] ifFalse:[ |
|
4853 |
(charSets includes:'ISO8859') ifTrue:[ |
|
4854 |
enc := #iso8859 |
|
4855 |
] ifFalse:[ |
|
4856 |
(charSets includes:'ASCII') ifTrue:[ |
|
4857 |
enc := #ascii |
|
4858 |
] ifFalse:[ |
|
4859 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
4860 |
enc := #iso8859 |
|
4861 |
] |
|
4862 |
] |
|
4863 |
] |
|
4864 |
] |
|
4865 |
] |
|
4866 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4867 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4868 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4869 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4870 |
"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
|
4871 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4872 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4873 |
|
1344 | 4874 |
flushListOfAvailableFonts |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4875 |
"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
|
4876 |
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
|
4877 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4878 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4879 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4880 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4881 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4882 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4883 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4884 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4885 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4886 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4887 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4888 |
|
1344 | 4889 |
fontMetricsOf:fontId into:aBlock |
991 | 4890 |
"evaluate aBlock, passing a fonts metrics as arguments" |
4891 |
||
4892 |
|encoding avgAscent avgDescent |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4893 |
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
|
4894 |
res resX resY| |
991 | 4895 |
|
994 | 4896 |
%{ |
991 | 4897 |
XFontStruct *f; |
4898 |
int len; |
|
4899 |
||
4900 |
if (ISCONNECTED) { |
|
1344 | 4901 |
if (__isExternalAddress(fontId)) { |
4902 |
f = _FontVal(fontId); |
|
4903 |
if (f) { |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4904 |
#ifdef NOTDEF |
1344 | 4905 |
char *cp; |
4906 |
XFontProp *prop; |
|
4907 |
||
4908 |
n = f->n_properties; |
|
4909 |
prop = f->properties; |
|
4910 |
||
4911 |
if (prop) { |
|
4912 |
while (n--) { |
|
4913 |
if (prop->name == RESOLUTION_X) { |
|
4914 |
resX = __MKSMALLINT(prop->card32); |
|
4915 |
} else if (prop->name == RESOLUTION_Y) { |
|
4916 |
resY = __MKSMALLINT(prop->card32); |
|
4917 |
} else if (prop->name == RESOLUTION) { |
|
4918 |
res = __MKSMALLINT(prop->card32); |
|
4919 |
} |
|
4920 |
prop++; |
|
4921 |
} |
|
4922 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4923 |
#endif |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4924 |
|
1344 | 4925 |
avgAscent = __MKSMALLINT(f->ascent); |
4926 |
avgDescent = __MKSMALLINT(f->descent); |
|
4927 |
maxAscent = __MKSMALLINT(f->max_bounds.ascent); |
|
4928 |
maxDescent = __MKSMALLINT(f->max_bounds.descent); |
|
4929 |
minWidth = __MKSMALLINT(f->min_bounds.width); |
|
4930 |
maxWidth = __MKSMALLINT(f->max_bounds.width); |
|
4931 |
BEGIN_INTERRUPTSBLOCKED |
|
4932 |
len = XTextWidth(f, " ", 1); |
|
4933 |
END_INTERRUPTSBLOCKED |
|
4934 |
avgWidth = __MKSMALLINT( len ); |
|
4935 |
} |
|
4936 |
} |
|
991 | 4937 |
} |
4938 |
%}. |
|
4939 |
encoding := self encodingOf:fontId. |
|
4940 |
aBlock value:encoding |
|
1344 | 4941 |
value:avgAscent |
4942 |
value:avgDescent |
|
4943 |
value:maxAscent |
|
4944 |
value:maxDescent |
|
4945 |
value:minWidth |
|
4946 |
value:maxWidth |
|
4947 |
value:avgWidth |
|
4948 |
! |
|
4949 |
||
4950 |
fontResolutionOf:fontId |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4951 |
"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
|
4952 |
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
|
4953 |
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
|
4954 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4955 |
|res resX resY| |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4956 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4957 |
%{ |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4958 |
XFontStruct *f; |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4959 |
|
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4960 |
if (ISCONNECTED) { |
1344 | 4961 |
Display *dpy = myDpy; |
4962 |
||
4963 |
if (__isExternalAddress(fontId)) { |
|
4964 |
f = _FontVal(fontId); |
|
4965 |
if (f) { |
|
4966 |
char *cp; |
|
4967 |
XFontProp *prop; |
|
4968 |
Atom resolutionXAtom, resolutionYAtom; |
|
4969 |
int n; |
|
4970 |
||
4971 |
n = f->n_properties; |
|
4972 |
prop = f->properties; |
|
4973 |
||
4974 |
if (prop) { |
|
4975 |
resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True); |
|
4976 |
resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True); |
|
4977 |
||
4978 |
while (n--) { |
|
4979 |
if (prop->name == resolutionXAtom) { |
|
4980 |
resX = __MKSMALLINT(prop->card32); |
|
4981 |
} else if (prop->name == resolutionYAtom) { |
|
4982 |
resY = __MKSMALLINT(prop->card32); |
|
4983 |
} else if (prop->name == XA_RESOLUTION) { |
|
4984 |
res = __MKSMALLINT(prop->card32); |
|
4985 |
} |
|
4986 |
prop++; |
|
4987 |
} |
|
4988 |
} |
|
4989 |
} |
|
4990 |
} |
|
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4991 |
} |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4992 |
%}. |
1046 | 4993 |
(resX notNil and:[resY notNil]) ifTrue:[ |
1344 | 4994 |
^ resX @ resY |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4995 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4996 |
res notNil ifTrue:[ |
1344 | 4997 |
^ res @ res |
1045
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4998 |
]. |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
4999 |
^ self resolution |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5000 |
! |
b03222053583
added query for a fonts real resolution (kludge for X)
Claus Gittinger <cg@exept.de>
parents:
1030
diff
changeset
|
5001 |
|
1344 | 5002 |
fullNameOf:aFontId |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5003 |
"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
|
5004 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5005 |
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
|
5006 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5007 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5008 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5009 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5010 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5011 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5012 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5013 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5014 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5015 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5016 |
if (ISCONNECTED) { |
1344 | 5017 |
Display *dpy = myDpy; |
5018 |
||
5019 |
fontAtom = XInternAtom(dpy, "FONT", True); |
|
5020 |
||
5021 |
if (__isExternalAddress(aFontId)) { |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5022 |
|
1344 | 5023 |
f = _FontVal(aFontId); |
5024 |
if (f) { |
|
5025 |
n = f->n_properties; |
|
5026 |
prop = f->properties; |
|
5027 |
if (prop) { |
|
5028 |
while (n--) { |
|
1049
59cc92776676
oops - free XGetAtomName string after use
Claus Gittinger <cg@exept.de>
parents:
1047
diff
changeset
|
5029 |
#ifdef SUPERDEBUG |
1344 | 5030 |
cp = XGetAtomName(dpy, prop->name); |
5031 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
|
5032 |
XFree(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5033 |
#endif |
1344 | 5034 |
if (prop->name == XA_FULL_NAME) { |
5035 |
cp = XGetAtomName(dpy, prop->card32); |
|
5036 |
if (cp) { |
|
5037 |
fullName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5038 |
#ifdef SUPERDEBUG |
1344 | 5039 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5040 |
#endif |
1344 | 5041 |
XFree(cp); |
5042 |
} |
|
5043 |
} |
|
5044 |
if (prop->name == fontAtom) { |
|
5045 |
cp = XGetAtomName(dpy, prop->card32); |
|
5046 |
if (cp) { |
|
5047 |
fontName = __MKSTRING(cp); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5048 |
#ifdef SUPERDEBUG |
1344 | 5049 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5050 |
#endif |
1344 | 5051 |
XFree(cp); |
5052 |
} |
|
5053 |
} |
|
5054 |
prop++; |
|
5055 |
} |
|
5056 |
} |
|
5057 |
} |
|
5058 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5059 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5060 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5061 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
1344 | 5062 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5063 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5064 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5065 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
5066 |
|
1344 | 5067 |
getAvailableFontsMatching:pattern |
295 | 5068 |
"return an Array filled with font names matching aPattern" |
5069 |
||
5070 |
%{ /* UNLIMITEDSTACK */ |
|
5071 |
||
5072 |
int nnames = 1500; |
|
5073 |
int available = nnames + 1; |
|
5074 |
char **fonts; |
|
5075 |
OBJ arr, str; |
|
5076 |
int i; |
|
5077 |
||
5078 |
if (ISCONNECTED) { |
|
1344 | 5079 |
if (__isString(pattern)) { |
5080 |
for (;;) { |
|
5081 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
5082 |
if ((fonts == NULL) || (available < nnames)) break; |
|
5083 |
XFreeFontNames(fonts); |
|
5084 |
nnames = available * 2; |
|
5085 |
} |
|
5086 |
if (fonts == NULL) { |
|
5087 |
RETURN ( nil ); |
|
5088 |
} |
|
5089 |
/* |
|
5090 |
* now, that we know the number of font names, |
|
5091 |
* create the array ... |
|
5092 |
*/ |
|
5093 |
arr = __ARRAY_NEW_INT(available); |
|
5094 |
if (! arr) { |
|
5095 |
RETURN (nil); |
|
5096 |
} |
|
5097 |
/* |
|
5098 |
* ... and fill it |
|
5099 |
*/ |
|
5100 |
for (i=0; i<available; i++) { |
|
5101 |
__PROTECT__(arr); |
|
5102 |
str = __MKSTRING(fonts[i]); |
|
5103 |
__UNPROTECT__(arr); |
|
5104 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
|
5105 |
} |
|
5106 |
RETURN (arr); |
|
5107 |
} |
|
295 | 5108 |
} |
5109 |
%}. |
|
5110 |
^ nil |
|
5111 |
! |
|
5112 |
||
1344 | 5113 |
getDefaultFont |
295 | 5114 |
"return a default font id - used when class Font cannot |
5115 |
find anything usable" |
|
5116 |
||
5117 |
^ self createFontFor:'fixed' |
|
5118 |
! |
|
5119 |
||
1344 | 5120 |
getFontWithFamily:familyString face:faceString |
5121 |
style:styleArgString size:sizeArg encoding:encodingSym |
|
295 | 5122 |
|
5123 |
"try to get the specified font, if not available, try next smaller |
|
5124 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
5125 |
as family and the other parameters as nil. For example, the cursor font |
|
5126 |
can be aquired that way." |
|
5127 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5128 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5129 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5130 |
styleString := styleArgString. |
295 | 5131 |
|
5132 |
"special: if face is nil, allow access to X-fonts" |
|
5133 |
faceString isNil ifTrue:[ |
|
1344 | 5134 |
sizeArg notNil ifTrue:[ |
5135 |
theName := familyString , '-' , sizeArg printString |
|
5136 |
] ifFalse:[ |
|
5137 |
theName := familyString |
|
5138 |
]. |
|
5139 |
theName isNil ifTrue:[ |
|
5140 |
" |
|
5141 |
mhmh - fall back to the default font |
|
5142 |
" |
|
5143 |
theName := 'fixed' |
|
5144 |
]. |
|
5145 |
theId := self createFontFor:theName. |
|
5146 |
theId isNil ifTrue:[ |
|
5147 |
theId := self getDefaultFont |
|
5148 |
]. |
|
5149 |
^ theId |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5150 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5151 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5152 |
"/ 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
|
5153 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5154 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5155 |
((styleString endsWith:'-narrow') |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5156 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
1344 | 5157 |
|i| |
5158 |
i := styleString lastIndexOf:$-. |
|
5159 |
spacing := styleString copyFrom:(i+1). |
|
5160 |
styleString := styleString copyTo:(i-1). |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5161 |
] ifFalse:[ |
1344 | 5162 |
spacing := 'normal'. |
295 | 5163 |
]. |
5164 |
||
5165 |
xlatedStyle := styleString. |
|
5166 |
xlatedStyle notNil ifTrue:[ |
|
1344 | 5167 |
xlatedStyle := xlatedStyle first asString |
295 | 5168 |
]. |
5169 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5170 |
id := self |
1344 | 5171 |
getFontWithFoundry:'*' |
5172 |
family:familyString asLowercase |
|
5173 |
weight:faceString |
|
5174 |
slant:xlatedStyle |
|
5175 |
spacing:spacing |
|
5176 |
pixelSize:nil |
|
5177 |
size:sizeArg |
|
5178 |
registry:encodingSym |
|
5179 |
encoding:'*'. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5180 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5181 |
id isNil ifTrue:[ |
1344 | 5182 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
5183 |
"/ too stupid: encodings come in both cases |
|
5184 |
"/ and X does not ignore case |
|
5185 |
"/ |
|
5186 |
id := self |
|
5187 |
getFontWithFoundry:'*' |
|
5188 |
family:familyString asLowercase |
|
5189 |
weight:faceString |
|
5190 |
slant:xlatedStyle |
|
5191 |
spacing:spacing |
|
5192 |
pixelSize:nil |
|
5193 |
size:sizeArg |
|
5194 |
registry:encodingSym asUppercase |
|
5195 |
encoding:'*'. |
|
5196 |
id isNil ifTrue:[ |
|
5197 |
id := self |
|
5198 |
getFontWithFoundry:'*' |
|
5199 |
family:familyString asLowercase |
|
5200 |
weight:faceString |
|
5201 |
slant:xlatedStyle |
|
5202 |
spacing:spacing |
|
5203 |
pixelSize:nil |
|
5204 |
size:sizeArg |
|
5205 |
registry:encodingSym asLowercase |
|
5206 |
encoding:'*'. |
|
5207 |
] |
|
5208 |
] |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5209 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5210 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5211 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5212 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
5213 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
295 | 5214 |
! |
5215 |
||
1344 | 5216 |
getFontWithFoundry:foundry family:family weight:weight |
5217 |
slant:slant spacing:spc pixelSize:pSize size:size |
|
5218 |
registry:registry encoding:encoding |
|
295 | 5219 |
|
5220 |
"get the specified font, if not available, return nil. |
|
5221 |
This is the new font creation method - all others will be changed to |
|
5222 |
use this entry. |
|
5223 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
5224 |
||
5225 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
5226 |
family: 'helvetica' 'courier' 'times' ... |
|
5227 |
weight: 'bold' 'medium' 'demi' ... |
|
5228 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
5229 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
5230 |
pixelSize: 16,18 ... usually left empty |
|
5231 |
size: size in point (1/72th of an inch) |
|
5232 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5233 |
encoding: vendor specific encoding (usually '*') |
295 | 5234 |
" |
5235 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5236 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5237 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
1099 | 5238 |
pSizeMatch registryMatch encodingMatch| |
295 | 5239 |
|
5240 |
"this works only on 'Release >= 3' - X-servers" |
|
5241 |
"name is: |
|
1344 | 5242 |
-foundry-family -weight -slant- |
5243 |
sony helvetica bold r |
|
5244 |
adobe courier medium i |
|
5245 |
msic fixed o |
|
5246 |
... ... |
|
295 | 5247 |
" |
5248 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5249 |
size isNil ifTrue:[ |
1344 | 5250 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5251 |
] ifFalse:[ |
1344 | 5252 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5253 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5254 |
foundry isNil ifTrue:[ |
1344 | 5255 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5256 |
] ifFalse:[ |
1344 | 5257 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5258 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5259 |
family isNil ifTrue:[ |
1344 | 5260 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5261 |
] ifFalse:[ |
1344 | 5262 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5263 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5264 |
weight isNil ifTrue:[ |
1344 | 5265 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5266 |
] ifFalse:[ |
1344 | 5267 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5268 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5269 |
slant isNil ifTrue:[ |
1344 | 5270 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5271 |
] ifFalse:[ |
1344 | 5272 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5273 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5274 |
spc isNil ifTrue:[ |
1344 | 5275 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5276 |
] ifFalse:[ |
1344 | 5277 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5278 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5279 |
pSize isNil ifTrue:[ |
1344 | 5280 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5281 |
] ifFalse:[ |
1344 | 5282 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5283 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5284 |
registry isNil ifTrue:[ |
1344 | 5285 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5286 |
] ifFalse:[ |
1344 | 5287 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5288 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5289 |
encoding isNil ifTrue:[ |
1344 | 5290 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5291 |
] ifFalse:[ |
1344 | 5292 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5293 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5294 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5295 |
theName := ('-' , foundryMatch, |
1344 | 5296 |
'-' , familyMatch, |
5297 |
'-' , weightMatch , |
|
5298 |
'-' , slantMatch , |
|
5299 |
'-' , spcMatch , |
|
5300 |
'-*' , |
|
5301 |
'-' , pSizeMatch , |
|
5302 |
'-' , sizeMatch , |
|
5303 |
'-*-*-*-*' , |
|
5304 |
'-' , registryMatch , |
|
5305 |
'-' , encodingMatch). |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5306 |
|
697 | 5307 |
"/ Transcript showCR:theName; endEntry. |
295 | 5308 |
|
5309 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5310 |
|
295 | 5311 |
|
5312 |
" |
|
5313 |
Display getFontWithFoundry:'*' |
|
1344 | 5314 |
family:'courier' |
5315 |
weight:'medium' |
|
5316 |
slant:'r' |
|
5317 |
spacing:nil |
|
5318 |
pixelSize:nil |
|
5319 |
size:13 |
|
5320 |
registry:'iso8859' |
|
5321 |
encoding:'*' |
|
295 | 5322 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5323 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
5324 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 5325 |
! |
5326 |
||
1344 | 5327 |
listOfAvailableFonts |
295 | 5328 |
"return a list with all available fonts on this display. |
5329 |
Since this takes a long time, keep the result of the query for the |
|
5330 |
next time. The elements of the returned collection are instances of |
|
5331 |
FontDescription." |
|
5332 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
5333 |
|"stream aName fntDescr" names| |
295 | 5334 |
|
5335 |
listOfXFonts isNil ifTrue:[ |
|
5336 |
"/ |
|
5337 |
"/ old code; using a pipe to xlsfonts |
|
5338 |
"/ |
|
5339 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
5340 |
"/ stream isNil ifTrue:[^ nil]. |
|
5341 |
"/ listOfXFonts := OrderedCollection new. |
|
5342 |
"/ [stream atEnd] whileFalse:[ |
|
5343 |
"/ aName := stream nextLine. |
|
5344 |
"/ aName notNil ifTrue:[ |
|
5345 |
"/ self decomposeXFontName:aName into: |
|
5346 |
"/ [:family :face :style :size :coding | |
|
5347 |
"/ family notNil ifTrue:[ |
|
5348 |
"/ fntDescr := FontDescription |
|
5349 |
"/ family:family |
|
5350 |
"/ face:face |
|
5351 |
"/ style:style |
|
5352 |
"/ size:size |
|
5353 |
"/ encoding:coding. |
|
5354 |
"/ listOfXFonts add:fntDescr |
|
5355 |
"/ ] |
|
5356 |
"/ ] |
|
5357 |
"/ ] |
|
5358 |
"/ ]. |
|
5359 |
"/ stream close. |
|
5360 |
"/ "if xlsfont is broken ... (hey sco)" |
|
5361 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
5362 |
"/ listOfXFonts := nil |
|
5363 |
"/ ] ifFalse:[ |
|
5364 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
5365 |
"/ ]. |
|
5366 |
||
1344 | 5367 |
"/ |
5368 |
"/ new code: |
|
5369 |
"/ use new primitive to get font names; |
|
5370 |
"/ this is much faster, and also works on systems where |
|
5371 |
"/ a) xlsfonts is broken (sco) |
|
5372 |
"/ b) xlsfonts is not available (aix) |
|
5373 |
"/ |
|
5374 |
names := self getAvailableFontsMatching:'*'. |
|
5375 |
names isNil ifTrue:[ |
|
5376 |
"no names returned ..." |
|
5377 |
^ nil |
|
5378 |
]. |
|
5379 |
listOfXFonts := names collect:[:aName | |
|
5380 |
|fntDescr| |
|
5381 |
||
5382 |
(self decomposeXFontName:aName into: |
|
5383 |
[:family :face :style :size :coding | |
|
5384 |
family notNil ifTrue:[ |
|
5385 |
fntDescr := FontDescription |
|
5386 |
family:family |
|
5387 |
face:face |
|
5388 |
style:style |
|
5389 |
size:size |
|
5390 |
encoding:coding. |
|
5391 |
] ifFalse:[ |
|
5392 |
fntDescr := FontDescription |
|
5393 |
name:aName |
|
5394 |
] |
|
5395 |
] |
|
5396 |
) ifFalse:[ |
|
5397 |
fntDescr := FontDescription name:aName. |
|
5398 |
]. |
|
5399 |
fntDescr |
|
5400 |
]. |
|
295 | 5401 |
|
5402 |
]. |
|
5403 |
^ listOfXFonts |
|
5404 |
||
5405 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5406 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5407 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
5408 |
Display getAvailableFontsMatching:'*'. |
295 | 5409 |
" |
5410 |
||
5411 |
"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
|
5412 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 5413 |
! |
5414 |
||
1344 | 5415 |
releaseFont:aFontId |
295 | 5416 |
|
5417 |
%{ /* NOCONTEXT */ |
|
5418 |
||
5419 |
XFontStruct *f; |
|
5420 |
||
1212 | 5421 |
if (! ISCONNECTED) { |
1344 | 5422 |
RETURN ( self ); |
1212 | 5423 |
} |
5424 |
||
5425 |
if (__isExternalAddress(aFontId)) { |
|
1344 | 5426 |
f = _FontVal(aFontId); |
5427 |
if (f) { |
|
5428 |
BEGIN_INTERRUPTSBLOCKED |
|
5429 |
XFreeFont(myDpy, f); |
|
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5430 |
#ifdef COUNT_RESOURCES |
1344 | 5431 |
__cnt_font--; |
923
64bbcd3ee100
added debug counting of X resource allocation
Claus Gittinger <cg@exept.de>
parents:
918
diff
changeset
|
5432 |
#endif |
1344 | 5433 |
END_INTERRUPTSBLOCKED |
5434 |
RETURN ( self ); |
|
5435 |
} |
|
295 | 5436 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5437 |
%}. |
295 | 5438 |
self primitiveFailed |
5439 |
! |
|
5440 |
||
1344 | 5441 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5442 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5443 |
on this display. |
|
5444 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5445 |
||
5446 |
|sizes| |
|
5447 |
||
466 | 5448 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5449 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
1344 | 5450 |
"special: in X11R5 and above, size 0 means: |
5451 |
there are scaled versions in all sizes available" |
|
5452 |
||
5453 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
|
295 | 5454 |
]. |
5455 |
^ sizes |
|
5456 |
||
5457 |
" |
|
5458 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5459 |
" |
|
466 | 5460 |
|
5461 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5462 |
! |
5463 |
||
1344 | 5464 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
295 | 5465 |
|
5466 |
%{ /* NOCONTEXT */ |
|
5467 |
||
5468 |
XFontStruct *f; |
|
5469 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5470 |
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
|
5471 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5472 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5473 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5474 |
int nInstBytes; |
295 | 5475 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5476 |
if (ISCONNECTED) { |
1344 | 5477 |
if (__bothSmallInteger(index1, index2) |
5478 |
&& __isExternalAddress(aFontId) |
|
5479 |
&& __isNonNilObject(aString)) { |
|
5480 |
f = _FontVal(aFontId); |
|
5481 |
if (! f) goto fail; |
|
5482 |
||
5483 |
i1 = __intVal(index1) - 1; |
|
5484 |
cls = __qClass(aString); |
|
5485 |
||
5486 |
if (i1 >= 0) { |
|
5487 |
i2 = __intVal(index2) - 1; |
|
5488 |
if (i2 < i1) { |
|
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5489 |
RETURN ( __MKSMALLINT(0) ); |
1344 | 5490 |
} |
5491 |
||
5492 |
cp = (char *) _stringVal(aString); |
|
5493 |
l = i2 - i1 + 1; |
|
5494 |
||
5495 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5496 |
n = _stringSize(aString); |
|
5497 |
if (i2 < n) { |
|
5498 |
cp += i1; |
|
5499 |
BEGIN_INTERRUPTSBLOCKED |
|
5500 |
len = XTextWidth(f, cp, l); |
|
5501 |
END_INTERRUPTSBLOCKED |
|
5502 |
RETURN ( __MKSMALLINT(len) ); |
|
5503 |
} |
|
5504 |
} |
|
5505 |
||
5506 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5507 |
cp += nInstBytes; |
|
5508 |
||
5509 |
if (__isBytes(aString)) { |
|
5510 |
n = __byteArraySize(aString) - nInstBytes; |
|
5511 |
if (i2 < n) { |
|
5512 |
cp += i1; |
|
5513 |
BEGIN_INTERRUPTSBLOCKED |
|
5514 |
len = XTextWidth(f, cp, l); |
|
5515 |
END_INTERRUPTSBLOCKED |
|
5516 |
RETURN ( __MKSMALLINT(len) ); |
|
5517 |
} |
|
5518 |
} |
|
5519 |
||
5520 |
/* TWOBYTESTRINGS */ |
|
5521 |
if (__isWords(aString)) { |
|
5522 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5523 |
||
5524 |
if (i2 < n) { |
|
5525 |
union { |
|
5526 |
char b[2]; |
|
5527 |
unsigned short s; |
|
5528 |
} u; |
|
5529 |
int i; |
|
5530 |
XChar2b *cp2 = (XChar2b *)0; |
|
5531 |
int mustFree = 0; |
|
5532 |
||
5533 |
cp += (i1 * 2); |
|
5534 |
if (l > 1000) l = 1000; |
|
5535 |
||
5536 |
/* |
|
5537 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5538 |
* X expects them MSB first |
|
5539 |
* convert as required |
|
5540 |
*/ |
|
5541 |
||
5542 |
u.s = 0x1234; |
|
5543 |
if (u.b[0] != 0x12) { |
|
5544 |
if (l <= NLOCALBUFFER) { |
|
5545 |
cp2 = xlatebuffer; |
|
5546 |
} else { |
|
5547 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5548 |
mustFree = 1; |
|
5549 |
} |
|
5550 |
for (i=0; i<l; i++) { |
|
5551 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5552 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5553 |
} |
|
5554 |
cp = (char *) cp2; |
|
5555 |
} |
|
5556 |
BEGIN_INTERRUPTSBLOCKED |
|
5557 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
5558 |
END_INTERRUPTSBLOCKED |
|
5559 |
||
5560 |
if (mustFree) { |
|
5561 |
free(cp2); |
|
5562 |
} |
|
5563 |
||
5564 |
RETURN ( __MKSMALLINT(len) ); |
|
5565 |
} |
|
5566 |
} |
|
5567 |
} |
|
5568 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5569 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5570 |
#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
|
5571 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5572 |
%}. |
295 | 5573 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5574 |
^ 0 |
295 | 5575 |
! |
5576 |
||
1344 | 5577 |
widthOf:aString inFont:aFontId |
295 | 5578 |
|
5579 |
%{ /* NOCONTEXT */ |
|
5580 |
||
5581 |
XFontStruct *f; |
|
5582 |
char *cp; |
|
5583 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5584 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5585 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5586 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5587 |
int nInstBytes; |
295 | 5588 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5589 |
if (ISCONNECTED) { |
1344 | 5590 |
if (__isExternalAddress(aFontId) |
5591 |
&& __isNonNilObject(aString)) { |
|
5592 |
f = _FontVal(aFontId); |
|
5593 |
if (! f) goto fail; |
|
5594 |
||
5595 |
cls = __qClass(aString); |
|
5596 |
||
5597 |
cp = (char *)_stringVal(aString); |
|
5598 |
||
5599 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5600 |
n = _stringSize(aString); |
|
5601 |
BEGIN_INTERRUPTSBLOCKED |
|
5602 |
len = XTextWidth(f, cp, n); |
|
5603 |
END_INTERRUPTSBLOCKED |
|
5604 |
RETURN ( __MKSMALLINT(len) ); |
|
5605 |
} |
|
5606 |
||
5607 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5608 |
cp += nInstBytes; |
|
5609 |
||
5610 |
if (__isBytes(aString)) { |
|
5611 |
n = __byteArraySize(aString) - nInstBytes; |
|
5612 |
||
5613 |
BEGIN_INTERRUPTSBLOCKED |
|
5614 |
len = XTextWidth(f, cp, n); |
|
5615 |
END_INTERRUPTSBLOCKED |
|
5616 |
RETURN ( __MKSMALLINT(len) ); |
|
5617 |
} |
|
5618 |
||
5619 |
/* TWOBYTESTRINGS */ |
|
5620 |
if (__isWords(aString)) { |
|
5621 |
union { |
|
5622 |
char b[2]; |
|
5623 |
unsigned short s; |
|
5624 |
} u; |
|
5625 |
int i; |
|
5626 |
XChar2b *cp2; |
|
5627 |
int mustFree = 0; |
|
5628 |
||
5629 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5630 |
if (n > 1000) n = 1000; |
|
5631 |
||
5632 |
/* |
|
5633 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5634 |
* X expects them MSB first |
|
5635 |
* convert as required |
|
5636 |
*/ |
|
5637 |
||
5638 |
u.s = 0x1234; |
|
5639 |
if (u.b[0] != 0x12) { |
|
5640 |
if (n <= NLOCALBUFFER) { |
|
5641 |
cp2 = xlatebuffer; |
|
5642 |
} else { |
|
5643 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
5644 |
mustFree = 1; |
|
5645 |
} |
|
5646 |
||
5647 |
for (i=0; i<n; i++) { |
|
5648 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5649 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5650 |
} |
|
5651 |
cp = (char *) cp2; |
|
5652 |
} |
|
5653 |
||
5654 |
BEGIN_INTERRUPTSBLOCKED |
|
5655 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
5656 |
END_INTERRUPTSBLOCKED |
|
5657 |
||
5658 |
if (mustFree) { |
|
5659 |
free(cp2); |
|
5660 |
} |
|
5661 |
||
5662 |
RETURN ( __MKSMALLINT(len) ); |
|
5663 |
} |
|
5664 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5665 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5666 |
#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
|
5667 |
fail: ; |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5668 |
%}. |
295 | 5669 |
self primitiveFailed. |
1361
784d654780e6
added circulate event hooks;
Claus Gittinger <cg@exept.de>
parents:
1345
diff
changeset
|
5670 |
^ 0 |
295 | 5671 |
! ! |
5672 |
||
5673 |
!XWorkstation methodsFor:'grabbing '! |
|
5674 |
||
1344 | 5675 |
allowEvents:mode |
295 | 5676 |
%{ /* NOCONTEXT */ |
5677 |
||
5678 |
int _mode, ok = 1; |
|
5679 |
||
5680 |
if (mode == @symbol(asyncPointer)) |
|
1344 | 5681 |
_mode = AsyncPointer; |
295 | 5682 |
else if (mode == @symbol(syncPointer)) |
1344 | 5683 |
_mode = SyncPointer; |
295 | 5684 |
else if (mode == @symbol(asyncKeyboard)) |
1344 | 5685 |
_mode = AsyncKeyboard; |
295 | 5686 |
else if (mode == @symbol(syncKeyboard)) |
1344 | 5687 |
_mode = SyncKeyboard; |
295 | 5688 |
else if (mode == @symbol(syncBoth)) |
1344 | 5689 |
_mode = SyncBoth; |
295 | 5690 |
else if (mode == @symbol(asyncBoth)) |
1344 | 5691 |
_mode = AsyncBoth; |
295 | 5692 |
else if (mode == @symbol(replayPointer)) |
1344 | 5693 |
_mode = ReplayPointer; |
295 | 5694 |
else if (mode == @symbol(replayKeyboard)) |
1344 | 5695 |
_mode = ReplayKeyboard; |
295 | 5696 |
else |
1344 | 5697 |
ok = 0; |
295 | 5698 |
|
5699 |
if (ok) { |
|
1344 | 5700 |
if (ISCONNECTED) { |
5701 |
BEGIN_INTERRUPTSBLOCKED |
|
5702 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5703 |
END_INTERRUPTSBLOCKED |
|
5704 |
RETURN (self); |
|
5705 |
} |
|
295 | 5706 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5707 |
%}. |
295 | 5708 |
self primitiveFailed |
5709 |
! |
|
5710 |
||
1344 | 5711 |
grabKeyboardIn:aWindowId |
295 | 5712 |
"grab the keyboard" |
5713 |
||
5714 |
%{ /* NOCONTEXT */ |
|
5715 |
int result, ok; |
|
5716 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5717 |
if (ISCONNECTED) { |
1344 | 5718 |
if (__isExternalAddress(aWindowId)) { |
5719 |
BEGIN_INTERRUPTSBLOCKED |
|
5720 |
result = XGrabKeyboard(myDpy, |
|
5721 |
_WindowVal(aWindowId), |
|
5722 |
True /* False */, |
|
5723 |
GrabModeAsync, |
|
5724 |
GrabModeAsync, |
|
5725 |
CurrentTime); |
|
5726 |
END_INTERRUPTSBLOCKED |
|
5727 |
ok = 0; |
|
5728 |
switch(result) { |
|
5729 |
case AlreadyGrabbed: |
|
5730 |
if (@global(ErrorPrinting) == true) { |
|
5731 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n"); |
|
5732 |
} |
|
5733 |
break; |
|
5734 |
case GrabNotViewable: |
|
5735 |
if (@global(ErrorPrinting) == true) { |
|
5736 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n"); |
|
5737 |
} |
|
5738 |
break; |
|
5739 |
case GrabInvalidTime: |
|
5740 |
if (@global(ErrorPrinting) == true) { |
|
5741 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n"); |
|
5742 |
} |
|
5743 |
break; |
|
5744 |
case GrabFrozen: |
|
5745 |
if (@global(ErrorPrinting) == true) { |
|
5746 |
fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n"); |
|
5747 |
} |
|
5748 |
break; |
|
5749 |
default: |
|
5750 |
ok = 1; |
|
5751 |
break; |
|
5752 |
} |
|
5753 |
if (! ok) { |
|
5754 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5755 |
RETURN (false); |
|
5756 |
} |
|
5757 |
||
5758 |
RETURN ( true ); |
|
5759 |
} |
|
295 | 5760 |
} |
1183 | 5761 |
%}. |
295 | 5762 |
self primitiveFailed |
5763 |
! |
|
5764 |
||
1344 | 5765 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
295 | 5766 |
"grap the pointer - return true if ok" |
5767 |
||
5768 |
%{ /* NOCONTEXT */ |
|
5769 |
||
5770 |
int result, ok; |
|
5771 |
Window confineWin; |
|
5772 |
Cursor curs; |
|
5773 |
int pointer_mode, keyboard_mode; |
|
5774 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5775 |
if (ISCONNECTED) { |
1344 | 5776 |
if (__isExternalAddress(aWindowId)) { |
5777 |
if (__isExternalAddress(confineId)) |
|
5778 |
confineWin = _WindowVal(confineId); |
|
5779 |
else |
|
5780 |
confineWin = (Window) None; |
|
5781 |
||
5782 |
if (__isExternalAddress(aCursorId)) |
|
5783 |
curs = _CursorVal(aCursorId); |
|
5784 |
else |
|
5785 |
curs = (Cursor) None; |
|
5786 |
||
5787 |
if (pMode == @symbol(sync)) |
|
5788 |
pointer_mode = GrabModeSync; |
|
5789 |
else |
|
5790 |
pointer_mode = GrabModeAsync; |
|
5791 |
||
5792 |
if (kMode == @symbol(sync)) |
|
5793 |
keyboard_mode = GrabModeSync; |
|
5794 |
else |
|
5795 |
keyboard_mode = GrabModeAsync; |
|
5796 |
||
5797 |
BEGIN_INTERRUPTSBLOCKED |
|
5798 |
result = XGrabPointer(myDpy, |
|
5799 |
_WindowVal(aWindowId), |
|
5800 |
False, |
|
5801 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5802 |
pointer_mode, keyboard_mode, |
|
5803 |
confineWin, |
|
5804 |
curs, |
|
5805 |
CurrentTime); |
|
5806 |
END_INTERRUPTSBLOCKED |
|
5807 |
||
5808 |
ok = 0; |
|
5809 |
switch (result) { |
|
5810 |
case AlreadyGrabbed: |
|
5811 |
if (@global(ErrorPrinting) == true) { |
|
5812 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n"); |
|
5813 |
} |
|
5814 |
break; |
|
5815 |
case GrabNotViewable: |
|
5816 |
if (@global(ErrorPrinting) == true) { |
|
5817 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n"); |
|
5818 |
} |
|
5819 |
break; |
|
5820 |
case GrabInvalidTime: |
|
5821 |
if (@global(ErrorPrinting) == true) { |
|
5822 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n"); |
|
5823 |
} |
|
5824 |
break; |
|
5825 |
case GrabFrozen: |
|
5826 |
if (@global(ErrorPrinting) == true) { |
|
5827 |
fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n"); |
|
5828 |
} |
|
5829 |
break; |
|
5830 |
default: |
|
5831 |
ok = 1; |
|
5832 |
break; |
|
5833 |
} |
|
5834 |
||
5835 |
if (! ok) { |
|
5836 |
XUngrabPointer(myDpy, CurrentTime); |
|
5837 |
RETURN (false); |
|
5838 |
} |
|
5839 |
RETURN ( true ); |
|
5840 |
} |
|
295 | 5841 |
} |
1183 | 5842 |
%}. |
295 | 5843 |
self primitiveFailed |
5844 |
! |
|
5845 |
||
1344 | 5846 |
ungrabKeyboard |
295 | 5847 |
"release the keyboard" |
5848 |
||
5849 |
%{ /* NOCONTEXT */ |
|
5850 |
||
5851 |
if (ISCONNECTED) { |
|
1344 | 5852 |
BEGIN_INTERRUPTSBLOCKED |
5853 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5854 |
XSync(myDpy, 0); |
|
5855 |
END_INTERRUPTSBLOCKED |
|
295 | 5856 |
} |
5857 |
%}. |
|
5858 |
activeKeyboardGrab := nil |
|
5859 |
! |
|
5860 |
||
1344 | 5861 |
ungrabPointer |
295 | 5862 |
"release the pointer" |
5863 |
||
5864 |
%{ /* NOCONTEXT */ |
|
5865 |
||
5866 |
if (ISCONNECTED) { |
|
1344 | 5867 |
BEGIN_INTERRUPTSBLOCKED |
5868 |
XUngrabPointer(myDpy, CurrentTime); |
|
5869 |
XSync(myDpy, 0); |
|
5870 |
END_INTERRUPTSBLOCKED |
|
295 | 5871 |
} |
5872 |
%}. |
|
5873 |
activePointerGrab := nil |
|
5874 |
! ! |
|
5875 |
||
5876 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5877 |
||
1344 | 5878 |
noClipIn:aGCId |
295 | 5879 |
"disable clipping rectangle" |
5880 |
||
5881 |
%{ /* NOCONTEXT */ |
|
5882 |
||
5883 |
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
|
5884 |
GC gc; |
295 | 5885 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5886 |
if (ISCONNECTED) { |
1344 | 5887 |
if (__isExternalAddress(aGCId)) { |
5888 |
gc = _GCVal(aGCId); |
|
5889 |
gcv.clip_mask = None; |
|
5890 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5891 |
RETURN ( self ); |
|
5892 |
} |
|
295 | 5893 |
} |
5894 |
%}. |
|
5895 |
self primitiveFailed |
|
5896 |
! |
|
5897 |
||
1344 | 5898 |
setBackground:bgColorIndex in:aGCId |
295 | 5899 |
"set background color to be drawn with" |
5900 |
||
5901 |
%{ /* NOCONTEXT */ |
|
5902 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5903 |
if (ISCONNECTED) { |
1344 | 5904 |
if (__isExternalAddress(aGCId) |
5905 |
&& __isSmallInteger(bgColorIndex)) { |
|
5906 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
|
5907 |
RETURN ( self ); |
|
5908 |
} |
|
295 | 5909 |
} |
5910 |
%}. |
|
5911 |
self primitiveFailed |
|
5912 |
! |
|
5913 |
||
1344 | 5914 |
setBitmapMask:aBitmapId in:aGCId |
295 | 5915 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
5916 |
||
5917 |
%{ /* NOCONTEXT */ |
|
5918 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5919 |
GC gc; |
295 | 5920 |
Pixmap bitmap; |
5921 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5922 |
if (ISCONNECTED) { |
1344 | 5923 |
Display *dpy = myDpy; |
5924 |
||
5925 |
if (__isExternalAddress(aGCId)) { |
|
5926 |
gc = _GCVal(aGCId); |
|
5927 |
if (__isExternalAddress(aBitmapId)) { |
|
5928 |
bitmap = _PixmapVal(aBitmapId); |
|
5929 |
XSetStipple(dpy, gc, bitmap); |
|
5930 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5931 |
RETURN ( self ); |
|
5932 |
} |
|
5933 |
if (aBitmapId == nil) { |
|
5934 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5935 |
RETURN ( self ); |
|
5936 |
} |
|
5937 |
} |
|
295 | 5938 |
} |
5939 |
%}. |
|
5940 |
self primitiveFailed |
|
5941 |
! |
|
5942 |
||
1344 | 5943 |
setClipByChildren:aBool in:aGCId |
295 | 5944 |
"enable/disable drawing into child views" |
5945 |
||
5946 |
%{ /* NOCONTEXT */ |
|
5947 |
||
5948 |
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
|
5949 |
GC gc; |
295 | 5950 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5951 |
if (ISCONNECTED) { |
1344 | 5952 |
if (__isExternalAddress(aGCId)) { |
5953 |
gc = _GCVal(aGCId); |
|
5954 |
if (aBool == true) |
|
5955 |
gcv.subwindow_mode = ClipByChildren; |
|
5956 |
else |
|
5957 |
gcv.subwindow_mode = IncludeInferiors; |
|
5958 |
||
5959 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5960 |
RETURN ( self ); |
|
5961 |
} |
|
295 | 5962 |
} |
5963 |
%}. |
|
5964 |
self primitiveFailed |
|
5965 |
! |
|
5966 |
||
1344 | 5967 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
295 | 5968 |
"clip to a rectangle" |
5969 |
||
5970 |
%{ /* NOCONTEXT */ |
|
5971 |
||
5972 |
XRectangle r; |
|
5973 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5974 |
if (ISCONNECTED) { |
1344 | 5975 |
if (__isExternalAddress(aGCId) |
5976 |
&& __bothSmallInteger(clipX, clipY) |
|
5977 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
5978 |
r.x = __intVal(clipX); |
|
5979 |
r.y = __intVal(clipY); |
|
5980 |
r.width = __intVal(clipWidth); |
|
5981 |
r.height = __intVal(clipHeight); |
|
5982 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
|
5983 |
RETURN ( self ); |
|
5984 |
} |
|
295 | 5985 |
} |
5986 |
%}. |
|
5987 |
self primitiveFailed |
|
5988 |
! |
|
5989 |
||
1344 | 5990 |
setDashes:dashList dashOffset:offset in:aGCId |
788 | 5991 |
"set line attributes" |
5992 |
||
5993 |
%{ /* NOCONTEXT */ |
|
5994 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
5995 |
if (ISCONNECTED) { |
1344 | 5996 |
if (__isExternalAddress(aGCId) |
5997 |
&& __isSmallInteger(offset) |
|
5998 |
&& __isByteArray(dashList)) { |
|
5999 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
6000 |
__intVal(offset), |
|
6001 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
6002 |
__byteArraySize(dashList)); |
|
6003 |
RETURN ( self ); |
|
6004 |
} |
|
788 | 6005 |
} |
6006 |
bad: ; |
|
6007 |
%}. |
|
6008 |
" |
|
6009 |
either aGCId is invalid, |
|
6010 |
and/or dashList is not a byteArray |
|
6011 |
and/or offset is not a smallInteger |
|
6012 |
" |
|
6013 |
self primitiveFailed |
|
6014 |
! |
|
6015 |
||
1344 | 6016 |
setFont:aFontId in:aGCId |
295 | 6017 |
"set font to be drawn in" |
6018 |
||
6019 |
%{ /* NOCONTEXT */ |
|
6020 |
||
6021 |
XFontStruct *f; |
|
6022 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6023 |
if (ISCONNECTED) { |
1344 | 6024 |
if (__isExternalAddress(aFontId) |
6025 |
&& __isExternalAddress(aGCId)) { |
|
6026 |
f = (XFontStruct *) _FontVal(aFontId); |
|
6027 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
6028 |
RETURN ( self ); |
|
6029 |
} |
|
295 | 6030 |
} |
6031 |
%}. |
|
6032 |
" |
|
6033 |
aGCId and/or aFontId are invalid |
|
6034 |
" |
|
6035 |
self primitiveFailed |
|
6036 |
! |
|
6037 |
||
1344 | 6038 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
295 | 6039 |
"set foreground and background colors to be drawn with" |
6040 |
||
6041 |
%{ /* NOCONTEXT */ |
|
6042 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6043 |
GC gc; |
295 | 6044 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6045 |
if (ISCONNECTED) { |
1344 | 6046 |
Display *dpy = myDpy; |
6047 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
6048 |
&& __isExternalAddress(aGCId)) { |
|
6049 |
gc = _GCVal(aGCId); |
|
6050 |
||
6051 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
|
6052 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
6053 |
RETURN ( self ); |
|
6054 |
} |
|
295 | 6055 |
} |
6056 |
%}. |
|
6057 |
self primitiveFailed |
|
6058 |
! |
|
6059 |
||
1344 | 6060 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
295 | 6061 |
"set foreground and background colors to be drawn with using mask or |
6062 |
solid (if aBitmapId is nil)" |
|
6063 |
||
6064 |
%{ /* NOCONTEXT */ |
|
6065 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6066 |
GC gc; |
295 | 6067 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6068 |
if (ISCONNECTED) { |
1344 | 6069 |
Display *dpy = myDpy; |
6070 |
||
6071 |
if (__isExternalAddress(aGCId)) { |
|
6072 |
gc = _GCVal(aGCId); |
|
6073 |
if (__isSmallInteger(fgColor)) |
|
6074 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
|
6075 |
if (__isSmallInteger(bgColor)) |
|
6076 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
|
6077 |
||
6078 |
if (__isExternalAddress(aBitmapId)) { |
|
6079 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
6080 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
6081 |
RETURN ( self ); |
|
6082 |
} |
|
6083 |
if (aBitmapId == nil) { |
|
6084 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6085 |
RETURN ( self ); |
|
6086 |
} |
|
6087 |
} |
|
295 | 6088 |
} |
6089 |
%}. |
|
6090 |
self primitiveFailed |
|
6091 |
! |
|
6092 |
||
1344 | 6093 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
295 | 6094 |
"set foreground and background colors to be drawn with using mask or |
6095 |
solid (if aBitmapId is nil); also set lineWidth" |
|
6096 |
||
6097 |
%{ /* NOCONTEXT */ |
|
6098 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6099 |
GC gc; |
295 | 6100 |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6101 |
if (ISCONNECTED) { |
1344 | 6102 |
Display *dpy = myDpy; |
6103 |
||
6104 |
if (__isExternalAddress(aGCId)) { |
|
6105 |
gc = _GCVal(aGCId); |
|
6106 |
if (__isSmallInteger(lw)) { |
|
6107 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
|
6108 |
LineSolid, CapNotLast, JoinMiter); |
|
6109 |
} |
|
6110 |
if (__isSmallInteger(fgColor)) |
|
6111 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
|
6112 |
if (__isSmallInteger(bgColor)) |
|
6113 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
|
6114 |
||
6115 |
if (__isExternalAddress(aBitmapId)) { |
|
6116 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
6117 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
6118 |
RETURN ( self ); |
|
6119 |
} |
|
6120 |
if (aBitmapId == nil) { |
|
6121 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6122 |
RETURN ( self ); |
|
6123 |
} |
|
6124 |
} |
|
295 | 6125 |
} |
6126 |
%}. |
|
6127 |
self primitiveFailed |
|
6128 |
! |
|
6129 |
||
1344 | 6130 |
setForeground:fgColorIndex in:aGCId |
295 | 6131 |
"set foreground color to be drawn with" |
6132 |
||
6133 |
%{ /* NOCONTEXT */ |
|
6134 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6135 |
if (ISCONNECTED) { |
1344 | 6136 |
if (__isExternalAddress(aGCId) |
6137 |
&& __isSmallInteger(fgColorIndex)) { |
|
6138 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
|
6139 |
RETURN ( self ); |
|
6140 |
} |
|
295 | 6141 |
} |
6142 |
%}. |
|
6143 |
self primitiveFailed |
|
6144 |
! |
|
6145 |
||
1344 | 6146 |
setFunction:aFunctionSymbol in:aGCId |
295 | 6147 |
"set alu function to be drawn with" |
6148 |
||
6149 |
%{ /* NOCONTEXT */ |
|
6150 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6151 |
GC gc; |
295 | 6152 |
int fun = -1; |
6153 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6154 |
if (ISCONNECTED) { |
1344 | 6155 |
if (__isExternalAddress(aGCId)) { |
6156 |
gc = _GCVal(aGCId); |
|
6157 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
|
6158 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
6159 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
6160 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
6161 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
6162 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
6163 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
6164 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
6165 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
6166 |
if (fun != -1) { |
|
6167 |
XSetFunction(myDpy, gc, fun); |
|
6168 |
RETURN ( self ); |
|
6169 |
} |
|
6170 |
} |
|
295 | 6171 |
} |
6172 |
%}. |
|
6173 |
" |
|
6174 |
either aGCId is not an integer, or an invalid symbol |
|
6175 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
6176 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
6177 |
" |
|
6178 |
self primitiveFailed |
|
6179 |
! |
|
6180 |
||
1344 | 6181 |
setGraphicsExposures:aBoolean in:aGCId |
295 | 6182 |
"set or clear the graphics exposures flag" |
6183 |
||
6184 |
%{ /* NOCONTEXT */ |
|
6185 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6186 |
if (ISCONNECTED) { |
1344 | 6187 |
if (__isExternalAddress(aGCId)) { |
6188 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
6189 |
RETURN ( self ); |
|
6190 |
} |
|
295 | 6191 |
} |
6192 |
%} |
|
6193 |
. |
|
6194 |
self primitiveFailed |
|
6195 |
! |
|
6196 |
||
1344 | 6197 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
295 | 6198 |
"set line attributes" |
6199 |
||
6200 |
%{ /* NOCONTEXT */ |
|
6201 |
||
6202 |
int x_style, x_cap, x_join; |
|
6203 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6204 |
if (ISCONNECTED) { |
1344 | 6205 |
if (__isExternalAddress(aGCId) |
6206 |
&& __isSmallInteger(aNumber)) { |
|
6207 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
6208 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
6209 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
6210 |
else goto bad; |
|
6211 |
||
6212 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
6213 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
6214 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
6215 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
6216 |
else goto bad; |
|
6217 |
||
6218 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
6219 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
6220 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
6221 |
else goto bad; |
|
6222 |
||
6223 |
XSetLineAttributes(myDpy, |
|
6224 |
_GCVal(aGCId), __intVal(aNumber), |
|
6225 |
x_style, x_cap, x_join); |
|
6226 |
RETURN ( self ); |
|
6227 |
} |
|
295 | 6228 |
} |
6229 |
bad: ; |
|
6230 |
%}. |
|
6231 |
" |
|
6232 |
either aGCId is invalid, |
|
6233 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
6234 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
6235 |
and/or joinStyle is none of #miter, #bevel, #round |
|
6236 |
" |
|
6237 |
self primitiveFailed |
|
6238 |
! |
|
6239 |
||
1344 | 6240 |
setMaskOriginX:orgX y:orgY in:aGCid |
295 | 6241 |
"set the mask origin" |
6242 |
||
6243 |
%{ /* NOCONTEXT */ |
|
6244 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6245 |
if (ISCONNECTED) { |
1344 | 6246 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
6247 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
|
6248 |
RETURN ( self ); |
|
6249 |
} |
|
295 | 6250 |
} |
6251 |
%}. |
|
6252 |
self primitiveFailed |
|
6253 |
! |
|
6254 |
||
1344 | 6255 |
setPixmapMask:aPixmapId in:aGCId |
295 | 6256 |
"set or clear the drawing mask - a pixmap mask providing full color" |
6257 |
||
6258 |
%{ /* NOCONTEXT */ |
|
6259 |
||
6260 |
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
|
6261 |
GC gc; |
295 | 6262 |
Pixmap pixmap; |
6263 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6264 |
if (ISCONNECTED) { |
1344 | 6265 |
if (__isExternalAddress(aGCId)) { |
6266 |
gc = _GCVal(aGCId); |
|
6267 |
if (__isExternalAddress(aPixmapId)) { |
|
6268 |
pixmap = _PixmapVal(aPixmapId); |
|
6269 |
XSetTile(dpy, gc, pixmap); |
|
6270 |
XSetFillStyle(dpy, gc, FillTiled); |
|
6271 |
RETURN ( self ); |
|
6272 |
} |
|
6273 |
if (aPixmapId == nil) { |
|
6274 |
XSetFillStyle(dpy, gc, FillSolid); |
|
6275 |
RETURN ( self ); |
|
6276 |
} |
|
6277 |
} |
|
295 | 6278 |
} |
6279 |
%}. |
|
6280 |
self primitiveFailed |
|
6281 |
! ! |
|
6282 |
||
6283 |
!XWorkstation methodsFor:'initialize / release'! |
|
6284 |
||
1344 | 6285 |
closeConnection |
295 | 6286 |
"close down the connection to the X-server" |
6287 |
||
6288 |
%{ /* NOCONTEXT */ |
|
6289 |
||
6290 |
if (ISCONNECTED) { |
|
1344 | 6291 |
Display *dpy = myDpy; |
6292 |
||
6293 |
BEGIN_INTERRUPTSBLOCKED |
|
6294 |
__INST(displayId) = nil; |
|
6295 |
XCloseDisplay(dpy); |
|
6296 |
END_INTERRUPTSBLOCKED |
|
295 | 6297 |
} |
6298 |
%} |
|
6299 |
! |
|
6300 |
||
1344 | 6301 |
initializeDefaultValues |
295 | 6302 |
buttonTranslation := ButtonTranslation. |
6303 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
6304 |
||
6305 |
self initializeModifierMappings |
|
6306 |
! |
|
6307 |
||
1344 | 6308 |
initializeEventBuffer |
295 | 6309 |
|sz| |
6310 |
||
6311 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6312 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 6313 |
%}. |
6314 |
eventBuffer isNil ifTrue:[ |
|
1344 | 6315 |
eventBuffer := ByteArray new:sz. |
295 | 6316 |
]. |
6317 |
! |
|
6318 |
||
1344 | 6319 |
initializeFor:aDisplayName |
295 | 6320 |
"initialize the receiver for a connection to an X-Server; |
6321 |
the argument, aDisplayName may be nil (for the default server from |
|
6322 |
DISPLAY-variable or command line argument) or the name of the server |
|
6323 |
as hostname:number" |
|
6324 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
6325 |
|dpyName index arguments| |
295 | 6326 |
|
6327 |
dpyName := aDisplayName. |
|
6328 |
dpyName isNil ifTrue:[ |
|
1344 | 6329 |
"look for a '-display xxx' argument" |
6330 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
|
6331 |
index := arguments indexOf:'-display'. |
|
6332 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
|
6333 |
dpyName := arguments at:index+1 |
|
6334 |
] |
|
6335 |
] |
|
295 | 6336 |
]. |
6337 |
%{ |
|
6338 |
int scr; |
|
6339 |
Display *dpy; |
|
6340 |
Visual *visual; |
|
6341 |
XVisualInfo viproto; |
|
6342 |
XVisualInfo *vip; /* retured info */ |
|
6343 |
int maxRGBDepth; |
|
6344 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6345 |
int rgbVisualID; |
|
6346 |
int nvi, i; |
|
6347 |
char *type, *nm; |
|
6348 |
int dummy; |
|
6349 |
OBJ dpyID; |
|
6350 |
||
555 | 6351 |
if (__INST(displayId) != nil) { |
1344 | 6352 |
/* |
6353 |
* already connected - you bad guy try to |
|
6354 |
* trick me manually ? |
|
6355 |
*/ |
|
6356 |
RETURN ( self ); |
|
295 | 6357 |
} |
6358 |
||
6359 |
BEGIN_INTERRUPTSBLOCKED |
|
6360 |
||
6361 |
if (__isString(dpyName)) |
|
1344 | 6362 |
nm = (char *)_stringVal(dpyName); |
295 | 6363 |
else { |
1344 | 6364 |
dpyName = __MKSTRING((char *)getenv("DISPLAY")); |
6365 |
nm = NULL; |
|
295 | 6366 |
} |
6367 |
dpy = XOpenDisplay(nm); |
|
6368 |
||
6369 |
if (dpy) { |
|
1344 | 6370 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 6371 |
|
6372 |
#ifdef SUPERDEBUG |
|
1344 | 6373 |
XSynchronize(dpy, 1); |
295 | 6374 |
#endif |
6375 |
||
1344 | 6376 |
XSetErrorHandler(__XErrorHandler__); |
295 | 6377 |
} |
6378 |
||
6379 |
END_INTERRUPTSBLOCKED |
|
6380 |
%}. |
|
6381 |
displayId isNil ifTrue:[ |
|
1344 | 6382 |
'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. |
6383 |
^ nil |
|
295 | 6384 |
]. |
6385 |
||
6386 |
dispatching := false. |
|
6387 |
dispatchingExpose := false. |
|
6388 |
isSlow := false. |
|
6389 |
shiftDown := false. |
|
6390 |
ctrlDown := false. |
|
6391 |
metaDown := false. |
|
6392 |
altDown := false. |
|
6393 |
motionEventCompression := true. |
|
6394 |
buttonsPressed := 0. |
|
6395 |
displayName := dpyName. |
|
6396 |
||
6397 |
protocolsAtom := nil. |
|
6398 |
deleteWindowAtom := nil. |
|
6399 |
saveYourselfAtom := nil. |
|
6400 |
quitAppAtom := nil. |
|
6401 |
||
6402 |
self initializeScreenProperties. |
|
1366 | 6403 |
self initializeDeviceResourceTables. |
295 | 6404 |
|
6405 |
self initializeDefaultValues. |
|
6406 |
self initializeEventBuffer. |
|
6407 |
self initializeSpecialFlags. |
|
6408 |
self initializeKeyboardMap. |
|
6409 |
||
6410 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
6411 |
! |
|
6412 |
||
1344 | 6413 |
initializeModifierMappings |
295 | 6414 |
|map mod| |
6415 |
||
6416 |
"/ altModifiers := #(Alt_L Alt_R). |
|
6417 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
6418 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
6419 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
6420 |
||
6421 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
6422 |
altModifierMask := metaModifierMask := nil. |
|
6423 |
||
6424 |
map := self modifierMapping. |
|
342 | 6425 |
map isNil ifTrue:[ |
1344 | 6426 |
"/ |
6427 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
6428 |
"/ setup some reasonable default. If that is not sufficient, |
|
6429 |
"/ you have to change things from your display.rc file. |
|
6430 |
"/ |
|
6431 |
altModifierMask := self modifier1Mask. |
|
6432 |
metaModifierMask := self modifier2Mask. |
|
6433 |
||
6434 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
6435 |
ctrlModifiers := #(Control_L Control_R Control). |
|
6436 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
6437 |
altModifiers := #(Alt_R Alt). |
|
342 | 6438 |
] ifFalse:[ |
1344 | 6439 |
altModifierMask := 0. |
6440 |
metaModifierMask := 0. |
|
6441 |
||
6442 |
mod := map at:1. |
|
6443 |
mod notNil ifTrue:[ |
|
6444 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6445 |
]. |
|
6446 |
mod := map at:3. |
|
6447 |
mod notNil ifTrue:[ |
|
6448 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6449 |
]. |
|
6450 |
mod := map at:4. |
|
6451 |
mod notNil ifTrue:[ |
|
6452 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6453 |
metaModifierMask := 1 bitShift:(4-1). |
|
6454 |
]. |
|
6455 |
mod := map at:5. |
|
6456 |
mod notNil ifTrue:[ |
|
6457 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
|
6458 |
altModifierMask := 1 bitShift:(5-1). |
|
6459 |
] |
|
295 | 6460 |
]. |
6461 |
||
6462 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
6463 |
! |
|
6464 |
||
1344 | 6465 |
initializeScreenProperties |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6466 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6467 |
|
295 | 6468 |
%{ /* NOCONTEXT */ |
6469 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
6470 |
Display *dpy; |
295 | 6471 |
int scr; |
6472 |
Visual *visual; |
|
6473 |
XVisualInfo viproto; |
|
6474 |
XVisualInfo *vip; /* retured info */ |
|
6475 |
int maxRGBDepth; |
|
6476 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
6477 |
int rgbVisualID; |
|
6478 |
int nvi, i; |
|
6479 |
int shapeEventBase, shapeErrorBase; |
|
6480 |
int shmEventBase, shmErrorBase; |
|
6481 |
char *type, *nm; |
|
6482 |
int dummy; |
|
6483 |
int mask, shift, nBits; |
|
6484 |
||
6485 |
if (ISCONNECTED) { |
|
1344 | 6486 |
dpy = myDpy; |
6487 |
||
6488 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
|
6489 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6490 |
||
6491 |
BEGIN_INTERRUPTSBLOCKED |
|
6492 |
||
6493 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6494 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6495 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6496 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6497 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6498 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6499 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6500 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6501 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6502 |
|
6503 |
#ifdef SHAPE |
|
1344 | 6504 |
if (XShapeQueryExtension(dpy, &dummy, &dummy)) |
6505 |
__INST(hasShapeExtension) = true; |
|
6506 |
else |
|
295 | 6507 |
#endif |
1344 | 6508 |
__INST(hasShapeExtension) = false; |
295 | 6509 |
|
6510 |
#ifdef SHM |
|
1344 | 6511 |
if (XQueryExtension(dpy, "MIT_SHM", &dummy, &dummy, &dummy)) |
6512 |
__INST(hasShmExtension) = true; |
|
6513 |
else |
|
295 | 6514 |
#endif |
1344 | 6515 |
__INST(hasShmExtension) = false; |
295 | 6516 |
|
6517 |
#ifdef DPS |
|
1344 | 6518 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6519 |
__INST(hasDPSExtension) = true; |
|
6520 |
else |
|
295 | 6521 |
#endif |
1344 | 6522 |
__INST(hasDPSExtension) = false; |
295 | 6523 |
|
6524 |
#ifdef XVIDEO |
|
1344 | 6525 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6526 |
__INST(hasXVideoExtension) = true; |
|
6527 |
else |
|
295 | 6528 |
#endif |
1344 | 6529 |
__INST(hasXVideoExtension) = false; |
295 | 6530 |
|
6531 |
#ifdef MBUF |
|
1344 | 6532 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6533 |
__INST(hasMbufExtension) = true; |
|
6534 |
else |
|
295 | 6535 |
#endif |
1344 | 6536 |
__INST(hasMbufExtension) = false; |
295 | 6537 |
|
6538 |
#ifdef PEX5 |
|
1344 | 6539 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6540 |
__INST(hasPEXExtension) = true; |
|
6541 |
else |
|
295 | 6542 |
#endif |
1344 | 6543 |
__INST(hasPEXExtension) = false; |
295 | 6544 |
|
6545 |
#ifdef XIE |
|
1344 | 6546 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6547 |
__INST(hasImageExtension) = true; |
|
6548 |
else |
|
295 | 6549 |
#endif |
1344 | 6550 |
__INST(hasImageExtension) = false; |
295 | 6551 |
|
6552 |
#ifdef XI |
|
1344 | 6553 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6554 |
__INST(hasInputExtension) = true; |
|
6555 |
else |
|
295 | 6556 |
#endif |
1344 | 6557 |
__INST(hasInputExtension) = false; |
6558 |
||
6559 |
/* |
|
6560 |
* look for RGB visual |
|
6561 |
*/ |
|
6562 |
nvi = 0; |
|
6563 |
viproto.screen = scr; |
|
6564 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6565 |
maxRGBDepth = 0; |
|
6566 |
for (i = 0; i < nvi; i++) { |
|
6567 |
switch (vip[i].class) { |
|
6568 |
case TrueColor: |
|
6569 |
if (vip[i].depth > maxRGBDepth) { |
|
6570 |
maxRGBDepth = vip[i].depth; |
|
6571 |
rgbRedMask = vip[i].red_mask; |
|
6572 |
rgbGreenMask = vip[i].green_mask; |
|
6573 |
rgbBlueMask = vip[i].blue_mask; |
|
6574 |
rgbVisualID = vip[i].visualid; |
|
6575 |
} |
|
6576 |
break; |
|
6577 |
} |
|
6578 |
} |
|
6579 |
if (vip) XFree ((char *) vip); |
|
6580 |
||
6581 |
if (maxRGBDepth) { |
|
6582 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6583 |
} |
|
6584 |
||
6585 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6586 |
__INST(monitorType) = @symbol(unknown); |
|
6587 |
__INST(hasColors) = true; |
|
6588 |
__INST(hasGreyscales) = true; |
|
6589 |
switch (visual->class) { |
|
6590 |
case StaticGray: |
|
6591 |
__INST(visualType) = @symbol(StaticGray); |
|
6592 |
__INST(hasColors) = false; |
|
6593 |
__INST(monitorType) = @symbol(monochrome); |
|
6594 |
break; |
|
6595 |
case GrayScale: |
|
6596 |
__INST(visualType) = @symbol(GrayScale); |
|
6597 |
__INST(hasColors) = false; |
|
6598 |
__INST(monitorType) = @symbol(monochrome); |
|
6599 |
break; |
|
6600 |
case StaticColor: |
|
6601 |
__INST(visualType) = @symbol(StaticColor); |
|
6602 |
break; |
|
6603 |
case PseudoColor: |
|
6604 |
__INST(visualType) = @symbol(PseudoColor); |
|
6605 |
break; |
|
6606 |
case TrueColor: |
|
6607 |
__INST(visualType) = @symbol(TrueColor); |
|
6608 |
break; |
|
6609 |
case DirectColor: |
|
6610 |
__INST(visualType) = @symbol(DirectColor); |
|
6611 |
break; |
|
6612 |
} |
|
6613 |
if (DisplayCells(dpy, scr) == 2) { |
|
6614 |
__INST(hasColors) = false; |
|
6615 |
__INST(hasGreyscales) = false; |
|
6616 |
__INST(monitorType) = @symbol(monochrome); |
|
6617 |
} |
|
6618 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
6619 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6620 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6621 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
6622 |
switch (visual->class) { |
|
6623 |
case TrueColor: |
|
6624 |
/* extract number of bits and shift counts */ |
|
6625 |
mask = visual->red_mask; |
|
6626 |
shift = 0; |
|
6627 |
while (mask && ((mask & 1) == 0)) { |
|
6628 |
mask >>= 1; |
|
6629 |
shift++; |
|
6630 |
} |
|
6631 |
__INST(redShift) = __MKSMALLINT(shift); |
|
6632 |
nBits = 0; |
|
6633 |
while (mask) { |
|
6634 |
mask >>= 1; |
|
6635 |
nBits++; |
|
6636 |
} |
|
6637 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
6638 |
||
6639 |
mask = visual->green_mask; |
|
6640 |
shift = 0; |
|
6641 |
while (mask && ((mask & 1) == 0)) { |
|
6642 |
mask >>= 1; |
|
6643 |
shift++; |
|
6644 |
} |
|
6645 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
6646 |
nBits = 0; |
|
6647 |
while (mask) { |
|
6648 |
mask >>= 1; |
|
6649 |
nBits++; |
|
6650 |
} |
|
6651 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
6652 |
||
6653 |
mask = visual->blue_mask; |
|
6654 |
shift = 0; |
|
6655 |
while (mask && ((mask & 1) == 0)) { |
|
6656 |
mask >>= 1; |
|
6657 |
shift++; |
|
6658 |
} |
|
6659 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
6660 |
nBits = 0; |
|
6661 |
while (mask) { |
|
6662 |
mask >>= 1; |
|
6663 |
nBits++; |
|
6664 |
} |
|
6665 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
6666 |
break; |
|
6667 |
} |
|
295 | 6668 |
|
6669 |
#ifndef XA_PRIMARY |
|
1344 | 6670 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6671 |
#else |
1344 | 6672 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6673 |
#endif |
6674 |
#ifndef XA_SECONDARY |
|
1344 | 6675 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6676 |
#else |
1344 | 6677 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6678 |
#endif |
6679 |
#ifndef XA_CUT_BUFFER0 |
|
1344 | 6680 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6681 |
#else |
1344 | 6682 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6683 |
#endif |
6684 |
#ifndef XA_STRING |
|
1344 | 6685 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6686 |
#else |
1344 | 6687 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6688 |
#endif |
6689 |
#ifndef XA_LENGTH |
|
1344 | 6690 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6691 |
#else |
1344 | 6692 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6693 |
#endif |
6694 |
||
1344 | 6695 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6696 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6697 |
%}. |
295 | 6698 |
! |
6699 |
||
1344 | 6700 |
initializeSpecialFlags |
295 | 6701 |
"perform additional special server implementation flags" |
6702 |
||
6703 |
"/ |
|
6704 |
"/ assume we have it ... (should check) |
|
6705 |
"/ |
|
6706 |
hasSaveUnder := true. |
|
6707 |
ignoreBackingStore := false. |
|
6708 |
||
6709 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
1344 | 6710 |
"/ |
6711 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6712 |
"/ which does not correctly handle saveUnder |
|
6713 |
"/ |
|
6714 |
hasSaveUnder := false. |
|
295 | 6715 |
]. |
6716 |
! |
|
6717 |
||
1344 | 6718 |
reinitialize |
295 | 6719 |
virtualRootId := rootId := nil. |
6720 |
super reinitialize. |
|
6721 |
dispatchingExpose := nil |
|
6722 |
! ! |
|
6723 |
||
6724 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6725 |
||
1344 | 6726 |
altModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6727 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6728 |
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
|
6729 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6730 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6731 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6732 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6733 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6734 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6735 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6736 |
|
1344 | 6737 |
altModifierMask:aSmallInteger |
341 | 6738 |
"define which key takes the role of an alt-key. |
6739 |
By default, this is X's modifier1, which is the ALT key on |
|
6740 |
most keyboards. However, there may be exceptions to this, |
|
6741 |
and the setting can be changed with: |
|
1344 | 6742 |
Display altModifierMask:(Display modifier2Mask) |
341 | 6743 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
6744 |
" |
|
6745 |
||
6746 |
altModifierMask := aSmallInteger |
|
6747 |
! |
|
6748 |
||
1344 | 6749 |
metaModifierMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6750 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6751 |
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
|
6752 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6753 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6754 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6755 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6756 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6757 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6758 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6759 |
|
1344 | 6760 |
metaModifierMask:aSmallInteger |
341 | 6761 |
"define which key takes the role of a meta key. |
6762 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6763 |
most keyboards (if present at all). |
|
6764 |
However, there may be exceptions to this, and the setting can |
|
6765 |
be changed with: |
|
1344 | 6766 |
Display metaModifierMask:(Display modifier1Mask) |
341 | 6767 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
6768 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6769 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6770 |
all the time. On those, you should disable the meta key by setting |
|
6771 |
the mask to 0. |
|
6772 |
" |
|
6773 |
||
6774 |
metaModifierMask := aSmallInteger |
|
6775 |
! |
|
6776 |
||
1344 | 6777 |
modifier1Mask |
341 | 6778 |
"return the Xlib mask bit for the 1st modifier key. |
6779 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6780 |
this could be used." |
|
6781 |
||
6782 |
%{ /* NOCONTEXT */ |
|
6783 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6784 |
%} |
|
6785 |
! |
|
6786 |
||
1344 | 6787 |
modifier2Mask |
341 | 6788 |
"return the Xlib mask bit for the 2nd modifier key. |
6789 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6790 |
this could be used." |
|
6791 |
||
6792 |
%{ /* NOCONTEXT */ |
|
6793 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6794 |
%} |
|
6795 |
! |
|
6796 |
||
1344 | 6797 |
modifierMapping |
341 | 6798 |
"Get the Modifier Mapping. |
6799 |
We return an array of arrays of keycodes" |
|
6800 |
||
6801 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6802 |
||
6803 |
%{ |
|
6804 |
XModifierKeymap *modmap; |
|
6805 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6806 |
||
6807 |
if (ISCONNECTED) { |
|
1344 | 6808 |
Display *dpy = myDpy; |
6809 |
||
6810 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6811 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6812 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6813 |
if (modifierKeyMap != nil) { |
|
6814 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6815 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6816 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6817 |
} |
|
6818 |
XFreeModifiermap(modmap); |
|
6819 |
} |
|
341 | 6820 |
} |
6821 |
%}. |
|
6822 |
||
6823 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6824 |
||
6825 |
ret := Array new:8. |
|
6826 |
nextKey := 1. |
|
6827 |
1 to:8 do:[ :i | |
|
1344 | 6828 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
6829 |
|mod| |
|
6830 |
||
6831 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6832 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6833 |
key ~= 0 ifTrue:[ |
|
6834 |
mod add:key |
|
6835 |
]. |
|
6836 |
]. |
|
6837 |
ret at:i put:mod. |
|
6838 |
]. |
|
6839 |
nextKey := nextKey+maxKeyPerMod. |
|
341 | 6840 |
]. |
6841 |
||
6842 |
^ ret |
|
6843 |
||
6844 |
" |
|
1344 | 6845 |
Display modifierMapping |
341 | 6846 |
" |
6847 |
! |
|
6848 |
||
1344 | 6849 |
stringFromKeycode:code |
341 | 6850 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
6851 |
||
6852 |
|str| |
|
6853 |
||
6854 |
%{ |
|
6855 |
KeySym keysym; |
|
6856 |
char *keystring; |
|
6857 |
||
6858 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
1344 | 6859 |
Display *dpy = myDpy; |
6860 |
||
6861 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6862 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6863 |
str = __MKSTRING(keystring); |
|
341 | 6864 |
} |
6865 |
%}. |
|
6866 |
^ str |
|
6867 |
||
6868 |
" |
|
1344 | 6869 |
Display stringFromKeycode:28 |
341 | 6870 |
" |
6871 |
! |
|
6872 |
||
1344 | 6873 |
translateKey:untranslatedKey |
295 | 6874 |
"Return the key translated via the translation table. |
6875 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6876 |
which gets further processed in the superclasses translation method." |
|
6877 |
||
6878 |
|key| |
|
6879 |
||
6880 |
(key := untranslatedKey) isString ifTrue:[ |
|
1344 | 6881 |
key := RawKeysymTranslation at:key ifAbsent:key. |
6882 |
key := key asSymbol. |
|
295 | 6883 |
]. |
6884 |
^ super translateKey:key |
|
6885 |
! ! |
|
6886 |
||
6887 |
!XWorkstation methodsFor:'misc'! |
|
6888 |
||
1344 | 6889 |
beep |
295 | 6890 |
"output an audible beep or bell" |
6891 |
||
6892 |
self beep:50 |
|
6893 |
! |
|
6894 |
||
1344 | 6895 |
beep:volumeInPercent |
295 | 6896 |
"output an audible beep" |
6897 |
%{ |
|
6898 |
int volume; |
|
6899 |
||
6900 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
1344 | 6901 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
6902 |
volume = __intVal(volumeInPercent) * 2 - 100; |
|
6903 |
if (volume < -100) volume = -100; |
|
6904 |
else if (volume > 100) volume = 100; |
|
6905 |
BEGIN_INTERRUPTSBLOCKED |
|
6906 |
XBell(myDpy, volume); |
|
6907 |
END_INTERRUPTSBLOCKED |
|
295 | 6908 |
} |
6909 |
%} |
|
6910 |
! |
|
6911 |
||
1344 | 6912 |
buffered |
295 | 6913 |
"buffer drawing - do not send it immediately to the display. |
374 | 6914 |
This is the default anyway. |
6915 |
See #unBuffered for additional info." |
|
295 | 6916 |
|
6917 |
%{ /* NOCONTEXT */ |
|
6918 |
||
6919 |
if (ISCONNECTED) { |
|
1344 | 6920 |
BEGIN_INTERRUPTSBLOCKED |
6921 |
XSynchronize(myDpy, 0); |
|
6922 |
END_INTERRUPTSBLOCKED |
|
295 | 6923 |
} |
6924 |
%} |
|
374 | 6925 |
" |
6926 |
Display buffered |
|
6927 |
" |
|
295 | 6928 |
! |
6929 |
||
1344 | 6930 |
flush |
295 | 6931 |
"send all buffered drawing to the display. |
6932 |
This may be required to make certain, that all previous operations |
|
6933 |
are really sent to the display before continuing. For example, |
|
6934 |
after a cursor-change with a followup long computation. |
|
374 | 6935 |
(otherwise, the cursor change request may still be in the output buffer) |
6936 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6937 |
|
6938 |
%{ /* NOCONTEXT */ |
|
6939 |
||
6940 |
if (ISCONNECTED) { |
|
1344 | 6941 |
BEGIN_INTERRUPTSBLOCKED |
6942 |
XFlush(myDpy); |
|
6943 |
END_INTERRUPTSBLOCKED |
|
310 | 6944 |
} |
6945 |
%} |
|
6946 |
! |
|
6947 |
||
1344 | 6948 |
flushDpsContext:aDPSContext |
295 | 6949 |
|
6950 |
%{ /* NOCONTEXT */ |
|
6951 |
#ifdef DPS |
|
6952 |
if (__isExternalAddress(aDPSContext)) { |
|
1344 | 6953 |
BEGIN_INTERRUPTSBLOCKED |
6954 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6955 |
END_INTERRUPTSBLOCKED |
|
6956 |
RETURN ( self ); |
|
295 | 6957 |
} |
6958 |
#endif |
|
374 | 6959 |
%}. |
295 | 6960 |
self primitiveFailed |
6961 |
! |
|
6962 |
||
1344 | 6963 |
refreshKeyboardMapping:eB |
295 | 6964 |
%{ |
6965 |
XMappingEvent *ev; |
|
6966 |
||
6967 |
if (__isByteArray(eB)) { |
|
1344 | 6968 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
6969 |
XRefreshKeyboardMapping(ev); |
|
295 | 6970 |
} |
6971 |
%} |
|
6972 |
! |
|
6973 |
||
1344 | 6974 |
setInputFocusTo:aWindowId |
295 | 6975 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
6976 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6977 |
! |
|
6978 |
||
1344 | 6979 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
295 | 6980 |
"set the focus to the view as defined by aWindowId. |
6981 |
Passing nil set the focus to no window and lets the display discard all |
|
6982 |
input until a new focus is set. |
|
6983 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6984 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6985 |
given to the parent view, the root view or no view." |
|
6986 |
||
6987 |
%{ /* NOCONTEXT */ |
|
6988 |
int arg; |
|
6989 |
Window focusWindow; |
|
6990 |
||
6991 |
if (ISCONNECTED) { |
|
1344 | 6992 |
if (__isExternalAddress(aWindowId)) { |
6993 |
focusWindow = _WindowVal(aWindowId); |
|
6994 |
} else { |
|
6995 |
focusWindow = None; |
|
6996 |
} |
|
6997 |
if (revertSymbol == @symbol(parent)) |
|
6998 |
arg = RevertToParent; |
|
6999 |
else if (revertSymbol == @symbol(root)) |
|
7000 |
arg = RevertToPointerRoot; |
|
7001 |
else |
|
7002 |
arg = RevertToNone; |
|
7003 |
||
7004 |
BEGIN_INTERRUPTSBLOCKED |
|
7005 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
7006 |
END_INTERRUPTSBLOCKED |
|
7007 |
RETURN ( self ); |
|
295 | 7008 |
} |
7009 |
%}. |
|
7010 |
self primitiveFailed |
|
7011 |
! |
|
7012 |
||
1344 | 7013 |
sync |
341 | 7014 |
"send all buffered drawing to the display AND wait until the display |
7015 |
has finished drawing it. |
|
7016 |
This is almost never needed, except if you are about to read previously |
|
374 | 7017 |
drawn pixels back from the display screen, or you want to wait for a beep |
7018 |
to be finished. See also #flush." |
|
341 | 7019 |
|
7020 |
%{ /* NOCONTEXT */ |
|
7021 |
||
7022 |
if (ISCONNECTED) { |
|
1344 | 7023 |
BEGIN_INTERRUPTSBLOCKED |
7024 |
XSync(myDpy, 0); |
|
7025 |
END_INTERRUPTSBLOCKED |
|
341 | 7026 |
} |
7027 |
%} |
|
7028 |
! |
|
7029 |
||
1344 | 7030 |
unBuffered |
374 | 7031 |
"make all drawing be sent immediately to the display. |
7032 |
This makes all graphics synchronous and turns off any buffering |
|
7033 |
(i.e. each individual draw-request is sent immediately without |
|
7034 |
packing multiple requests into a larger message buffer). |
|
7035 |
Be prepared, that this slows down graphics considerably. |
|
7036 |
However, it allows display errors to be handled immediately and |
|
7037 |
may be useful if you get Xdisplay errors and want to find the request |
|
7038 |
which was responsiblefor it. See also #buffered." |
|
295 | 7039 |
|
7040 |
%{ /* NOCONTEXT */ |
|
7041 |
||
7042 |
if (ISCONNECTED) { |
|
1344 | 7043 |
BEGIN_INTERRUPTSBLOCKED |
7044 |
XSynchronize(myDpy, 1); |
|
7045 |
END_INTERRUPTSBLOCKED |
|
295 | 7046 |
} |
7047 |
%} |
|
7048 |
"Display unbuffered" |
|
7049 |
! ! |
|
7050 |
||
7051 |
!XWorkstation methodsFor:'pointer queries '! |
|
7052 |
||
1344 | 7053 |
anyButtonStateMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7054 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7055 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7056 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7057 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7058 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7059 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7060 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7061 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7062 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7063 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7064 |
|
1344 | 7065 |
buttonStates |
295 | 7066 |
"return an integer representing the state of the pointer buttons; |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7067 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7068 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7069 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 7070 |
|
7071 |
%{ /* NOCONTEXT*/ |
|
7072 |
Window w; |
|
555 | 7073 |
int screen = __intVal(__INST(screen)); |
295 | 7074 |
Window rootRet, childRet; |
7075 |
int rootX, rootY, winX, winY; |
|
7076 |
unsigned int mask; |
|
7077 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7078 |
if (ISCONNECTED) { |
1344 | 7079 |
Display *dpy = myDpy; |
7080 |
||
7081 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7082 |
#ifdef VIRTUAL_ROOT |
1344 | 7083 |
w = getRootWindow(myDpy, screen); |
295 | 7084 |
#else |
1344 | 7085 |
w = RootWindow(dpy, screen); |
295 | 7086 |
#endif |
1344 | 7087 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7088 |
&rootX, &rootY, |
|
7089 |
&winX, &winY, |
|
7090 |
&mask); |
|
7091 |
END_INTERRUPTSBLOCKED |
|
7092 |
RETURN (__MKSMALLINT(mask)); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7093 |
} |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7094 |
%}. |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7095 |
self primitiveFailed |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7096 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7097 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7098 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7099 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7100 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7101 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7102 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7103 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7104 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7105 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7106 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7107 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7108 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7109 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7110 |
" |
295 | 7111 |
! |
7112 |
||
1344 | 7113 |
leftButtonStateMask |
295 | 7114 |
"return an integer for masking out the left button from a |
7115 |
buttonStates value" |
|
7116 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7117 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7118 |
|
295 | 7119 |
^ 256 |
540
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 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 7122 |
! |
7123 |
||
1344 | 7124 |
middleButtonStateMask |
295 | 7125 |
"return an integer for masking out the middle button from a |
7126 |
buttonStates value" |
|
7127 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7128 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7129 |
|
295 | 7130 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7131 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7132 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 7133 |
! |
7134 |
||
1344 | 7135 |
pointerPosition |
295 | 7136 |
"return the current pointer position in root-window coordinates" |
7137 |
||
7138 |
|xpos ypos| |
|
7139 |
||
7140 |
%{ |
|
7141 |
Window w; |
|
555 | 7142 |
int screen = __intVal(__INST(screen)); |
295 | 7143 |
Window rootRet, childRet; |
7144 |
int rootX, rootY, winX, winY; |
|
7145 |
unsigned int mask; |
|
7146 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7147 |
if (ISCONNECTED) { |
1344 | 7148 |
Display *dpy = myDpy; |
7149 |
||
7150 |
BEGIN_INTERRUPTSBLOCKED |
|
295 | 7151 |
#ifdef VIRTUAL_ROOT |
1344 | 7152 |
w = getRootWindow(myDpy, screen); |
295 | 7153 |
#else |
1344 | 7154 |
w = RootWindow(dpy, screen); |
295 | 7155 |
#endif |
1344 | 7156 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
7157 |
&rootX, &rootY, |
|
7158 |
&winX, &winY, |
|
7159 |
&mask); |
|
7160 |
xpos = __MKSMALLINT(rootX); |
|
7161 |
ypos = __MKSMALLINT(rootY); |
|
7162 |
END_INTERRUPTSBLOCKED |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7163 |
} |
295 | 7164 |
%} |
7165 |
. |
|
7166 |
^ xpos @ ypos |
|
7167 |
! |
|
7168 |
||
1344 | 7169 |
rightButtonStateMask |
295 | 7170 |
"return an integer for masking out the right button from a |
7171 |
buttonStates value" |
|
7172 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7173 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7174 |
|
295 | 7175 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7176 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
7177 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 7178 |
! |
7179 |
||
1344 | 7180 |
rootPositionOfLastEvent |
295 | 7181 |
"return the position in root-window coordinates |
7182 |
of the last button, key or pointer event" |
|
7183 |
||
7184 |
^ eventRootX @ eventRootY |
|
7185 |
! ! |
|
7186 |
||
7187 |
!XWorkstation methodsFor:'resources'! |
|
7188 |
||
1344 | 7189 |
atomIDOf:aStringOrSymbol |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7190 |
"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
|
7191 |
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
|
7192 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7193 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7194 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7195 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7196 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7197 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7198 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7199 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7200 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7201 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7202 |
|
1344 | 7203 |
atomIDOf:aStringOrSymbol create:create |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7204 |
"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
|
7205 |
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
|
7206 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7207 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7208 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7209 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7210 |
if (ISCONNECTED) { |
1344 | 7211 |
if (__isString(aStringOrSymbol) |
7212 |
|| __isSymbol(aStringOrSymbol)) { |
|
7213 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
7214 |
(create == true) ? False : True); |
|
7215 |
if (prop == None) { |
|
7216 |
RETURN (nil); |
|
7217 |
} |
|
7218 |
RETURN ( __MKATOMOBJ(prop) ); |
|
7219 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7220 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7221 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7222 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7223 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7224 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7225 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7226 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7227 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7228 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7229 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7230 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7231 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7232 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7233 |
|
1344 | 7234 |
atomIDOfCUTBUFFER0 |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7235 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7236 |
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
|
7237 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7238 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7239 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7240 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7241 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7242 |
|
1344 | 7243 |
atomIDOfLENGTH |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7244 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7245 |
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
|
7246 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7247 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7248 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7249 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7250 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7251 |
|
1344 | 7252 |
atomIDOfPRIMARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7253 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7254 |
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
|
7255 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7256 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7257 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7258 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7259 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7260 |
|
1344 | 7261 |
atomIDOfSECONDARY |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7262 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7263 |
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
|
7264 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7265 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7266 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7267 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7268 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7269 |
|
1344 | 7270 |
atomIDOfSTRING |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7271 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7272 |
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
|
7273 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7274 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7275 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7276 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7277 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7278 |
|
1344 | 7279 |
atomName:anAtomID |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7280 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7281 |
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
|
7282 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7283 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7284 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7285 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7286 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7287 |
if (ISCONNECTED) { |
1344 | 7288 |
if (__isAtomID(anAtomID)) { |
7289 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
7290 |
if (name == 0) { |
|
7291 |
RETURN (nil); |
|
7292 |
} |
|
7293 |
str = __MKSTRING(name); |
|
7294 |
XFree(name); |
|
7295 |
RETURN ( str ); |
|
7296 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7297 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7298 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7299 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7300 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7301 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7302 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7303 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7304 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7305 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7306 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7307 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7308 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7309 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7310 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7311 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7312 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7313 |
|
1344 | 7314 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7315 |
"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
|
7316 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7317 |
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
|
7318 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7319 |
Notice: |
1344 | 7320 |
we do not plan to use X's resources for ST/X's defaults, |
7321 |
styles or resources. This would make porting of applications |
|
7322 |
to different platforms much more difficult (Windows has no resource |
|
7323 |
database). If you stay within ST/X's resource files, these can be |
|
7324 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7325 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7326 |
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
|
7327 |
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
|
7328 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7329 |
|
295 | 7330 |
%{ |
7331 |
char *rslt; |
|
7332 |
||
7333 |
if ((__isString(name) || __isSymbol(name)) |
|
7334 |
&& (__isString(cls) || __isSymbol(cls)) |
|
7335 |
&& ISCONNECTED) { |
|
1344 | 7336 |
BEGIN_INTERRUPTSBLOCKED |
7337 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
7338 |
(char *)_stringVal(name)); |
|
7339 |
END_INTERRUPTSBLOCKED |
|
7340 |
RETURN (rslt ? __MKSTRING(rslt) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7341 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7342 |
%}. |
295 | 7343 |
self primitiveFailed. |
7344 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7345 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7346 |
"if your ~/.Xdefaults contains an entry such as: |
1344 | 7347 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7348 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7349 |
|
1344 | 7350 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7351 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7352 |
if your ~/.Xdefaults contains an entry such as: |
1344 | 7353 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7354 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7355 |
|
1344 | 7356 |
Display getResource:'beNiceToColormap' class:'any' |
7357 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
7358 |
" |
295 | 7359 |
! ! |
7360 |
||
7361 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
7362 |
||
1344 | 7363 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
295 | 7364 |
"get bits from a drawable into the imageBits. The storage for the bits |
7365 |
must be big enough for the data to fit. If ok, returns an array with some |
|
7366 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
7367 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
7368 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
7369 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7370 |
|rawInfo info| |
295 | 7371 |
|
7372 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
1344 | 7373 |
self primitiveFailed. |
7374 |
^ nil |
|
295 | 7375 |
]. |
7376 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7377 |
rawInfo := Array new:8. |
1344 | 7378 |
"1 -> bit order" |
7379 |
"2 -> depth" |
|
7380 |
"3 -> bytes_per_line" |
|
7381 |
"4 -> byte_order" |
|
7382 |
"5 -> format" |
|
7383 |
"6 -> bitmap_unit" |
|
7384 |
"7 -> bitmap_pad" |
|
7385 |
"8 -> bits_per_pixel" |
|
295 | 7386 |
|
7387 |
"/ had to extract the getPixel call into a separate method, to specify |
|
7388 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
7389 |
"/ of temporary stack space |
|
7390 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7391 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
1344 | 7392 |
info := IdentityDictionary new. |
7393 |
info at:#bitOrder put:(rawInfo at:1). |
|
7394 |
info at:#depth put:(rawInfo at:2). |
|
7395 |
info at:#bytesPerLine put:(rawInfo at:3). |
|
7396 |
info at:#byteOrder put:(rawInfo at:4). |
|
7397 |
info at:#format put:(rawInfo at:5). |
|
7398 |
info at:#bitmapUnit put:(rawInfo at:6). |
|
7399 |
info at:#bitmapPad put:(rawInfo at:7). |
|
7400 |
info at:#bitsPerPixel put:(rawInfo at:8). |
|
7401 |
^ info |
|
295 | 7402 |
]. |
7403 |
" |
|
7404 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
7405 |
or is too small to hold the bits |
|
7406 |
" |
|
7407 |
^ self primitiveFailed |
|
7408 |
! |
|
7409 |
||
1344 | 7410 |
getPixelX:x y:y from:aDrawableId |
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
7411 |
"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
|
7412 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 7413 |
|
7414 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
7415 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7416 |
Window win; |
295 | 7417 |
XImage *img; |
7418 |
int ret; |
|
7419 |
int xpos, ypos; |
|
7420 |
||
1209 | 7421 |
if (ISCONNECTED |
7422 |
&& __isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
1344 | 7423 |
win = _WindowVal(aDrawableId); |
7424 |
xpos = __intVal(x); |
|
7425 |
ypos = __intVal(y); |
|
7426 |
if ((xpos < 0) || (ypos < 0)) { |
|
7427 |
RETURN ( __MKSMALLINT(0) ); |
|
7428 |
} |
|
7429 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
7430 |
if (img != 0) { |
|
7431 |
ret = XGetPixel(img, 0, 0); |
|
7432 |
XDestroyImage(img); |
|
7433 |
RETURN ( __MKSMALLINT(ret) ); |
|
7434 |
} |
|
295 | 7435 |
} |
7436 |
%}. |
|
7437 |
^ nil |
|
7438 |
! |
|
7439 |
||
1344 | 7440 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 7441 |
"since XGetImage may allocate huge amount of stack space |
7442 |
(some implementations use alloca), this must run with unlimited stack." |
|
7443 |
||
7444 |
%{ /* UNLIMITEDSTACK */ |
|
7445 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
7446 |
Window win; |
295 | 7447 |
XImage *image = (XImage *)0; |
7448 |
int pad, bytes_per_line, numBytes; |
|
7449 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7450 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7451 |
&& __isExternalAddress(aDrawableId) |
295 | 7452 |
&& __bothSmallInteger(srcx, srcy) |
7453 |
&& __bothSmallInteger(w, h) |
|
7454 |
&& __isArray(info) |
|
7455 |
&& __isByteArray(imageBits)) { |
|
1344 | 7456 |
Display *dpy = myDpy; |
7457 |
||
7458 |
win = _WindowVal(aDrawableId); |
|
7459 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
|
7460 |
__intVal(w), __intVal(h), |
|
7461 |
(unsigned)AllPlanes, ZPixmap); |
|
7462 |
||
7463 |
if (! image) { |
|
7464 |
RETURN ( false ); |
|
7465 |
} |
|
7466 |
||
7467 |
pad = image->bitmap_pad; |
|
295 | 7468 |
#ifdef SUPERDEBUG |
1344 | 7469 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
295 | 7470 |
#endif |
1344 | 7471 |
switch (image->depth) { |
7472 |
case 1: |
|
7473 |
case 2: |
|
7474 |
case 4: |
|
7475 |
case 8: |
|
7476 |
case 16: |
|
7477 |
case 24: |
|
7478 |
case 32: |
|
7479 |
numBytes = image->bytes_per_line * image->height; |
|
7480 |
break; |
|
7481 |
default: |
|
7482 |
/* unsupported depth ? */ |
|
7483 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
|
7484 |
numBytes = image->bytes_per_line * image->height; |
|
7485 |
break; |
|
7486 |
} |
|
295 | 7487 |
|
7488 |
#ifdef SUPERDEBUG |
|
1344 | 7489 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 7490 |
#endif |
7491 |
||
1344 | 7492 |
if (numBytes > __byteArraySize(imageBits)) { |
7493 |
/* imageBits too small */ |
|
7494 |
printf("provided byteArray too small\n"); |
|
7495 |
goto fail; |
|
7496 |
} |
|
7497 |
if (image->bitmap_bit_order == MSBFirst) |
|
7498 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
|
7499 |
else |
|
7500 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
|
7501 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
7502 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
7503 |
if (image->byte_order == MSBFirst) |
|
7504 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
|
7505 |
else |
|
7506 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
|
7507 |
if (image->format == XYBitmap) |
|
7508 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
|
7509 |
else if (image->format == XYPixmap) |
|
7510 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
|
7511 |
else if (image->format == ZPixmap) |
|
7512 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7513 |
|
1344 | 7514 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
7515 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
7516 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
7517 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
7518 |
XDestroyImage(image); |
|
7519 |
RETURN ( true ); |
|
295 | 7520 |
} |
7521 |
fail: |
|
7522 |
if (image) { |
|
1344 | 7523 |
XDestroyImage(image); |
295 | 7524 |
} |
7525 |
%}. |
|
7526 |
^ false |
|
7527 |
! ! |
|
7528 |
||
7529 |
!XWorkstation methodsFor:'selections'! |
|
7530 |
||
1344 | 7531 |
getObjectProperty:propertyID from:aWindowID |
295 | 7532 |
"get an object property; return object or nil" |
7533 |
||
7534 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1344 | 7535 |
type == stringAtom ifTrue:[ |
7536 |
^ value |
|
7537 |
]. |
|
7538 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7539 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7540 |
] |
|
295 | 7541 |
]. |
7542 |
^ nil |
|
7543 |
! |
|
7544 |
||
1344 | 7545 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
295 | 7546 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
7547 |
||
7548 |
|val typeID cls| |
|
7549 |
||
7550 |
cls := ByteArray. |
|
7551 |
%{ |
|
7552 |
Window window; |
|
7553 |
Atom property; |
|
7554 |
char *cp, *cp2; |
|
7555 |
Atom actual_type; |
|
7556 |
int actual_format,i; |
|
7557 |
unsigned long nitems, bytes_after, nread; |
|
7558 |
unsigned char *data; |
|
7559 |
int ok = 1; |
|
7560 |
# define PROP_SIZE 2048 |
|
7561 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7562 |
if (ISCONNECTED) { |
1344 | 7563 |
Display *dpy = myDpy; |
7564 |
||
7565 |
if (__isAtomID(propertyID)) { |
|
7566 |
property = _AtomVal(propertyID); |
|
7567 |
if (__isExternalAddress(aWindowID)) { |
|
7568 |
window = _WindowVal(aWindowID); |
|
7569 |
} else { |
|
7570 |
window = DefaultRootWindow(dpy); |
|
7571 |
} |
|
7572 |
||
7573 |
nread = 0; |
|
7574 |
cp = 0; |
|
295 | 7575 |
/* |
1344 | 7576 |
fprintf(stderr, "getProperty: "); |
295 | 7577 |
*/ |
1344 | 7578 |
do { |
7579 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7580 |
AnyPropertyType,&actual_type,&actual_format, |
|
7581 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7582 |
!= Success) { |
|
7583 |
ok = 0; |
|
7584 |
break; |
|
7585 |
} |
|
7586 |
typeID = __MKATOMOBJ(actual_type); |
|
7587 |
if (! cp) { |
|
7588 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7589 |
} else { |
|
7590 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7591 |
cp2 = cp + nread; |
|
7592 |
} |
|
7593 |
if (! cp) { |
|
7594 |
XFree(data); |
|
7595 |
goto fail; |
|
7596 |
} |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7597 |
|
1344 | 7598 |
nread += nitems; |
7599 |
bcopy(data, cp2, nitems); |
|
7600 |
XFree(data); |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7601 |
/* |
1344 | 7602 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7603 |
*/ |
1344 | 7604 |
} while (bytes_after > 0); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7605 |
/* |
1344 | 7606 |
fprintf(stderr, "\n"); |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7607 |
*/ |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7608 |
|
1344 | 7609 |
if (ok) { |
7610 |
if (actual_type == XA_STRING) { |
|
7611 |
cp[nread] = '\0'; |
|
7612 |
val = __MKSTRING_L(cp, nread); |
|
7613 |
} else { |
|
7614 |
val = __new(nread + OHDR_SIZE); |
|
7615 |
val->o_class = cls; |
|
7616 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
|
7617 |
} |
|
7618 |
} |
|
7619 |
if (cp) |
|
7620 |
free(cp); |
|
7621 |
} |
|
295 | 7622 |
} |
7623 |
fail: ; |
|
7624 |
%}. |
|
7625 |
typeID isNil ifTrue:[ |
|
1344 | 7626 |
^ false |
295 | 7627 |
]. |
7628 |
aTwoArgBlock value:typeID value:val. |
|
7629 |
^ true |
|
7630 |
! |
|
7631 |
||
1344 | 7632 |
getSelectionFor:drawableId |
295 | 7633 |
"get the object selection - either immediate, or asynchronous. |
7634 |
Returns nil, if async request is on its way" |
|
7635 |
||
7636 |
|selProp sel| |
|
7637 |
||
7638 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 7639 |
"no primary selection - use cut buffer" |
7640 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7641 |
^ sel |
|
295 | 7642 |
]. |
7643 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7644 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7645 |
^ nil |
|
7646 |
! |
|
7647 |
||
1344 | 7648 |
getSelectionOwnerOf:selectionAtomID |
295 | 7649 |
"get the owner of a selection" |
7650 |
||
7651 |
%{ /* NOCONTEXT */ |
|
7652 |
Atom selection; |
|
7653 |
Window window; |
|
7654 |
||
7655 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
1344 | 7656 |
Display *dpy = myDpy; |
7657 |
||
7658 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7659 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
295 | 7660 |
} |
7661 |
%}. |
|
7662 |
self primitiveFailed. |
|
7663 |
^ nil |
|
7664 |
! |
|
7665 |
||
1344 | 7666 |
getTextProperty:propertyID from:aWindowID |
295 | 7667 |
"get a text property; return string or nil" |
7668 |
||
7669 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
1344 | 7670 |
type == stringAtom ifTrue:[ |
7671 |
^ value |
|
7672 |
] |
|
295 | 7673 |
]. |
7674 |
^ nil |
|
7675 |
! |
|
7676 |
||
1344 | 7677 |
getTextSelectionFor:drawableId |
295 | 7678 |
"get the text selection - either immediate, or asynchronous. |
7679 |
Returns nil, if async request is on its way" |
|
7680 |
||
7681 |
|selProp sel| |
|
7682 |
||
7683 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
1344 | 7684 |
"no primary selection - use cut buffer" |
7685 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7686 |
^ sel |
|
295 | 7687 |
]. |
7688 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7689 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7690 |
^ nil |
|
7691 |
! |
|
7692 |
||
1344 | 7693 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
295 | 7694 |
"ask the server to send us the selection - the view with ID aWindowID |
7695 |
will later receive a SelectionNotify event for it." |
|
7696 |
||
7697 |
^ self requestSelection:selectionID |
|
1344 | 7698 |
property:propertyID |
7699 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7700 |
for:aWindowId |
|
7701 |
! |
|
7702 |
||
7703 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
295 | 7704 |
"ask the server to send us the selection - the view with id aWindowID |
7705 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7706 |
with the selections value)." |
|
7707 |
||
7708 |
%{ /* NOCONTEXT */ |
|
7709 |
Atom sel_prop; |
|
7710 |
char *cp; |
|
7711 |
||
7712 |
if (__isExternalAddress(aWindowId) |
|
7713 |
&& ISCONNECTED |
|
7714 |
&& __isSmallInteger(typeID) |
|
7715 |
&& __isAtomID(selectionID)) { |
|
1344 | 7716 |
Display *dpy = myDpy; |
7717 |
||
7718 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7719 |
/* |
|
7720 |
* no owner of primary selection |
|
7721 |
*/ |
|
7722 |
RETURN (false); |
|
7723 |
} |
|
7724 |
/* |
|
7725 |
* PRIMARY selection |
|
7726 |
*/ |
|
7727 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7728 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7729 |
RETURN (true); |
|
295 | 7730 |
} |
7731 |
%}. |
|
7732 |
self primitiveFailed. |
|
7733 |
^ false |
|
7734 |
||
7735 |
" |
|
7736 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
1344 | 7737 |
property:(Display atomIDOf:'VT_SELECTION') |
7738 |
for:0 |
|
295 | 7739 |
" |
7740 |
! |
|
7741 |
||
1344 | 7742 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
295 | 7743 |
"ask the server to send us the selection - the view with ID aWindowID |
7744 |
will later receive a SelectionNotify event for it." |
|
7745 |
||
7746 |
^ self requestSelection:selectionID |
|
1344 | 7747 |
property:propertyID |
7748 |
type:stringAtom |
|
7749 |
for:aWindowId |
|
7750 |
! |
|
7751 |
||
7752 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7753 |
"send aString back from a SelectionRequest" |
7754 |
||
7755 |
self |
|
1344 | 7756 |
sendSelection:something |
7757 |
selection:primaryAtom |
|
7758 |
property:propertyID |
|
7759 |
target:targetID |
|
7760 |
from:windowID |
|
7761 |
to:requestorID |
|
7762 |
! |
|
7763 |
||
7764 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7765 |
"send aString back from a SelectionRequest" |
7766 |
||
7767 |
self |
|
1344 | 7768 |
setProperty:propertyID |
7769 |
type:targetID |
|
7770 |
value:something |
|
7771 |
for:requestorID. |
|
295 | 7772 |
self |
1344 | 7773 |
sendSelectionNotifySelection:selectionID |
7774 |
property:propertyID |
|
7775 |
target:targetID |
|
7776 |
from:requestorID |
|
7777 |
to:requestorID. |
|
7778 |
! |
|
7779 |
||
7780 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
295 | 7781 |
"send a selectionNotify back from a SelectionRequest" |
7782 |
||
7783 |
%{ /* NOCONTEXT */ |
|
7784 |
||
7785 |
if (__isAtomID(propertyID) |
|
7786 |
&& __isExternalAddress(requestorID) |
|
7787 |
&& ISCONNECTED |
|
7788 |
&& __isAtomID(targetID) |
|
7789 |
&& __isAtomID(selectionID)) { |
|
1344 | 7790 |
Display *dpy = myDpy; |
7791 |
XEvent ev; |
|
7792 |
Window requestor = _WindowVal(requestorID); |
|
7793 |
Atom property = _AtomVal(propertyID); |
|
7794 |
Atom target = _AtomVal(targetID); |
|
7795 |
Atom selection = _AtomVal(selectionID); |
|
7796 |
Status result; |
|
7797 |
||
7798 |
ev.xselection.type = SelectionNotify; |
|
7799 |
ev.xselection.selection = selection; |
|
7800 |
ev.xselection.target = target; |
|
7801 |
if (__isExternalAddress(windowID)) |
|
7802 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7803 |
else |
|
7804 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7805 |
ev.xselection.time = CurrentTime; |
|
7806 |
if (property == None) |
|
7807 |
ev.xselection.property = target; |
|
7808 |
else |
|
7809 |
ev.xselection.property = property; |
|
7810 |
||
7811 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7812 |
ev.xselection.selection, |
|
7813 |
ev.xselection.property, |
|
7814 |
ev.xselection.target, |
|
7815 |
ev.xselection.requestor, |
|
7816 |
requestor)); |
|
7817 |
||
7818 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7819 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7820 |
DPRINTF(("bad status\n")); |
|
7821 |
RETURN (false); |
|
7822 |
} |
|
7823 |
RETURN (true) |
|
382 | 7824 |
} |
7825 |
%}. |
|
7826 |
self primitiveFailed. |
|
7827 |
^ false |
|
295 | 7828 |
! |
7829 |
||
1344 | 7830 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
295 | 7831 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
7832 |
! |
|
7833 |
||
1344 | 7834 |
setObjectProperty:propertyID value:anObject for:aWindowID |
295 | 7835 |
|s| |
7836 |
||
7837 |
(anObject isMemberOf:String) ifTrue:[ |
|
1344 | 7838 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
295 | 7839 |
]. |
7840 |
s := WriteStream on:(ByteArray new:200). |
|
7841 |
anObject storeBinaryOn:s. |
|
7842 |
^ self |
|
1344 | 7843 |
setProperty:propertyID |
7844 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7845 |
value:(s contents) |
|
7846 |
for:aWindowID |
|
7847 |
! |
|
7848 |
||
7849 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
295 | 7850 |
|
7851 |
%{ /* UNLIMITEDSTACK */ |
|
7852 |
||
7853 |
Atom prop, type; |
|
7854 |
Window window; |
|
7855 |
unsigned int value; |
|
7856 |
||
7857 |
if (__isAtomID(propertyID) |
|
7858 |
&& __isAtomID(typeID) |
|
7859 |
&& ISCONNECTED |
|
7860 |
&& (__isString(anObject) |
|
1344 | 7861 |
|| __isSmallInteger(anObject) |
7862 |
|| __isSymbol(anObject) |
|
7863 |
|| __isByteArray(anObject) |
|
7864 |
|| __isWords(anObject))) { |
|
7865 |
||
7866 |
Display *dpy = myDpy; |
|
7867 |
||
7868 |
prop = _AtomVal(propertyID); |
|
7869 |
type = _AtomVal(typeID); |
|
7870 |
if (__isExternalAddress(aWindowID)) { |
|
7871 |
window = _WindowVal(aWindowID); |
|
7872 |
} else { |
|
7873 |
window = DefaultRootWindow(dpy); |
|
7874 |
} |
|
7875 |
if (__isSmallInteger(anObject)) { |
|
7876 |
value = __intVal(anObject); |
|
7877 |
XChangeProperty(dpy, window, prop, type, 32, |
|
7878 |
PropModeReplace, |
|
7879 |
(unsigned char *)(&value), sizeof(unsigned int)); |
|
7880 |
} else { |
|
7881 |
if (__isByteArray(anObject)) { |
|
7882 |
XChangeProperty(dpy, window, prop, type, 8, |
|
7883 |
PropModeReplace, |
|
7884 |
__ByteArrayInstPtr(anObject)->ba_element, |
|
7885 |
__byteArraySize(anObject)); |
|
7886 |
} else { |
|
7887 |
/* string or symbol or wordArray-like (16bit-string) object */ |
|
7888 |
if (__isWords(__qClass(anObject))) { |
|
7889 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
|
7890 |
PropModeReplace, |
|
7891 |
__stringVal(anObject), |
|
7892 |
__wordArraySize(anObject)); |
|
7893 |
} else { |
|
7894 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
|
7895 |
PropModeReplace, |
|
7896 |
__stringVal(anObject), |
|
7897 |
strlen(__stringVal(anObject))); |
|
7898 |
} |
|
7899 |
} |
|
7900 |
} |
|
7901 |
RETURN (true); |
|
295 | 7902 |
} |
7903 |
%}. |
|
7904 |
^ false |
|
7905 |
! |
|
7906 |
||
1344 | 7907 |
setSelection:anObject owner:aWindowId |
295 | 7908 |
"set the object selection, and make aWindowId be the owner. |
7909 |
This can be used by other Smalltalk(X) applications only." |
|
7910 |
||
7911 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 7912 |
^ false |
295 | 7913 |
]. |
7914 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7915 |
^ true |
|
7916 |
! |
|
7917 |
||
1344 | 7918 |
setSelectionOwner:aWindowId of:selectionID |
295 | 7919 |
"set the owner of a selection; return false if failed" |
7920 |
||
7921 |
%{ /* NOCONTEXT */ |
|
7922 |
Window win; |
|
7923 |
||
7924 |
if (__isExternalAddress(aWindowId) |
|
7925 |
&& __isAtomID(selectionID) |
|
7926 |
&& ISCONNECTED) { |
|
1344 | 7927 |
Display *dpy = myDpy; |
7928 |
||
7929 |
win = _WindowVal(aWindowId); |
|
7930 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7931 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7932 |
RETURN (false); |
|
7933 |
} |
|
7934 |
RETURN (true); |
|
295 | 7935 |
} |
7936 |
%} |
|
7937 |
. |
|
7938 |
self primitiveFailed. |
|
7939 |
^ nil |
|
7940 |
! |
|
7941 |
||
1344 | 7942 |
setTextProperty:propertyID value:aString for:aWindowID |
295 | 7943 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
7944 |
! |
|
7945 |
||
1344 | 7946 |
setTextSelection:aString owner:aWindowId |
295 | 7947 |
"set the text selection, and make aWindowId be the owner. |
7948 |
This can be used by any other X application." |
|
7949 |
||
7950 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
1344 | 7951 |
'XWorkstation [warning]: selection ownerchange failed' errorPrintCR. |
295 | 7952 |
]. |
7953 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
7954 |
|
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
7955 |
"Modified: 10.1.1997 / 18:18:00 / cg" |
295 | 7956 |
! ! |
7957 |
||
7958 |
!XWorkstation methodsFor:'window stuff'! |
|
7959 |
||
1344 | 7960 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
295 | 7961 |
"clear a rectangular area to viewbackground" |
7962 |
||
7963 |
%{ /* NOCONTEXT */ |
|
7964 |
||
7965 |
int w, h; |
|
7966 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7967 |
if (ISCONNECTED) { |
1344 | 7968 |
if (__isExternalAddress(aWindowId) |
7969 |
&& __bothSmallInteger(x, y) |
|
7970 |
&& __bothSmallInteger(width, height)) { |
|
7971 |
w = __intVal(width); |
|
7972 |
h = __intVal(height); |
|
7973 |
/* |
|
7974 |
* need this check here: some servers simply dump core with bad args |
|
7975 |
*/ |
|
7976 |
if ((w >= 0) && (h >= 0)) { |
|
7977 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
|
7978 |
} |
|
7979 |
RETURN ( self ); |
|
7980 |
} |
|
295 | 7981 |
} |
7982 |
%} |
|
7983 |
. |
|
7984 |
self primitiveFailed |
|
7985 |
! |
|
7986 |
||
1344 | 7987 |
clearWindow:aWindowId |
295 | 7988 |
"clear a window to viewbackground" |
7989 |
||
7990 |
%{ /* NOCONTEXT */ |
|
7991 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
7992 |
if (ISCONNECTED) { |
1344 | 7993 |
if (__isExternalAddress(aWindowId)) { |
7994 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7995 |
RETURN ( self ); |
|
7996 |
} |
|
295 | 7997 |
} |
7998 |
%} |
|
7999 |
. |
|
8000 |
self primitiveFailed |
|
8001 |
! |
|
8002 |
||
1344 | 8003 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
295 | 8004 |
"configure stacking operation of aWindowId w.r.t siblingId" |
8005 |
||
8006 |
%{ /* NOCONTEXT */ |
|
8007 |
||
8008 |
XWindowChanges chg; |
|
8009 |
int mask = CWSibling | CWStackMode; |
|
8010 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8011 |
if (ISCONNECTED) { |
1344 | 8012 |
if (__isExternalAddress(aWindowId) |
8013 |
&& __isExternalAddress(siblingId)) { |
|
8014 |
if (modeSymbol == @symbol(above)) { |
|
8015 |
chg.stack_mode = Above; |
|
8016 |
} else if (modeSymbol == @symbol(below)) { |
|
8017 |
chg.stack_mode = Below; |
|
8018 |
} else if (modeSymbol == @symbol(topIf)) { |
|
8019 |
chg.stack_mode = TopIf; |
|
8020 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
8021 |
chg.stack_mode = BottomIf; |
|
8022 |
} else if (modeSymbol == @symbol(opposite)) { |
|
8023 |
chg.stack_mode = Opposite; |
|
8024 |
} else { |
|
8025 |
mask = CWSibling; |
|
8026 |
} |
|
8027 |
||
8028 |
chg.sibling = _WindowVal(siblingId); |
|
8029 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
8030 |
mask, &chg); |
|
8031 |
RETURN ( self ); |
|
8032 |
} |
|
295 | 8033 |
} |
8034 |
bad: ; |
|
8035 |
%} |
|
8036 |
. |
|
8037 |
self primitiveFailed |
|
8038 |
! |
|
8039 |
||
1344 | 8040 |
lowerWindow:aWindowId |
295 | 8041 |
"bring a window to back" |
8042 |
||
8043 |
%{ /* NOCONTEXT */ |
|
8044 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8045 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8046 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8047 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
8048 |
RETURN ( self ); |
|
295 | 8049 |
} |
8050 |
%} |
|
8051 |
. |
|
8052 |
self primitiveFailed |
|
8053 |
! |
|
8054 |
||
1344 | 8055 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
295 | 8056 |
"make a window visible - either as icon or as a real view - needed for restart" |
8057 |
||
8058 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
8059 |
||
8060 |
aBoolean ifTrue:[ |
|
1344 | 8061 |
wicon := aView icon. |
8062 |
wicon notNil ifTrue:[ |
|
8063 |
wiconId := wicon id |
|
8064 |
]. |
|
8065 |
wiconView := aView iconView. |
|
8066 |
wiconView notNil ifTrue:[ |
|
8067 |
wiconViewId := wiconView id |
|
8068 |
]. |
|
8069 |
wlabel := aView label. |
|
295 | 8070 |
]. |
8071 |
%{ |
|
8072 |
||
8073 |
XWMHints wmhints; |
|
8074 |
XSizeHints szhints; |
|
8075 |
Window win; |
|
8076 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8077 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8078 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8079 |
Display *dpy = myDpy; |
8080 |
||
8081 |
win = _WindowVal(aWindowId); |
|
8082 |
||
8083 |
szhints.flags = 0; |
|
8084 |
if (__bothSmallInteger(xPos, yPos)) { |
|
8085 |
szhints.x = __intVal(xPos); |
|
8086 |
szhints.y = __intVal(yPos); |
|
8087 |
szhints.flags |= USPosition; |
|
8088 |
} |
|
8089 |
if (__bothSmallInteger(w, h)) { |
|
8090 |
szhints.width = __intVal(w); |
|
8091 |
szhints.height = __intVal(h); |
|
8092 |
szhints.flags |= USSize; |
|
8093 |
} |
|
8094 |
||
8095 |
if (aBoolean == true) { |
|
8096 |
char *windowName; |
|
8097 |
Pixmap iconBitmap = (Pixmap)0; |
|
8098 |
Window iconWindow; |
|
8099 |
||
8100 |
if (__isExternalAddress(wiconId)) |
|
8101 |
iconBitmap = _PixmapVal(wiconId); |
|
8102 |
else |
|
8103 |
iconBitmap = (Pixmap)0; |
|
8104 |
||
8105 |
if (__isExternalAddress(wiconViewId)) |
|
8106 |
iconWindow = _WindowVal(wiconViewId); |
|
8107 |
else |
|
8108 |
iconWindow = (Window)0; |
|
8109 |
||
8110 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
8111 |
windowName = (char *)_stringVal(wlabel); |
|
8112 |
else |
|
8113 |
windowName = ""; |
|
8114 |
||
8115 |
if (iconBitmap || windowName) { |
|
8116 |
XSetStandardProperties(dpy, win, |
|
8117 |
windowName, windowName, |
|
8118 |
iconBitmap, |
|
8119 |
0, 0, &szhints); |
|
8120 |
} |
|
8121 |
||
8122 |
wmhints.flags = 0; |
|
8123 |
if (iconBitmap) { |
|
8124 |
wmhints.flags |= IconPixmapHint; |
|
8125 |
wmhints.icon_pixmap = iconBitmap; |
|
8126 |
} |
|
8127 |
if (iconWindow) { |
|
8128 |
wmhints.flags |= IconWindowHint; |
|
8129 |
wmhints.icon_window = iconWindow; |
|
8130 |
} |
|
8131 |
||
8132 |
wmhints.initial_state = IconicState; |
|
8133 |
wmhints.flags |= StateHint; |
|
8134 |
XSetWMHints(dpy, win, &wmhints); |
|
8135 |
} |
|
8136 |
||
8137 |
if (szhints.flags) { |
|
8138 |
XSetNormalHints(dpy, win, &szhints); |
|
8139 |
} |
|
8140 |
||
8141 |
XMapWindow(dpy, win); |
|
8142 |
RETURN ( self ); |
|
295 | 8143 |
} |
8144 |
%} |
|
8145 |
. |
|
8146 |
self primitiveFailed |
|
8147 |
! |
|
8148 |
||
1344 | 8149 |
mapWindow:aWindowId |
295 | 8150 |
"make a window visible" |
8151 |
||
8152 |
%{ /* NOCONTEXT */ |
|
8153 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8154 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8155 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8156 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
8157 |
RETURN ( self ); |
|
295 | 8158 |
} |
8159 |
%} |
|
8160 |
. |
|
8161 |
self primitiveFailed |
|
8162 |
! |
|
8163 |
||
1344 | 8164 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
295 | 8165 |
"move and resize a window" |
8166 |
||
8167 |
%{ /* NOCONTEXT */ |
|
8168 |
||
8169 |
int newWidth, newHeight; |
|
8170 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8171 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8172 |
&& __isExternalAddress(aWindowId) |
295 | 8173 |
&& __bothSmallInteger(w, h) |
8174 |
&& __bothSmallInteger(x, y)) { |
|
1344 | 8175 |
newWidth = __intVal(w); |
8176 |
newHeight = __intVal(h); |
|
8177 |
if (newWidth < 1) newWidth = 1; |
|
8178 |
if (newHeight < 1) newHeight = 1; |
|
8179 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
8180 |
__intVal(x), __intVal(y), |
|
8181 |
newWidth, newHeight); |
|
8182 |
RETURN ( self ); |
|
295 | 8183 |
} |
8184 |
%} |
|
8185 |
. |
|
8186 |
self primitiveFailed |
|
8187 |
! |
|
8188 |
||
1344 | 8189 |
moveWindow:aWindowId x:x y:y |
295 | 8190 |
"move a window" |
8191 |
||
8192 |
%{ /* NOCONTEXT */ |
|
8193 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8194 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8195 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
1344 | 8196 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
8197 |
RETURN ( self ); |
|
295 | 8198 |
} |
8199 |
%} |
|
8200 |
. |
|
8201 |
self primitiveFailed |
|
8202 |
! |
|
8203 |
||
1344 | 8204 |
raiseWindow:aWindowId |
295 | 8205 |
"bring a window to front" |
8206 |
||
8207 |
%{ /* NOCONTEXT */ |
|
8208 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8209 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8210 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8211 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
8212 |
RETURN ( self ); |
|
295 | 8213 |
} |
8214 |
%} |
|
8215 |
. |
|
8216 |
self primitiveFailed |
|
8217 |
! |
|
8218 |
||
1344 | 8219 |
resizeWindow:aWindowId width:w height:h |
295 | 8220 |
"resize a window" |
8221 |
||
8222 |
%{ /* NOCONTEXT */ |
|
8223 |
||
8224 |
int newWidth, newHeight; |
|
8225 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8226 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8227 |
&& __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
1344 | 8228 |
newWidth = __intVal(w); |
8229 |
newHeight = __intVal(h); |
|
8230 |
if (newWidth < 1) newWidth = 1; |
|
8231 |
if (newHeight < 1) newHeight = 1; |
|
8232 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
8233 |
RETURN ( self ); |
|
295 | 8234 |
} |
8235 |
%} |
|
8236 |
. |
|
8237 |
self primitiveFailed |
|
8238 |
! |
|
8239 |
||
1344 | 8240 |
setBackingStore:how in:aWindowId |
295 | 8241 |
"turn on/off backing-store for a window" |
8242 |
||
8243 |
%{ /* NOCONTEXT */ |
|
8244 |
||
8245 |
XSetWindowAttributes wa; |
|
8246 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8247 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8248 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8249 |
if (__INST(ignoreBackingStore) != true) { |
8250 |
if (how == @symbol(always)) wa.backing_store = Always; |
|
8251 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
8252 |
else if (how == true) wa.backing_store = Always; |
|
8253 |
else wa.backing_store = 0; |
|
8254 |
BEGIN_INTERRUPTSBLOCKED |
|
8255 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
8256 |
END_INTERRUPTSBLOCKED |
|
8257 |
} |
|
8258 |
RETURN ( self ); |
|
295 | 8259 |
} |
8260 |
%}. |
|
8261 |
self primitiveFailed |
|
8262 |
! |
|
8263 |
||
1344 | 8264 |
setBitGravity:how in:aWindowId |
295 | 8265 |
"set bit gravity for a window" |
8266 |
||
8267 |
%{ /* NOCONTEXT */ |
|
8268 |
||
8269 |
XSetWindowAttributes wa; |
|
8270 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8271 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8272 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8273 |
if (how == @symbol(NorthWest)) { |
8274 |
wa.bit_gravity = NorthWestGravity; |
|
8275 |
} else if (how == @symbol(NorthEast)) { |
|
8276 |
wa.bit_gravity = NorthEastGravity; |
|
8277 |
} else if (how == @symbol(SouthWest)) { |
|
8278 |
wa.bit_gravity = SouthWestGravity; |
|
8279 |
} else if (how == @symbol(SouthEast)) { |
|
8280 |
wa.bit_gravity = SouthEastGravity; |
|
8281 |
} else if (how == @symbol(Center)) { |
|
8282 |
wa.bit_gravity = CenterGravity; |
|
8283 |
} else if (how == @symbol(North)) { |
|
8284 |
wa.bit_gravity = NorthGravity; |
|
8285 |
} else if (how == @symbol(South)) { |
|
8286 |
wa.bit_gravity = SouthGravity; |
|
8287 |
} else if (how == @symbol(West)) { |
|
8288 |
wa.bit_gravity = WestGravity; |
|
8289 |
} else if (how == @symbol(East)) { |
|
8290 |
wa.bit_gravity = EastGravity; |
|
8291 |
} else { |
|
8292 |
wa.bit_gravity = NorthWestGravity; |
|
8293 |
} |
|
8294 |
||
8295 |
BEGIN_INTERRUPTSBLOCKED |
|
8296 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
8297 |
END_INTERRUPTSBLOCKED |
|
8298 |
RETURN ( self ); |
|
295 | 8299 |
} |
8300 |
%}. |
|
8301 |
self primitiveFailed |
|
8302 |
! |
|
8303 |
||
1344 | 8304 |
setCursor:aCursorId in:aWindowId |
295 | 8305 |
"define a windows cursor" |
8306 |
||
8307 |
%{ /* NOCONTEXT */ |
|
8308 |
||
8309 |
Display *dpy = myDpy; |
|
8310 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8311 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8312 |
&& __isExternalAddress(aWindowId) |
295 | 8313 |
&& __isExternalAddress(aCursorId)) { |
1344 | 8314 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
8315 |
RETURN ( self ); |
|
295 | 8316 |
} |
8317 |
%}. |
|
8318 |
self primitiveFailed |
|
8319 |
! |
|
8320 |
||
1344 | 8321 |
setIconName:aString in:aWindowId |
295 | 8322 |
"define a windows iconname" |
8323 |
||
8324 |
%{ /* NOCONTEXT */ |
|
8325 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8326 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8327 |
&& __isExternalAddress(aWindowId) |
295 | 8328 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8329 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8330 |
RETURN ( self ); |
|
295 | 8331 |
} |
8332 |
%}. |
|
8333 |
self primitiveFailed |
|
8334 |
! |
|
8335 |
||
1344 | 8336 |
setSaveUnder:yesOrNo in:aWindowId |
295 | 8337 |
"turn on/off save-under for a window" |
8338 |
||
8339 |
%{ /* NOCONTEXT */ |
|
8340 |
||
8341 |
XSetWindowAttributes wa; |
|
8342 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8343 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8344 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8345 |
if (__INST(hasSaveUnder) == true) { |
8346 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
|
8347 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
8348 |
} |
|
8349 |
RETURN ( self ); |
|
295 | 8350 |
} |
8351 |
%}. |
|
8352 |
self primitiveFailed |
|
8353 |
! |
|
8354 |
||
1344 | 8355 |
setTransient:aWindowId for:aMainWindowId |
295 | 8356 |
"set aWindowId to be a transient of aMainWindow" |
8357 |
||
8358 |
%{ /* NOCONTEXT */ |
|
8359 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8360 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8361 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8362 |
Window w; |
8363 |
||
8364 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
|
8365 |
w = (Window) 0; |
|
8366 |
} else { |
|
8367 |
if (__isExternalAddress(aMainWindowId)) { |
|
8368 |
w = _WindowVal(aMainWindowId); |
|
8369 |
} else { |
|
8370 |
goto getOutOfHere; |
|
8371 |
} |
|
8372 |
} |
|
8373 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
|
8374 |
RETURN ( self ); |
|
295 | 8375 |
} |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
8376 |
getOutOfHere: ; |
295 | 8377 |
%}. |
8378 |
self primitiveFailed |
|
8379 |
! |
|
8380 |
||
1344 | 8381 |
setWindowBackground:aColorIndex in:aWindowId |
295 | 8382 |
"set the windows background color. This is the color with which |
8383 |
the view is filled whenever exposed. Do not confuse this with |
|
8384 |
the background drawing color, which is used with opaque drawing." |
|
8385 |
||
8386 |
%{ /* NOCONTEXT */ |
|
8387 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8388 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8389 |
&& __isExternalAddress(aWindowId) |
295 | 8390 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8391 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8392 |
RETURN ( self ); |
|
295 | 8393 |
} |
8394 |
%}. |
|
8395 |
self primitiveFailed |
|
8396 |
! |
|
8397 |
||
1344 | 8398 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
295 | 8399 |
"set the windows background pattern to be a form. |
8400 |
This is the pattern with which the view is filled whenever exposed. |
|
8401 |
Do not confuse this with the background drawing color, which is used |
|
8402 |
with opaque drawing." |
|
8403 |
||
8404 |
%{ /* NOCONTEXT */ |
|
8405 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8406 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8407 |
&& __isExternalAddress(aWindowId) |
295 | 8408 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8409 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8410 |
RETURN ( self ); |
|
295 | 8411 |
} |
8412 |
%}. |
|
8413 |
self primitiveFailed |
|
8414 |
! |
|
8415 |
||
1344 | 8416 |
setWindowBorderColor:aColorIndex in:aWindowId |
295 | 8417 |
"set the windows border color" |
8418 |
||
8419 |
%{ /* NOCONTEXT */ |
|
8420 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8421 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8422 |
&& __isExternalAddress(aWindowId) |
295 | 8423 |
&& __isSmallInteger(aColorIndex)) { |
1344 | 8424 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
8425 |
RETURN ( self ); |
|
295 | 8426 |
} |
8427 |
%}. |
|
8428 |
self primitiveFailed |
|
8429 |
! |
|
8430 |
||
1344 | 8431 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
295 | 8432 |
"set the windows border pattern" |
8433 |
||
8434 |
%{ /* NOCONTEXT */ |
|
8435 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8436 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8437 |
&& __isExternalAddress(aWindowId) |
295 | 8438 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8439 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
8440 |
RETURN ( self ); |
|
295 | 8441 |
} |
8442 |
%} |
|
8443 |
. |
|
8444 |
self primitiveFailed |
|
8445 |
! |
|
8446 |
||
1344 | 8447 |
setWindowBorderShape:aPixmapId in:aWindowId |
295 | 8448 |
"set the windows border shape" |
8449 |
||
8450 |
hasShapeExtension ifFalse:[^ self]. |
|
8451 |
||
8452 |
%{ /* NOCONTEXT */ |
|
8453 |
||
8454 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8455 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8456 |
&& __isExternalAddress(aWindowId) |
295 | 8457 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8458 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
8459 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
8460 |
RETURN ( self ); |
|
295 | 8461 |
} |
8462 |
#endif |
|
8463 |
%}. |
|
8464 |
self primitiveFailed |
|
8465 |
! |
|
8466 |
||
1344 | 8467 |
setWindowBorderWidth:aNumber in:aWindowId |
295 | 8468 |
"set the windows border width" |
8469 |
||
8470 |
%{ /* NOCONTEXT */ |
|
8471 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8472 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8473 |
&& __isExternalAddress(aWindowId) |
295 | 8474 |
&& __isSmallInteger(aNumber)) { |
1344 | 8475 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
8476 |
RETURN ( self ); |
|
295 | 8477 |
} |
8478 |
%}. |
|
8479 |
self primitiveFailed |
|
8480 |
! |
|
8481 |
||
1344 | 8482 |
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
|
8483 |
"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
|
8484 |
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
|
8485 |
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
|
8486 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8487 |
%{ |
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8488 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8489 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8490 |
XClassHint classhint; |
8491 |
||
8492 |
classhint.res_class = classhint.res_name = 0; |
|
8493 |
||
8494 |
if (__isString(wClass) || __isSymbol(wClass)) { |
|
8495 |
classhint.res_class = (char *)_stringVal(wClass); |
|
8496 |
} else if (wClass != nil) |
|
8497 |
goto error; |
|
8498 |
||
8499 |
if (__isString(wName) || __isSymbol(wName)) { |
|
8500 |
classhint.res_name = (char *)_stringVal(wName); |
|
8501 |
} else if (wName != nil) |
|
8502 |
goto error; |
|
8503 |
||
8504 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
|
8505 |
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
|
8506 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8507 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8508 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8509 |
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
|
8510 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
8511 |
|
1344 | 8512 |
setWindowGravity:how in:aWindowId |
295 | 8513 |
"set window gravity for a window" |
8514 |
||
8515 |
%{ /* NOCONTEXT */ |
|
8516 |
||
8517 |
XSetWindowAttributes wa; |
|
8518 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8519 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8520 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8521 |
if (how == @symbol(NorthWest)) { |
8522 |
wa.win_gravity = NorthWestGravity; |
|
8523 |
} else if (how == @symbol(NorthEast)) { |
|
8524 |
wa.win_gravity = NorthEastGravity; |
|
8525 |
} else if (how == @symbol(SouthWest)) { |
|
8526 |
wa.win_gravity = SouthWestGravity; |
|
8527 |
} else if (how == @symbol(SouthEast)) { |
|
8528 |
wa.win_gravity = SouthEastGravity; |
|
8529 |
} else if (how == @symbol(Center)) { |
|
8530 |
wa.win_gravity = CenterGravity; |
|
8531 |
} else if (how == @symbol(North)) { |
|
8532 |
wa.win_gravity = NorthGravity; |
|
8533 |
} else if (how == @symbol(South)) { |
|
8534 |
wa.win_gravity = SouthGravity; |
|
8535 |
} else if (how == @symbol(West)) { |
|
8536 |
wa.win_gravity = WestGravity; |
|
8537 |
} else if (how == @symbol(East)) { |
|
8538 |
wa.win_gravity = EastGravity; |
|
8539 |
} else { |
|
8540 |
wa.win_gravity = NorthWestGravity; |
|
8541 |
} |
|
8542 |
||
8543 |
BEGIN_INTERRUPTSBLOCKED |
|
8544 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8545 |
END_INTERRUPTSBLOCKED |
|
8546 |
RETURN ( self ); |
|
295 | 8547 |
} |
8548 |
%}. |
|
8549 |
self primitiveFailed |
|
8550 |
! |
|
8551 |
||
1344 | 8552 |
setWindowIcon:aForm in:aWindowId |
295 | 8553 |
"define a bitmap to be used as icon" |
8554 |
||
8555 |
|iconId| |
|
8556 |
||
8557 |
aForm notNil ifTrue:[ |
|
1344 | 8558 |
iconId := aForm id |
295 | 8559 |
]. |
8560 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8561 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8562 |
&& __isExternalAddress(iconId) |
295 | 8563 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8564 |
XWMHints hints; |
8565 |
||
8566 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8567 |
hints.flags = IconPixmapHint; |
|
8568 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8569 |
RETURN ( self ); |
|
295 | 8570 |
} |
8571 |
%}. |
|
8572 |
self primitiveFailed |
|
8573 |
! |
|
8574 |
||
1344 | 8575 |
setWindowIconWindow:aView in:aWindowId |
295 | 8576 |
"define a window to be used as icon" |
8577 |
||
8578 |
|iconWindowId| |
|
8579 |
||
8580 |
aView notNil ifTrue:[ |
|
1344 | 8581 |
iconWindowId := aView id |
295 | 8582 |
]. |
8583 |
%{ |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8584 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8585 |
&& __isExternalAddress(iconWindowId) |
295 | 8586 |
&& __isExternalAddress(aWindowId)) { |
1344 | 8587 |
XWMHints wmhints; |
8588 |
||
8589 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
8590 |
wmhints.flags = IconWindowHint; |
|
8591 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
8592 |
RETURN ( self ); |
|
295 | 8593 |
} |
8594 |
%}. |
|
8595 |
self primitiveFailed |
|
8596 |
! |
|
8597 |
||
1344 | 8598 |
setWindowName:aString in:aWindowId |
295 | 8599 |
"define a windows name" |
8600 |
||
8601 |
%{ /* NOCONTEXT */ |
|
8602 |
||
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8603 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8604 |
&& __isExternalAddress(aWindowId) |
295 | 8605 |
&& (__isString(aString) || __isSymbol(aString))) { |
1344 | 8606 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
8607 |
RETURN ( self ); |
|
295 | 8608 |
} |
8609 |
%}. |
|
8610 |
self primitiveFailed |
|
8611 |
! |
|
8612 |
||
1344 | 8613 |
setWindowShape:aPixmapId in:aWindowId |
295 | 8614 |
"set the windows shape" |
8615 |
||
8616 |
hasShapeExtension ifFalse:[^ self]. |
|
8617 |
||
8618 |
%{ /* NOCONTEXT */ |
|
8619 |
||
8620 |
#ifdef SHAPE |
|
1207
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8621 |
if (ISCONNECTED |
274dbb13f15a
always check if display connection is valid, before doing anything
Claus Gittinger <cg@exept.de>
parents:
1206
diff
changeset
|
8622 |
&& __isExternalAddress(aWindowId) |
295 | 8623 |
&& __isExternalAddress(aPixmapId)) { |
1344 | 8624 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
8625 |
0, 0, |
|
8626 |
_PixmapVal(aPixmapId), ShapeSet); |
|
8627 |
RETURN ( self ); |
|
295 | 8628 |
} |
8629 |
#endif |
|
8630 |
%}. |
|
8631 |
self primitiveFailed |
|
8632 |
! |
|
8633 |
||
1344 | 8634 |
unmapWindow:aWindowId |
295 | 8635 |
"make a window invisible" |
8636 |
||
8637 |
%{ /* NOCONTEXT */ |
|
8638 |
||
1214 | 8639 |
if (!ISCONNECTED) { |
1344 | 8640 |
RETURN ( self ); |
1214 | 8641 |
} |
8642 |
||
8643 |
if (__isExternalAddress(aWindowId)) { |
|
1344 | 8644 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
8645 |
RETURN ( self ); |
|
8646 |
} |
|
8647 |
%}. |
|
295 | 8648 |
self primitiveFailed |
8649 |
! ! |
|
8650 |
||
1171
a40ea3d796fd
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
8651 |
!XWorkstation class methodsFor:'documentation'! |
295 | 8652 |
|
8653 |
version |
|
1366 | 8654 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.207 1997-02-24 17:37:48 cg Exp $' |
295 | 8655 |
! ! |
8656 |
XWorkstation initialize! |