author | Claus Gittinger <cg@exept.de> |
Sat, 08 Feb 1997 20:34:37 +0100 | |
changeset 1318 | 5810dfc3137a |
parent 1317 | e1bd3b4aee72 |
child 1320 | 478840db1666 |
permissions | -rw-r--r-- |
26 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 3 |
All Rights Reserved |
26 | 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 |
" |
|
0 | 12 |
|
13 |
Object subclass:#WindowSensor |
|
326 | 14 |
instanceVariableNames:'eventSemaphore damage mouseAndKeyboard compressMotionEvents |
260 | 15 |
ignoreUserInput exposeEventSemaphore catchExpose gotExpose |
16 |
gotOtherEvent translateKeyboardEvents shiftDown ctrlDown metaDown |
|
17 |
altDown leftButtonDown middleButtonDown rightButtonDown |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
18 |
eventListener keyboardListener ignoreExposeEvents accessLock' |
326 | 19 |
classVariableNames:'ControlCEnabled EventListener ComposeTable GotCompose Compose1' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Support' |
|
0 | 22 |
! |
23 |
||
1082 | 24 |
!WindowSensor class methodsFor:'documentation'! |
46 | 25 |
|
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
72 | 29 |
All Rights Reserved |
46 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
72 | 42 |
Instances of this class keep track of events and damage areas for a group of |
43 |
views. All incoming expose rectangles and events (from Workstation) are |
|
144 | 44 |
collected here, until someone (usually the windowGroup process) |
45 |
gets a chance to handle them. |
|
46 |
In contrast to ST-80 (which has one windowSensor per window), ST/X usually |
|
47 |
only assigns one sensor per windowGroup. |
|
157 | 48 |
(however, you could manually arrange for per view private sensors |
49 |
- at least, theoretically) |
|
144 | 50 |
|
72 | 51 |
When adding an expose rectangle, WindowSensor tries to merge the rectangle |
52 |
with the list of existing damages to minimize redrawing. |
|
47 | 53 |
|
158 | 54 |
Processing of compose key sequences is done here; if a Compose |
55 |
key event arrives, the following 2 characters are used to search an |
|
56 |
entry in the composeTable, and are replaced by the character found there. |
|
57 |
For example, pressing Compose-a-` gives the french a-accent-grave character; |
|
58 |
pressing Compose-a-e gives the ae ligature. |
|
59 |
||
144 | 60 |
Beside the above, windowSensors provide facilities (hooks) to allow |
157 | 61 |
a so-called 'eventListener' to get the event before it is entered into |
144 | 62 |
the queue. There are 3 possible listening hooks available: |
63 |
||
1271 | 64 |
a global EventListener - gets keybd/mouse events for all views |
65 |
a per-sensor eventListener - gets only keybd/mouse events for this sensors wGroup |
|
66 |
a per-sensor keyboardListener - only gets keyboard events for this sensors wGroup |
|
144 | 67 |
|
172 | 68 |
(actually, there are two more mechanisms, event delegation which allows |
69 |
delegation of key- and buttonEvents of a specific view, |
|
70 |
and per-windowGroup eventHooks) |
|
144 | 71 |
|
72 |
The global eventListener is installed via a class method (eventListener:) to |
|
73 |
the WindowSensor class; local listeners are installed via instance methods. |
|
74 |
Each listener should return true, if it handled the event and that event should |
|
75 |
therefore NOT be enqueued. Likewise, if it returns false, the event is |
|
157 | 76 |
processed as usual (i.e. enqueued and forwarded to the views controller). |
77 |
||
144 | 78 |
The global listener is called before the local listener, which is called |
79 |
before the keyboard listener. If any returns true, later listeners wont get |
|
80 |
the event. |
|
81 |
EventListeners were added to allow the implementation of event recorders |
|
157 | 82 |
or other spy functionality. They also allow hooking up views which otherwise |
83 |
insist on doing things themself. |
|
144 | 84 |
|
85 |
Notice, that beside event listening, you can also define a delegate for |
|
86 |
a views keyboard and button events. |
|
87 |
Read the documentation in WindowEvent for more info. |
|
88 |
||
89 |
||
598 | 90 |
[instance variables:] |
1271 | 91 |
eventSemaphore <Semaphore> the semaphore to be signalled when an event |
92 |
(or damage) arrives |
|
47 | 93 |
|
1271 | 94 |
damage <Collection> collection of damage events |
47 | 95 |
|
1271 | 96 |
mouseAndKeyboard <Collection> collection of user events |
47 | 97 |
|
1271 | 98 |
compressMotionEvents <Boolean> if true, multiple motion events are |
99 |
compressed to one event. If false, each |
|
100 |
event is handled individual. |
|
101 |
(should be set to false when doing free-hand drawing) |
|
47 | 102 |
|
1271 | 103 |
ignoreUserInput <Boolean> if true, key & button events are ignored |
104 |
(usually set to true by WindowGroup, while a |
|
105 |
modalbox covers a view) |
|
47 | 106 |
|
1271 | 107 |
shiftDown <Boolean> true while shift/meta/control-key is pressed |
108 |
metaDown (to support ST-80 style query: sensor shiftDown) |
|
109 |
ctrlDown |
|
110 |
altDown (notice, that on most systems, alt and meta key is |
|
111 |
the same, both reported as #Alt) |
|
72 | 112 |
|
1271 | 113 |
exposeEventSemaphore <Semaphore> X-special: semaphore to be signalled when |
114 |
expose event arrives after a copyArea. |
|
47 | 115 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
116 |
catchExpose <SetOfView> if nonEMpty, the drawables which wait for |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
117 |
an expose/noExpose event. (after a copyArea) |
47 | 118 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
119 |
gotExpose <SetOfView> the set of drawables which got an expose/noExpose |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
120 |
event. (after a copyarea) |
47 | 121 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
122 |
gotOtherEvent <SetOfView> set of drawables which received if other events, |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
123 |
while waiting for expose (after a copyarea). |
47 | 124 |
|
1271 | 125 |
translateKeyboardEvents <Boolean> if true, keyboard events are translated via |
126 |
the devices leyboardMap; if false, they |
|
127 |
are reported as raw-keys. Default is true. |
|
81 | 128 |
|
1271 | 129 |
eventListener <Object> if non nil, this one will get all pointer |
130 |
and keyboard events for this sensors views first. |
|
131 |
If it returns true, the event is supposed to |
|
132 |
be already handled by the listener and not sent to |
|
133 |
the view. If false, the event is handled as usual. |
|
134 |
This allows applications to catch events for any of |
|
135 |
its views. |
|
140 | 136 |
|
1271 | 137 |
keyboardListener <Object> if non nil, this one will get all keyboard events |
138 |
for this sensors views first (but after the eventListener, |
|
139 |
if any). |
|
140 |
If it returns true, the event is supposed to |
|
141 |
be already handled by the listener and not sent to |
|
142 |
the view. If false, the event is handled as usual. |
|
143 |
This allows applications to catch events for any of |
|
144 |
its views. |
|
145 |
ApplicationModels can catch keyboard input with: |
|
146 |
postOpenWith:aBuilder |
|
147 |
aBuilder window sensor keyboardListener:self |
|
140 | 148 |
|
1271 | 149 |
accessLock <Semaphore> controls access to the event queues |
140 | 150 |
|
598 | 151 |
[class variables:] |
140 | 152 |
|
1271 | 153 |
ControlCEnabled <Boolean> if true (which is the default) Control-C |
154 |
will interrupt the process handling the |
|
155 |
view. |
|
156 |
For secure stand-alone applications, |
|
157 |
this can be set to false, in which case |
|
158 |
Control-C does NOT interrupt the process. |
|
124 | 159 |
|
1271 | 160 |
EventListener <Object> if non nil, this one will get all pointer |
161 |
and keyboard events for ALL views first. |
|
162 |
If it returns true, the event is supposed to |
|
163 |
be already handled by the listener and not enqueued. |
|
164 |
If false, the event is handled as usual. |
|
165 |
This allows overall event catchers to be |
|
166 |
installed for example to implement event |
|
167 |
recorders, active help managers etc. |
|
157 | 168 |
|
1271 | 169 |
ComposeTable <Array> compose-key translation table |
598 | 170 |
|
171 |
||
612 | 172 |
[author:] |
1271 | 173 |
Claus Gittinger |
612 | 174 |
|
598 | 175 |
[see also:] |
1271 | 176 |
WindowGroup |
177 |
WindowEvent KeyboardMap KeyboardForwarder EventListener |
|
178 |
DeviceWorkstation View |
|
46 | 179 |
" |
180 |
! ! |
|
181 |
||
1082 | 182 |
!WindowSensor class methodsFor:'initialization'! |
47 | 183 |
|
184 |
initialize |
|
581 | 185 |
"initialize the classes constants" |
186 |
||
81 | 187 |
ControlCEnabled := true. |
158 | 188 |
|
386 | 189 |
ComposeTable isNil ifTrue:[ |
1271 | 190 |
self initializeComposeKeyTable |
386 | 191 |
] |
157 | 192 |
|
193 |
" |
|
194 |
WindowSensor initialize |
|
195 |
" |
|
581 | 196 |
|
197 |
"Modified: 22.4.1996 / 16:19:24 / cg" |
|
198 |
! |
|
199 |
||
200 |
initializeComposeKeyTable |
|
201 |
"setup the composeKey table" |
|
202 |
||
203 |
ComposeTable := #( |
|
1271 | 204 |
"/ format is: |
205 |
"/ ( key1 key2 <character or asciiValue> ) |
|
206 |
"/ |
|
207 |
($+ $+ $#) "/ number-sign |
|
208 |
($A $A $@) "/ at-sign |
|
581 | 209 |
|
1271 | 210 |
($( $- ${) "/ left brace |
211 |
($) $- $}) "/ right brace |
|
581 | 212 |
|
1271 | 213 |
($| $c 16rA2) "/ cent-sign |
214 |
($| $S $$) "/ dollar-sign |
|
215 |
($= $L 16rA3) "/ pound-sign |
|
216 |
($= $Y 16rA5) "/ yen-sign |
|
217 |
($!! $s 16rA7) "/ section-sign |
|
218 |
($O $C 16rA9) "/ copyright |
|
219 |
($< $< 16rAB) "/ french <<-quotes |
|
220 |
($O $R 16rAE) "/ registered |
|
221 |
($/ $u 16rB5) "/ greek mu |
|
222 |
($!! $p 16rB6) "/ paragraph sign |
|
223 |
($> $> 16rBB) "/ french >> quotes |
|
224 |
($^ $0 16rB0) "/ degree sign |
|
225 |
($+ $- 16rB1) "/ plus-minus |
|
226 |
($^ $2 16rB2) "/ superscript-2 |
|
227 |
($^ $3 16rB3) "/ superscript-3 |
|
228 |
($^ $. 16rB7) "/ middle dot |
|
229 |
($^ $1 16rB9) "/ superscript-1 |
|
230 |
($1 $4 16rBC) "/ 1/4 |
|
231 |
($1 $2 16rBD) "/ 1/2 |
|
232 |
($3 $4 16rBE) "/ 3/4 |
|
233 |
($? $? 16rBF) "/ ?-inverted |
|
234 |
($- $: 16rF7) "/ divide |
|
581 | 235 |
|
1271 | 236 |
"/ diacriticals: Compose diacrit character |
237 |
"/ grave |
|
581 | 238 |
|
1271 | 239 |
($A $` 16rC0) "/ A-` |
240 |
($a $` 16rE0) "/ a-` |
|
241 |
($E $` 16rC8) "/ E-` |
|
242 |
($e $` 16rE8) "/ e-` |
|
243 |
($I $` 16rCC) "/ I-` |
|
244 |
($i $` 16rEC) "/ i-` |
|
245 |
($O $` 16rD2) "/ O-` |
|
246 |
($o $` 16rF2) "/ o-` |
|
247 |
($U $` 16rD9) "/ U-` |
|
248 |
($u $` 16rF9) "/ u-` |
|
581 | 249 |
|
1271 | 250 |
"/ acute |
251 |
($A $' 16rC1) "/ A-' |
|
252 |
($a $' 16rE1) "/ a-' |
|
253 |
($E $' 16rC9) "/ E-' |
|
254 |
($e $' 16rE9) "/ e-' |
|
255 |
($I $' 16rCD) "/ I-' |
|
256 |
($i $' 16rED) "/ i-' |
|
257 |
($O $' 16rD3) "/ O-' |
|
258 |
($o $' 16rF3) "/ o-' |
|
259 |
($U $' 16rDA) "/ U-' |
|
260 |
($u $' 16rFA) "/ u-' |
|
261 |
($Y $' 16rDD) "/ Y-' |
|
262 |
($y $' 16rFD) "/ y-' |
|
581 | 263 |
|
1271 | 264 |
"/ circumflex |
265 |
($A $^ 16rC2) "/ A-^ |
|
266 |
($a $^ 16rE2) "/ a-^ |
|
267 |
($E $^ 16rCA) "/ E-^ |
|
268 |
($e $^ 16rEA) "/ e-^ |
|
269 |
($I $^ 16rCE) "/ I-^ |
|
270 |
($i $^ 16rEE) "/ i-^ |
|
271 |
($O $^ 16rD4) "/ O-^ |
|
272 |
($o $^ 16rF4) "/ o-^ |
|
273 |
($U $^ 16rDB) "/ U-^ |
|
274 |
($u $^ 16rFB) "/ u-^ |
|
581 | 275 |
|
1271 | 276 |
"/ tilde |
277 |
($A $~ 16rC3) "/ A-~ |
|
278 |
($a $~ 16rE3) "/ a-~ |
|
279 |
($O $~ 16rD5) "/ O-~ |
|
280 |
($o $~ 16rF5) "/ o-~ |
|
281 |
($N $~ 16rD1) "/ N-tilde |
|
282 |
($n $~ 16rF1) "/ n-~ |
|
581 | 283 |
|
1271 | 284 |
"/ ring above |
285 |
($a $* 16rE5) "/ a-* |
|
286 |
($A $* 16rC5) "/ A-* |
|
581 | 287 |
|
1271 | 288 |
"/ cedille |
289 |
($C $, 16rC7) "/ C-, |
|
290 |
($c $, 16rE7) "/ c-, |
|
581 | 291 |
|
1271 | 292 |
"/ dieresis |
293 |
($A $" 16rC4) "/ A-" |
|
294 |
($a $" 16rE4) "/ a-" |
|
295 |
($E $" 16rCB) "/ E-" |
|
296 |
($e $" 16rEB) "/ e-" |
|
297 |
($I $" 16rCF) "/ I-" |
|
298 |
($i $" 16rEF) "/ i-" |
|
299 |
($O $" 16rD6) "/ O-" |
|
300 |
($o $" 16rF6) "/ o-" |
|
301 |
($U $" 16rDC) "/ U-" |
|
302 |
($u $" 16rFC) "/ u-" |
|
303 |
($y $" 16rFF) "/ y-" |
|
581 | 304 |
|
1271 | 305 |
"/ slashed |
306 |
($o $/ 16rF8) "/ o-/ |
|
307 |
($O $/ 16rD8) "/ O-/ |
|
608 | 308 |
|
1271 | 309 |
"/ ligatures |
310 |
($s $s 16rDF) "/ german sz |
|
311 |
($a $e 16rE6) "/ (french) ae |
|
312 |
($A $E 16rC6) "/ (french) AE |
|
581 | 313 |
). |
314 |
||
608 | 315 |
" |
581 | 316 |
WindowSensor initializeComposeKeyTable |
317 |
" |
|
318 |
||
319 |
"Created: 22.4.1996 / 14:06:43 / cg" |
|
608 | 320 |
"Modified: 24.4.1996 / 16:37:08 / cg" |
140 | 321 |
! ! |
81 | 322 |
|
1082 | 323 |
!WindowSensor class methodsFor:'instance creation'! |
140 | 324 |
|
325 |
new |
|
581 | 326 |
"return a new initialized instance" |
327 |
||
140 | 328 |
^ self basicNew initialize |
581 | 329 |
|
330 |
"Modified: 22.4.1996 / 16:19:40 / cg" |
|
124 | 331 |
! ! |
332 |
||
1082 | 333 |
!WindowSensor class methodsFor:'accessing'! |
47 | 334 |
|
244 | 335 |
composeTable |
336 |
"return the compose-key table. |
|
337 |
Entries consist of 3-element arrays each, where |
|
338 |
the first two entries (of each entry) are the raw characters, |
|
339 |
and the third is the resulting composed-key" |
|
340 |
||
341 |
^ ComposeTable |
|
342 |
! |
|
343 |
||
344 |
composeTable:aTable |
|
345 |
"set the compose-key table. |
|
346 |
Entries consist of 3-element arrays each, where |
|
347 |
the first two entries (of each entry) are the raw characters, |
|
348 |
and the third is the resulting composed-key" |
|
349 |
||
350 |
ComposeTable := aTable |
|
351 |
! |
|
352 |
||
144 | 353 |
controlCEnabled:aBoolean |
354 |
"enable/disable Control-C processing. |
|
355 |
If enabled, pressing CNTL-C in a view will interrupt it and bring |
|
72 | 356 |
its process into the debugger (actually raising signal). |
47 | 357 |
Otherwise, CNTL-C is sent to the view like any other key. |
144 | 358 |
The default is true (enabled). |
47 | 359 |
" |
360 |
||
144 | 361 |
ControlCEnabled := aBoolean |
124 | 362 |
! |
363 |
||
364 |
eventListener |
|
365 |
"return the eventListener |
|
366 |
- see documentation for what this can be used for" |
|
367 |
||
368 |
^ EventListener |
|
157 | 369 |
! |
370 |
||
244 | 371 |
eventListener:aListener |
372 |
"set the eventListener |
|
373 |
- see documentation for what this can be used for" |
|
157 | 374 |
|
244 | 375 |
EventListener := aListener |
47 | 376 |
! ! |
377 |
||
1082 | 378 |
!WindowSensor class methodsFor:'queries'! |
133 | 379 |
|
380 |
cursorPoint |
|
140 | 381 |
"ST-80 compatibility: |
157 | 382 |
return the position of the cursor on the current display" |
133 | 383 |
|
153 | 384 |
^ Screen current pointerPosition |
133 | 385 |
|
386 |
" |
|
387 |
WindowSensor cursorPoint |
|
388 |
" |
|
389 |
! ! |
|
390 |
||
244 | 391 |
!WindowSensor methodsFor:'accessing'! |
392 |
||
393 |
compressMotionEvents:aBoolean |
|
394 |
"turn on/off motion event compression" |
|
395 |
||
396 |
compressMotionEvents := aBoolean |
|
397 |
! |
|
398 |
||
399 |
eventListener |
|
400 |
"return the eventListener |
|
401 |
- see documentation for what this can be used for" |
|
402 |
||
403 |
^ eventListener |
|
404 |
! |
|
405 |
||
406 |
eventListener:aListener |
|
407 |
"set the eventListener |
|
408 |
- see documentation for what this can be used for" |
|
409 |
||
410 |
eventListener := aListener |
|
411 |
||
412 |
! |
|
140 | 413 |
|
244 | 414 |
eventSemaphore |
415 |
"return the semaphore used to signal event arrival" |
|
416 |
||
417 |
^ eventSemaphore |
|
418 |
! |
|
419 |
||
420 |
eventSemaphore:aSemaphore |
|
421 |
"set the semaphore used to signal event arrival" |
|
422 |
||
423 |
eventSemaphore := aSemaphore |
|
424 |
! |
|
425 |
||
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
426 |
ignoreExposeEvents:aBoolean |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
427 |
ignoreExposeEvents := aBoolean |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
428 |
|
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
429 |
"Created: 21.5.1996 / 18:21:18 / cg" |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
430 |
! |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
431 |
|
244 | 432 |
ignoreUserInput |
433 |
"return true, if Ctrl-C processing is currently turned off" |
|
434 |
||
435 |
^ ignoreUserInput |
|
436 |
! |
|
437 |
||
438 |
ignoreUserInput:aBoolean |
|
439 |
"turn on/off ignoring of Ctrl-C processing" |
|
440 |
||
441 |
ignoreUserInput := aBoolean |
|
140 | 442 |
! |
443 |
||
244 | 444 |
keyboardListener |
445 |
"return the keyboardListener |
|
446 |
- see documentation for what this can be used for" |
|
447 |
||
448 |
^ keyboardListener |
|
449 |
! |
|
450 |
||
451 |
keyboardListener:aListener |
|
452 |
"set the keyboardListener |
|
453 |
- see documentation for what this can be used for" |
|
454 |
||
455 |
keyboardListener := aListener |
|
456 |
||
457 |
! ! |
|
458 |
||
459 |
!WindowSensor methodsFor:'event flushing'! |
|
144 | 460 |
|
244 | 461 |
compressKeyPressEventsWithKey:aKey |
462 |
"count and remove multiple pending keyPress events for the |
|
463 |
same key, aKey. This is currently used in TextViews to compress |
|
464 |
multiple cursorUp/cursorDown events and do the scroll in one |
|
465 |
operation. (to avoid run-after-cursor on slow displays)" |
|
466 |
||
467 |
|n ev| |
|
468 |
||
469 |
n := 0. |
|
470 |
ev := self pendingEvent. |
|
471 |
[ev notNil and:[ev isKeyPressEvent]] whileTrue:[ |
|
472 |
((ev arguments at:1) == aKey) ifTrue:[ |
|
473 |
n := n + 1. |
|
474 |
self nextEvent. |
|
475 |
ev := self pendingEvent. |
|
476 |
] ifFalse:[ |
|
477 |
ev := nil |
|
478 |
] |
|
144 | 479 |
]. |
244 | 480 |
^ n |
481 |
! |
|
482 |
||
483 |
flushEventsFor:aView |
|
484 |
"throw away all events for aView, |
|
485 |
or any view, if the argument is nil." |
|
486 |
||
487 |
self flushExposeEventsFor:aView. |
|
488 |
self flushUserEventsFor:aView. |
|
489 |
! |
|
490 |
||
491 |
flushExposeEvents |
|
492 |
"throw away all pending expose events; this |
|
493 |
can be done after a full redraw (or in views, which are |
|
494 |
doing full redraws anly)" |
|
495 |
||
1317 | 496 |
self flushExposeEventsFor:nil. |
497 |
||
498 |
"/ (damage isNil or:[damage size > 0]) ifTrue:[ |
|
499 |
"/ damage := OrderedCollection new |
|
500 |
"/ ]. |
|
501 |
||
502 |
"Modified: 8.2.1997 / 15:13:21 / cg" |
|
144 | 503 |
! |
504 |
||
244 | 505 |
flushExposeEventsFor:aView |
506 |
"throw away all pending expose events for aView, |
|
507 |
or any view, if the argument is nil. |
|
508 |
This can be done after a full redraw |
|
509 |
(or in views, which are always doing full redraws - |
|
510 |
instead of drawing the clip-area only)" |
|
511 |
||
1317 | 512 |
|nEvent "{ Class: SmallInteger }" |
513 |
anEvent| |
|
157 | 514 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
515 |
accessLock critical:[ |
1317 | 516 |
damage notNil ifTrue:[ |
517 |
nEvent := damage size. |
|
518 |
1 to:nEvent do:[:index | |
|
519 |
anEvent := damage at:index. |
|
520 |
anEvent notNil ifTrue:[ |
|
521 |
anEvent isDamage ifTrue:[ |
|
522 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
523 |
damage at:index put:nil |
|
524 |
] |
|
525 |
] |
|
526 |
] |
|
527 |
] |
|
528 |
]. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
529 |
] |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
530 |
|
1317 | 531 |
"Modified: 8.2.1997 / 15:10:37 / cg" |
244 | 532 |
! |
533 |
||
534 |
flushKeyboard |
|
535 |
"ST-80 compatibility: throw away all pending keyboard events" |
|
536 |
||
537 |
self flushKeyboardFor:nil |
|
538 |
! |
|
539 |
||
540 |
flushKeyboardFor:aView |
|
541 |
"throw away all pending keyboard events for aView, |
|
542 |
or any view, if the argument is nil." |
|
543 |
||
544 |
|nEvent "{ Class: SmallInteger }"| |
|
545 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
546 |
accessLock critical:[ |
1271 | 547 |
mouseAndKeyboard notNil ifTrue:[ |
548 |
nEvent := mouseAndKeyboard size. |
|
549 |
1 to:nEvent do:[:i | |
|
550 |
|anEvent| |
|
244 | 551 |
|
1271 | 552 |
anEvent := mouseAndKeyboard at:i. |
553 |
(anEvent notNil and:[anEvent isKeyEvent]) ifTrue:[ |
|
554 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
555 |
mouseAndKeyboard at:i put:nil |
|
556 |
] |
|
557 |
] |
|
558 |
] |
|
559 |
]. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
560 |
] |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
561 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
562 |
"Modified: 18.1.1997 / 14:01:04 / cg" |
244 | 563 |
! |
564 |
||
565 |
flushUserEvents |
|
566 |
"throw away all pending user events" |
|
567 |
||
568 |
(mouseAndKeyboard isNil or:[mouseAndKeyboard size > 0]) ifTrue:[ |
|
1271 | 569 |
self flushUserEventsFor:nil |
244 | 570 |
]. |
1159
e5247f8a48f3
do not flush synthetic events in #flushUserEvents
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
571 |
|
e5247f8a48f3
do not flush synthetic events in #flushUserEvents
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
572 |
"Modified: 8.1.1997 / 11:23:11 / cg" |
244 | 573 |
! |
574 |
||
575 |
flushUserEventsFor:aView |
|
576 |
"throw away all pending user events for aView, |
|
1159
e5247f8a48f3
do not flush synthetic events in #flushUserEvents
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
577 |
or for any view, if the argument is nil." |
244 | 578 |
|
579 |
|nEvent "{ Class: SmallInteger }"| |
|
580 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
581 |
accessLock critical:[ |
1271 | 582 |
mouseAndKeyboard notNil ifTrue:[ |
583 |
nEvent := mouseAndKeyboard size. |
|
584 |
1 to:nEvent do:[:i | |
|
585 |
|anEvent| |
|
244 | 586 |
|
1271 | 587 |
anEvent := mouseAndKeyboard at:i. |
588 |
anEvent notNil ifTrue:[ |
|
589 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
590 |
anEvent isUserEvent ifTrue:[ |
|
591 |
mouseAndKeyboard at:i put:nil |
|
592 |
] |
|
593 |
] |
|
594 |
] |
|
595 |
] |
|
596 |
]. |
|
244 | 597 |
]. |
1159
e5247f8a48f3
do not flush synthetic events in #flushUserEvents
Claus Gittinger <cg@exept.de>
parents:
1155
diff
changeset
|
598 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
599 |
"Modified: 18.1.1997 / 14:01:17 / cg" |
157 | 600 |
! ! |
601 |
||
602 |
!WindowSensor methodsFor:'event processing'! |
|
603 |
||
140 | 604 |
buttonMotion:state x:x y:y view:aView |
605 |
"mouse was moved - this is sent from the device (Display)" |
|
606 |
||
607 |
|args| |
|
608 |
||
1100 | 609 |
"/ update my idea of shift/alt/ctrl pressed information |
610 |
self updateModifierStateFrom:state device:(aView graphicsDevice). |
|
611 |
||
140 | 612 |
EventListener notNil ifTrue:[ |
1271 | 613 |
(EventListener buttonMotion:state x:x y:y view:aView) ifTrue:[^ self] |
140 | 614 |
]. |
615 |
eventListener notNil ifTrue:[ |
|
1271 | 616 |
(eventListener buttonMotion:state x:x y:y view:aView) ifTrue:[^ self] |
140 | 617 |
]. |
618 |
||
619 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 620 |
^ self |
140 | 621 |
]. |
622 |
args := Array with:state with:x with:y. |
|
623 |
||
624 |
compressMotionEvents ifTrue:[ |
|
1271 | 625 |
" |
626 |
merge with last motion |
|
627 |
" |
|
628 |
accessLock critical:[ |
|
629 |
mouseAndKeyboard reverseDo:[:ev | |
|
630 |
ev notNil ifTrue:[ |
|
631 |
((ev type == #buttonMotion:x:y:) |
|
632 |
and:[(ev view == aView) |
|
633 |
and:[(ev arguments at:1) == state]]) ifTrue:[ |
|
634 |
ev arguments:args. |
|
635 |
^ self |
|
636 |
] |
|
637 |
] |
|
638 |
] |
|
639 |
] |
|
140 | 640 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
641 |
self pushEvent:(WindowEvent |
1271 | 642 |
for:aView |
643 |
type:#buttonMotion:x:y: |
|
644 |
arguments:args). |
|
1100 | 645 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
646 |
"Modified: 18.1.1997 / 14:06:07 / cg" |
140 | 647 |
! |
648 |
||
244 | 649 |
buttonMultiPress:button x:x y:y view:aView |
650 |
"mouse button was pressed - this is sent from the device (Display)" |
|
140 | 651 |
|
1083
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
652 |
self button:button inView:aView state:true. |
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
653 |
|
140 | 654 |
EventListener notNil ifTrue:[ |
1271 | 655 |
(EventListener buttonMultiPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 656 |
]. |
657 |
eventListener notNil ifTrue:[ |
|
1271 | 658 |
(eventListener buttonMultiPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 659 |
]. |
660 |
||
661 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 662 |
^ self |
140 | 663 |
]. |
1083
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
664 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
665 |
self pushEvent:(WindowEvent |
1271 | 666 |
for:aView |
667 |
type:#buttonMultiPress:x:y: |
|
668 |
arguments:(Array with:button with:x with:y)). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
669 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
670 |
"Modified: 18.1.1997 / 14:06:22 / cg" |
140 | 671 |
! |
672 |
||
673 |
buttonPress:button x:x y:y view:aView |
|
674 |
"mouse button was pressed - this is sent from the device (Display)" |
|
675 |
||
157 | 676 |
self button:button inView:aView state:true. |
677 |
||
140 | 678 |
EventListener notNil ifTrue:[ |
1271 | 679 |
(EventListener buttonPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 680 |
]. |
681 |
eventListener notNil ifTrue:[ |
|
1271 | 682 |
(eventListener buttonPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 683 |
]. |
684 |
||
685 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 686 |
^ self |
140 | 687 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
688 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
689 |
self pushEvent:(WindowEvent |
1271 | 690 |
for:aView |
691 |
type:#buttonPress:x:y: |
|
692 |
arguments:(Array with:button with:x with:y)). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
693 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
694 |
"Modified: 18.1.1997 / 14:06:33 / cg" |
140 | 695 |
! |
696 |
||
244 | 697 |
buttonRelease:button x:x y:y view:aView |
698 |
"mouse button was released- this is sent from the device (Display)" |
|
699 |
||
700 |
self button:button inView:aView state:false. |
|
701 |
||
702 |
EventListener notNil ifTrue:[ |
|
1271 | 703 |
(EventListener buttonRelease:button x:x y:y view:aView) ifTrue:[^ self] |
244 | 704 |
]. |
705 |
eventListener notNil ifTrue:[ |
|
1271 | 706 |
(eventListener buttonRelease:button x:x y:y view:aView) ifTrue:[^ self] |
244 | 707 |
]. |
708 |
||
709 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 710 |
^ self |
244 | 711 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
712 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
713 |
self pushEvent:(WindowEvent |
1271 | 714 |
for:aView |
715 |
type:#buttonRelease:x:y: |
|
716 |
arguments:(Array with:button with:x with:y)). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
717 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
718 |
"Modified: 18.1.1997 / 14:06:46 / cg" |
244 | 719 |
! |
720 |
||
721 |
configureX:x y:y width:w height:h view:aView |
|
722 |
"a views size or position has changed - this is sent from the device (Display)" |
|
723 |
||
1108
748f9e5c5b1e
ignore configureEvents for subviews.
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
724 |
aView superView notNil ifTrue:[ |
1271 | 725 |
"/ this is a configure event for a subView |
726 |
"/ I guess, this resulted from a resize of |
|
727 |
"/ myself (are there any windowManagers which resize sibviews ?) |
|
728 |
"/ Therefore, ignore it here. |
|
729 |
"/ This also fixed problems due to late-arriving configure events, |
|
730 |
"/ in case of a resized view, which was resized before. |
|
731 |
"/ Without the return below, we need a flushConfigureEvents entry here, |
|
732 |
"/ to be invoked whenever a subview is resized / repositioned. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
733 |
|
1271 | 734 |
^ self |
1108
748f9e5c5b1e
ignore configureEvents for subviews.
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
735 |
]. |
748f9e5c5b1e
ignore configureEvents for subviews.
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
736 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
737 |
self pushDamageEvent:(WindowEvent |
1271 | 738 |
for:aView |
739 |
type:#configureX:y:width:height: |
|
740 |
arguments:(Array with:x with:y with:w with:h)). |
|
1108
748f9e5c5b1e
ignore configureEvents for subviews.
Claus Gittinger <cg@exept.de>
parents:
1100
diff
changeset
|
741 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
742 |
"Modified: 18.1.1997 / 14:18:56 / cg" |
244 | 743 |
! |
744 |
||
745 |
coveredBy:sibling view:aView |
|
746 |
"aView was covered by one of its siblings - this is sent from the device (Display)" |
|
747 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
748 |
self pushDamageEvent:(WindowEvent |
1271 | 749 |
for:aView |
750 |
type:#coveredBy: |
|
751 |
arguments:(Array with:sibling)). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
752 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
753 |
"Modified: 18.1.1997 / 14:18:32 / cg" |
244 | 754 |
! |
755 |
||
756 |
destroyedView:aView |
|
757 |
"view was destroyed (from window manager) - this is sent from the device (Display)" |
|
758 |
||
759 |
"at this time, the view is already gone; remove |
|
760 |
all pending events for this one ..." |
|
761 |
||
762 |
self flushEventsFor:aView. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
763 |
self pushDamageEvent:(WindowEvent |
1271 | 764 |
for:aView |
765 |
type:#destroyed). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
766 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
767 |
"Modified: 18.1.1997 / 14:18:19 / cg" |
244 | 768 |
! |
769 |
||
770 |
exposeX:left y:top width:width height:height view:aView |
|
771 |
"an expose event arrived - this is sent from the device (Display)" |
|
772 |
||
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
773 |
ignoreExposeEvents ~~ true ifTrue:[ |
1271 | 774 |
self addDamage:(Rectangle left:left top:top width:width height:height) |
775 |
view:aView |
|
776 |
wakeup:true |
|
244 | 777 |
] |
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
778 |
|
1268
612204a36c38
no, regular expose events should not trigger the exposeSema
Claus Gittinger <cg@exept.de>
parents:
1264
diff
changeset
|
779 |
"Modified: 23.1.1997 / 22:32:32 / cg" |
140 | 780 |
! |
781 |
||
782 |
focusInView:aView |
|
783 |
"view got input focus - this is sent from the device (Display)" |
|
784 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
785 |
self pushEvent:(WindowEvent |
1271 | 786 |
for:aView |
787 |
type:#focusIn). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
788 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
789 |
"Modified: 18.1.1997 / 14:07:01 / cg" |
140 | 790 |
! |
791 |
||
244 | 792 |
focusOutView:aView |
793 |
"view lost input focus - this is sent from the device (Display)" |
|
140 | 794 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
795 |
self pushEvent:(WindowEvent |
1271 | 796 |
for:aView |
797 |
type:#focusOut). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
798 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
799 |
"Modified: 18.1.1997 / 14:07:09 / cg" |
140 | 800 |
! |
801 |
||
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
802 |
graphicsExposeX:left y:top width:width height:height final:final view:aView |
244 | 803 |
"a graphic expose event arrived - this is sent from the device (Display)" |
140 | 804 |
|
1243
0c33cb7f8458
hopefully fixed the 'lost expose' bug
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
805 |
"/ this is also a possible response to a scroll operation |
0c33cb7f8458
hopefully fixed the 'lost expose' bug
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
806 |
"/ (if an expose is pending) |
0c33cb7f8458
hopefully fixed the 'lost expose' bug
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
807 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
808 |
final ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
809 |
(catchExpose includes:aView) ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
810 |
gotExpose add:aView. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
811 |
exposeEventSemaphore signalForAll |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
812 |
] ifFalse:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
813 |
'WSensor [warning]: got exposeEvent for non-catching view:' infoPrint. aView infoPrintCR |
1271 | 814 |
] |
1243
0c33cb7f8458
hopefully fixed the 'lost expose' bug
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
815 |
]. |
0c33cb7f8458
hopefully fixed the 'lost expose' bug
Claus Gittinger <cg@exept.de>
parents:
1242
diff
changeset
|
816 |
|
751 | 817 |
self addDamage:(left @ top extent:width @ height) view:aView wakeup:false. |
818 |
||
1268
612204a36c38
no, regular expose events should not trigger the exposeSema
Claus Gittinger <cg@exept.de>
parents:
1264
diff
changeset
|
819 |
"Modified: 23.1.1997 / 22:15:53 / cg" |
140 | 820 |
! |
821 |
||
822 |
keyPress:key x:x y:y view:aView |
|
823 |
"key was pressed - this is sent from the device (Display). |
|
824 |
beside the keyboard translation, CntlC processing is done here." |
|
825 |
||
510 | 826 |
<resource: #keyboard ( #Compose #DestroyView #DestroyTopView #FlushInput |
1271 | 827 |
#UserInterrupt ) > |
510 | 828 |
|
140 | 829 |
|xlatedKey group process| |
830 |
||
144 | 831 |
self key:key state:true. |
832 |
||
140 | 833 |
EventListener notNil ifTrue:[ |
1271 | 834 |
(EventListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 835 |
]. |
836 |
eventListener notNil ifTrue:[ |
|
1271 | 837 |
(eventListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 838 |
]. |
839 |
keyboardListener notNil ifTrue:[ |
|
1271 | 840 |
(keyboardListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 841 |
]. |
842 |
||
843 |
translateKeyboardEvents ifTrue:[ |
|
1271 | 844 |
xlatedKey := aView graphicsDevice translateKey:key. |
140 | 845 |
] ifFalse:[ |
1271 | 846 |
xlatedKey := key. |
140 | 847 |
]. |
157 | 848 |
|
140 | 849 |
xlatedKey isNil ifTrue:[^ self]. |
850 |
||
157 | 851 |
(xlatedKey == #Compose) ifTrue:[ |
1271 | 852 |
GotCompose := true. Compose1 := nil. |
853 |
^ self |
|
157 | 854 |
]. |
855 |
GotCompose == true ifTrue:[ |
|
1271 | 856 |
Compose1 isNil ifTrue:[ |
857 |
(self isModifierKey:xlatedKey) ifFalse:[ |
|
858 |
Compose1 := xlatedKey. |
|
859 |
]. |
|
860 |
^ self |
|
861 |
]. |
|
862 |
(self isModifierKey:xlatedKey) ifFalse:[ |
|
863 |
xlatedKey := self compose:Compose1 with:xlatedKey. |
|
864 |
Compose1 := nil. GotCompose := false. |
|
865 |
] |
|
157 | 866 |
]. |
867 |
||
868 |
(xlatedKey == #CmdCtrlV) ifTrue:[ |
|
1271 | 869 |
'Smalltalk/X ' errorPrint. |
870 |
Smalltalk versionString errorPrint. ' of ' errorPrint. |
|
871 |
Smalltalk versionDate errorPrintCR. |
|
872 |
Smalltalk copyrightString errorPrintCR. |
|
140 | 873 |
]. |
874 |
||
157 | 875 |
(xlatedKey == #DestroyView) ifTrue:[ |
1271 | 876 |
aView closeRequest. |
157 | 877 |
]. |
878 |
(xlatedKey == #DestroyTopView) ifTrue:[ |
|
1271 | 879 |
aView topView closeRequest. |
157 | 880 |
]. |
881 |
||
152 | 882 |
(xlatedKey == #FlushInput) ifTrue:[ |
1271 | 883 |
"this removes any enqueued user events - |
884 |
helps, if you pressed DoIt too often, and want to flush those |
|
885 |
" |
|
886 |
self flushUserEvents. |
|
887 |
^ self |
|
152 | 888 |
]. |
889 |
||
140 | 890 |
((xlatedKey == #UserInterrupt) and:[ControlCEnabled]) ifTrue:[ |
1271 | 891 |
" |
892 |
Special handling for Ctrl-C: interrupt the underlying process. |
|
140 | 893 |
|
1271 | 894 |
cannot halt here (this would stop the event-dispatcher), |
895 |
but instead interrupt the underlying process and have it |
|
896 |
perform the userInterrupt in the interrupt-method. |
|
897 |
" |
|
898 |
group := aView windowGroup. |
|
899 |
group notNil ifTrue:[ |
|
900 |
process := group process. |
|
901 |
process notNil ifTrue:[ |
|
902 |
process interruptWith:[:where | process userInterruptIn:where] |
|
903 |
] |
|
904 |
]. |
|
905 |
^ self |
|
140 | 906 |
]. |
907 |
||
908 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 909 |
^ self |
140 | 910 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
911 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
912 |
self pushEvent:(WindowEvent |
1271 | 913 |
for:aView |
914 |
type:#keyPress:x:y: |
|
915 |
arguments:(Array with:xlatedKey with:x with:y)). |
|
510 | 916 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
917 |
"Modified: 18.1.1997 / 14:07:25 / cg" |
140 | 918 |
! |
919 |
||
920 |
keyRelease:key x:x y:y view:aView |
|
921 |
"key was released - this is sent from the device (Display)." |
|
922 |
||
923 |
|xlatedKey| |
|
924 |
||
144 | 925 |
self key:key state:false. |
926 |
||
140 | 927 |
EventListener notNil ifTrue:[ |
1271 | 928 |
(EventListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 929 |
]. |
930 |
eventListener notNil ifTrue:[ |
|
1271 | 931 |
(eventListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 932 |
]. |
933 |
keyboardListener notNil ifTrue:[ |
|
1271 | 934 |
(keyboardListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 935 |
]. |
936 |
||
937 |
ignoreUserInput == true ifTrue:[ |
|
1271 | 938 |
^ self |
140 | 939 |
]. |
940 |
translateKeyboardEvents ifTrue:[ |
|
1271 | 941 |
xlatedKey := aView graphicsDevice translateKey:key. |
140 | 942 |
] ifFalse:[ |
1271 | 943 |
xlatedKey := key. |
140 | 944 |
]. |
945 |
xlatedKey isNil ifTrue:[^ self]. |
|
946 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
947 |
self pushEvent:(WindowEvent |
1271 | 948 |
for:aView |
949 |
type:#keyRelease:x:y: |
|
950 |
arguments:(Array with:xlatedKey with:x with:y)). |
|
743 | 951 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
952 |
"Modified: 18.1.1997 / 14:07:36 / cg" |
140 | 953 |
! |
954 |
||
244 | 955 |
mappedView:aView |
956 |
"view was mapped (from window manager) - this is sent from the device (Display)" |
|
140 | 957 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
958 |
self pushDamageEvent:(WindowEvent |
1271 | 959 |
for:aView |
960 |
type:#mapped). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
961 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
962 |
"Modified: 18.1.1997 / 14:17:58 / cg" |
244 | 963 |
! |
964 |
||
965 |
noExposeView:aView |
|
966 |
"an noexpose event arrived - this is sent from the device (Display)" |
|
967 |
||
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
968 |
(catchExpose includes:aView) ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
969 |
gotExpose add:aView. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
970 |
exposeEventSemaphore signalForAll |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
971 |
] ifFalse:[ |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
972 |
'WSensor [warning]: got noExpose for non-catching view:' infoPrint. aView infoPrintCR |
244 | 973 |
] |
974 |
! |
|
975 |
||
976 |
pointerEnter:state x:x y:y view:aView |
|
977 |
"mouse cursor was moved into the view - this is sent from the device (Display)" |
|
978 |
||
470
c5c227de3443
care for wrong shift/ctrl/alt setting when pointer leaves view and reenters with different keyState
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
979 |
"/ update my idea of shift/alt/ctrl pressed information |
743 | 980 |
self updateModifierStateFrom:state device:(aView graphicsDevice). |
470
c5c227de3443
care for wrong shift/ctrl/alt setting when pointer leaves view and reenters with different keyState
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
981 |
|
244 | 982 |
EventListener notNil ifTrue:[ |
1271 | 983 |
(EventListener pointerEnter:state x:x y:y view:aView) ifTrue:[^ self] |
244 | 984 |
]. |
985 |
eventListener notNil ifTrue:[ |
|
1271 | 986 |
(eventListener pointerEnter:state x:x y:y view:aView) ifTrue:[^ self] |
244 | 987 |
]. |
988 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
989 |
self pushEvent:(WindowEvent |
1271 | 990 |
for:aView |
991 |
type:#pointerEnter:x:y: |
|
992 |
arguments:(Array with:state with:x with:y)). |
|
470
c5c227de3443
care for wrong shift/ctrl/alt setting when pointer leaves view and reenters with different keyState
Claus Gittinger <cg@exept.de>
parents:
428
diff
changeset
|
993 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
994 |
"Modified: 18.1.1997 / 14:07:58 / cg" |
244 | 995 |
! |
996 |
||
997 |
pointerLeave:state view:aView |
|
998 |
"mouse cursor was moved out of the view - this is sent from the device (Display)" |
|
999 |
||
1100 | 1000 |
"/ update my idea of shift/alt/ctrl pressed information |
1001 |
self updateModifierStateFrom:state device:(aView graphicsDevice). |
|
1002 |
||
244 | 1003 |
EventListener notNil ifTrue:[ |
1271 | 1004 |
(EventListener pointerLeave:state view:aView) ifTrue:[^ self] |
244 | 1005 |
]. |
1006 |
eventListener notNil ifTrue:[ |
|
1271 | 1007 |
(eventListener pointerLeave:state view:aView) ifTrue:[^ self] |
244 | 1008 |
]. |
1009 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1010 |
self pushEvent:(WindowEvent |
1271 | 1011 |
for:aView |
1012 |
type:#pointerLeave: |
|
1013 |
arguments:(Array with:state)). |
|
1100 | 1014 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1015 |
"Modified: 18.1.1997 / 14:08:07 / cg" |
140 | 1016 |
! |
1017 |
||
1018 |
saveAndTerminateView:aView |
|
1019 |
"view should save & terminate (from window manager) - this is sent from the device (Display)" |
|
1020 |
||
1021 |
self flushEventsFor:aView. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1022 |
self pushDamageEvent:(WindowEvent |
1271 | 1023 |
for:aView |
1024 |
type:#saveAndTerminate). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1025 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1026 |
"Modified: 18.1.1997 / 14:17:37 / cg" |
140 | 1027 |
! |
1028 |
||
244 | 1029 |
terminateView:aView |
1030 |
"view should terminate (from window manager) - this is sent from the device (Display)" |
|
140 | 1031 |
|
1032 |
self flushEventsFor:aView. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1033 |
self pushDamageEvent:(WindowEvent |
1271 | 1034 |
for:aView |
1035 |
type:#terminate). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1036 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1037 |
"Modified: 18.1.1997 / 14:17:24 / cg" |
244 | 1038 |
! |
1039 |
||
1040 |
unmappedView:aView |
|
1041 |
"view was unmapped (from window manager) - this is sent from the device (Display)" |
|
1042 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1043 |
self pushDamageEvent:(WindowEvent |
1271 | 1044 |
for:aView |
1045 |
type:#unmapped). |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1046 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1047 |
"Modified: 18.1.1997 / 14:17:01 / cg" |
0 | 1048 |
! ! |
1049 |
||
581 | 1050 |
!WindowSensor methodsFor:'event processing - private'! |
1051 |
||
1052 |
button:button inView:aView state:onOrOff |
|
1053 |
"update the state of the xxxButtonDown flags" |
|
1054 |
||
1055 |
|physicalButton| |
|
1056 |
||
743 | 1057 |
physicalButton := aView graphicsDevice buttonTranslation keyAtValue:button ifAbsent:button. |
1084 | 1058 |
|
581 | 1059 |
(physicalButton == 1) ifTrue:[ |
1271 | 1060 |
leftButtonDown := onOrOff. |
1061 |
^ self |
|
581 | 1062 |
]. |
1063 |
(physicalButton == 2) ifTrue:[ |
|
1271 | 1064 |
middleButtonDown := onOrOff. |
1065 |
^ self |
|
581 | 1066 |
]. |
1067 |
(physicalButton == 3) ifTrue:[ |
|
1271 | 1068 |
rightButtonDown := onOrOff. |
1069 |
^ self |
|
581 | 1070 |
]. |
743 | 1071 |
|
1084 | 1072 |
"Modified: 21.10.1996 / 11:47:35 / cg" |
581 | 1073 |
! |
1074 |
||
1075 |
compose:key1 with:key2 |
|
1076 |
"compose a 2-character sequence into a composed key" |
|
1077 |
||
1078 |
ComposeTable do:[:entry | |
|
1079 |
|v| |
|
1080 |
||
1081 |
((key1 == (entry at:1)) and:[key2 == (entry at:2)]) ifTrue:[ |
|
1082 |
v := entry at:3. |
|
1083 |
v isCharacter ifFalse:[v := Character value:v]. |
|
1084 |
^ v |
|
1085 |
] |
|
1086 |
]. |
|
1087 |
"/ |
|
1088 |
"/ for illegal sequence, return 2nd key |
|
1089 |
"/ |
|
1090 |
"/ key1 print. ' ' print. key2 printNL. |
|
1091 |
^ key2 |
|
1092 |
! |
|
1093 |
||
1094 |
isModifierKey:key |
|
1095 |
"return true if key is a modifier (Alt, Shift, Ctrl or Meta)" |
|
1096 |
||
1097 |
(key == #Shift |
|
1098 |
or:[key == #'Shift_R' |
|
1099 |
or:[key == #'Shift_L']]) ifTrue:[ |
|
1271 | 1100 |
^ true |
581 | 1101 |
]. |
1102 |
(key == #Alt |
|
1103 |
or:[key == #'Alt_R' or:[key == #'Alt_L']]) ifTrue:[ |
|
1271 | 1104 |
^ true |
581 | 1105 |
]. |
1106 |
(key == #Meta |
|
1107 |
or:[key == #'Meta_R' or:[key == #'Meta_L']]) ifTrue:[ |
|
1271 | 1108 |
^ true |
581 | 1109 |
]. |
1110 |
(key == #Control |
|
1111 |
or:[key == #'Control_R' or:[key == #'Control_L']]) ifTrue:[ |
|
1271 | 1112 |
^ true |
581 | 1113 |
]. |
1114 |
^ false |
|
1115 |
||
1116 |
"Modified: 22.4.1996 / 16:22:16 / cg" |
|
1117 |
! |
|
1118 |
||
1119 |
key:key state:onOrOff |
|
1120 |
"update the state of the shiftDown/metaDown and ctrlDown |
|
1121 |
flags" |
|
1122 |
||
1123 |
(key = #Shift |
|
1124 |
or:[key = #'Shift_R' |
|
1125 |
or:[key = #'Shift_L']]) ifTrue:[ |
|
1126 |
shiftDown := onOrOff. |
|
1127 |
^ self |
|
1128 |
]. |
|
1129 |
(key = #Alt |
|
1130 |
or:[key = #'Alt_R' or:[key = #'Alt_L']]) ifTrue:[ |
|
1131 |
altDown := onOrOff. |
|
1132 |
^ self |
|
1133 |
]. |
|
1134 |
(key = #Meta |
|
1135 |
or:[key = #'Meta_R' or:[key = #'Meta_L']]) ifTrue:[ |
|
1136 |
metaDown := onOrOff. |
|
1137 |
^ self |
|
1138 |
]. |
|
1139 |
(key = #Control |
|
1140 |
or:[key = #'Control_R' or:[key = #'Control_L']]) ifTrue:[ |
|
1141 |
ctrlDown := onOrOff. |
|
1142 |
^ self |
|
1143 |
]. |
|
1144 |
! |
|
1145 |
||
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1146 |
notifyEventArrival:aView |
581 | 1147 |
"an event arrived - if there is an eventSemaphore, |
1148 |
signal it, to wake up any windowGroup process" |
|
1149 |
||
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1150 |
(catchExpose includesIdentical:aView) ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1151 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1152 |
dont wake up, if we are currently waiting for an expose |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1153 |
but remember arrival of something. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1154 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1155 |
gotOtherEvent add:aView. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1156 |
^ self |
581 | 1157 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1158 |
|
581 | 1159 |
eventSemaphore notNil ifTrue:[ |
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1160 |
"/ eventSemaphore signal |
1184
1372bad824af
single trigger on the eventSemaphore is ok
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1161 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1162 |
"/ can get along with a single trigger; |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1163 |
"/ because processEvents will read all events |
1184
1372bad824af
single trigger on the eventSemaphore is ok
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1164 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1165 |
eventSemaphore signalOnce |
581 | 1166 |
] |
1184
1372bad824af
single trigger on the eventSemaphore is ok
Claus Gittinger <cg@exept.de>
parents:
1179
diff
changeset
|
1167 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1168 |
"Modified: 8.2.1997 / 12:01:48 / cg" |
581 | 1169 |
! |
1170 |
||
1171 |
updateModifierStateFrom:state device:aDevice |
|
1172 |
"this refetches the modifier key-states. |
|
1173 |
Called privately when pointer enters a view." |
|
1174 |
||
1175 |
"/ Prevents wrong behavior in the following scenario: |
|
1176 |
"/ ctrl is pressed in a view |
|
1177 |
"/ pointer is moved out of view |
|
1178 |
"/ ctrl is released |
|
1179 |
"/ pointer moved back into view |
|
1180 |
"/ popup-menu still thinks that ctrl is pressed" |
|
1181 |
||
1100 | 1182 |
shiftDown := "state bitAnd:(aDevice shiftMask) " aDevice shiftDown. |
1183 |
ctrlDown := "state bitAnd:(aDevice controlMask) " aDevice ctrlDown. |
|
1184 |
metaDown := "state bitAnd:(aDevice metaModifierMask) " aDevice metaDown. |
|
1185 |
altDown := "state bitAnd:(aDevice altModifierMask) " aDevice altDown. |
|
1186 |
||
1187 |
leftButtonDown := "state bitAnd:(aDevice leftButtonStateMask) " aDevice leftButtonPressed. |
|
1188 |
middleButtonDown := "state bitAnd:(aDevice middleButtonStateMask)" aDevice middleButtonPressed. |
|
1189 |
rightButtonDown := "state bitAnd:(aDevice rightButtonStateMask)" aDevice rightButtonPressed. |
|
581 | 1190 |
|
1191 |
"Created: 27.2.1996 / 14:54:38 / cg" |
|
1100 | 1192 |
"Modified: 1.11.1996 / 16:51:47 / cg" |
581 | 1193 |
! ! |
1194 |
||
140 | 1195 |
!WindowSensor methodsFor:'event queue'! |
1196 |
||
144 | 1197 |
addDamage:aRectangle view:aView |
1318 | 1198 |
"{ Pragma: +optSpeed }" |
1199 |
||
0 | 1200 |
"Add aRectangle to the damage list. |
144 | 1201 |
Try to merge incoming rectangles with the existing damage rectangles. |
1202 |
Incoming rectangles which are completely contained in any existing damage rect are ignored, |
|
1203 |
any existing damage rectangle which is completely contained in the incoming rectangle |
|
152 | 1204 |
is replaced. Also, rectangles are merged into bigger ones, if they join exactly. |
144 | 1205 |
Except for special cases (moveOpaque of a view over one of my views), |
1206 |
these optimizations are not noticable." |
|
0 | 1207 |
|
751 | 1208 |
^ self addDamage:aRectangle view:aView wakeup:true |
1209 |
||
1210 |
"Modified: 28.5.1996 / 21:52:47 / cg" |
|
1211 |
! |
|
1212 |
||
1213 |
addDamage:aRectangle view:aView wakeup:doWakeup |
|
1317 | 1214 |
"{ Pragma: +optSpeed }" |
1215 |
||
751 | 1216 |
"Add aRectangle to the damage list. |
1217 |
Try to merge incoming rectangles with the existing damage rectangles. |
|
1218 |
Incoming rectangles which are completely contained in any existing damage rect are ignored, |
|
1219 |
any existing damage rectangle which is completely contained in the incoming rectangle |
|
1220 |
is replaced. Also, rectangles are merged into bigger ones, if they join exactly. |
|
1221 |
Except for special cases (moveOpaque of a view over one of my views), |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1222 |
these optimizations are not noticable. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1223 |
Returns true, if a new event has been added to the queue, false if it |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1224 |
was optimized away." |
751 | 1225 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1226 |
|wakeup| |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1227 |
|
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1228 |
accessLock critical:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1229 |
(self basicAddDamage:aRectangle view:aView) |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1230 |
ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1231 |
doWakeup ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1232 |
self notifyEventArrival:aView. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1233 |
^ true |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1234 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1235 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1236 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1237 |
^ false |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1238 |
|
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1239 |
"Created: 28.5.1996 / 21:51:16 / cg" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1240 |
"Modified: 8.2.1997 / 12:10:35 / cg" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1241 |
! |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1242 |
|
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1243 |
basicAddDamage:aRectangle view:aView |
1317 | 1244 |
"{ Pragma: +optSpeed }" |
1245 |
||
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1246 |
"Add aRectangle to the damage list. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1247 |
Try to merge incoming rectangles with the existing damage rectangles. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1248 |
Incoming rectangles which are completely contained in any existing damage rect are ignored, |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1249 |
any existing damage rectangle which is completely contained in the incoming rectangle |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1250 |
is replaced. Also, rectangles are merged into bigger ones, if they join exactly. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1251 |
Except for special cases (moveOpaque of a view over one of my views), |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1252 |
these optimizations are not noticable. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1253 |
Returns true, if a new event has been added to the queue, false if it |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1254 |
was optimized away." |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1255 |
|
154 | 1256 |
|temp index newEvent r rL rT rB rR |
152 | 1257 |
count "{ Class: SmallInteger }" |
1258 |
sz "{ Class: SmallInteger }" |
|
322 | 1259 |
firstInteresting "{ Class: SmallInteger }" |
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1260 |
lastInteresting "{ Class: SmallInteger }" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1261 |
aDamage dRect dL dR dT dB fullRedraw| |
0 | 1262 |
|
152 | 1263 |
r := aRectangle. |
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1264 |
(fullRedraw := aView redrawsFull) ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1265 |
r := 0@0 corner:9999@9999. |
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1266 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1267 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1268 |
sz := damage size. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1269 |
sz == 0 ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1270 |
damage := OrderedCollection new:10. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1271 |
] ifFalse:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1272 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1273 |
first look, if this rectangle is already in the expose list; |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1274 |
if so, dont add to queue |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1275 |
On the fly, count the number of damages for this view |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1276 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1277 |
fullRedraw ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1278 |
firstInteresting := 1. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1279 |
lastInteresting := sz. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1280 |
] ifFalse:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1281 |
count := firstInteresting := 0. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1282 |
1 to:sz do:[:i | |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1283 |
aDamage := damage at:i. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1284 |
aDamage notNil ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1285 |
aDamage isDamage ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1286 |
aDamage view == aView ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1287 |
((aDamage rectangle) contains:r) ifTrue: [^ false]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1288 |
count := count + 1. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1289 |
lastInteresting := i. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1290 |
firstInteresting == 0 ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1291 |
firstInteresting := i |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1292 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1293 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1294 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1295 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1296 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1297 |
]. |
46 | 1298 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1299 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1300 |
are there any damages for this view in the queue ? |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1301 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1302 |
firstInteresting ~~ 0 ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1303 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1304 |
if there are already many damages for this view, |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1305 |
remove them all, and replace by a full expose |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1306 |
This limits the runtime spent here, which may become big |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1307 |
due to the square runtime behavior (stupid algorithm ...) |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1308 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1309 |
(fullRedraw or:[count > 30]) ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1310 |
r := 0@0 corner:99999@99999. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1311 |
firstInteresting to:lastInteresting do:[:i | |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1312 |
aDamage := damage at:i. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1313 |
aDamage notNil ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1314 |
aDamage isDamage ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1315 |
(aDamage view) == aView ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1316 |
damage at:i put:nil. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1317 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1318 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1319 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1320 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1321 |
newEvent := WindowEvent damageFor:aView rectangle:r. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1322 |
damage add:newEvent. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1323 |
^ true |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1324 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1325 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1326 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1327 |
then look, if the new rectangle contains any in the expose list; |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1328 |
if so, remove the old damage (here, by nilling it in the queue). |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1329 |
Or, merge it with existing rectangles if possible. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1330 |
" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1331 |
count := 0. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1332 |
rR := r right. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1333 |
rL := r left. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1334 |
rT := r top. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1335 |
rB := r bottom. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1336 |
firstInteresting to:lastInteresting do:[:i | |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1337 |
aDamage := damage at:i. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1338 |
aDamage notNil ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1339 |
aDamage isDamage ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1340 |
(aDamage view) == aView ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1341 |
dRect := aDamage rectangle. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1342 |
(r contains:dRect) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1343 |
damage at:i put:nil. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1344 |
count := count + 1 |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1345 |
] ifFalse:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1346 |
dL := dRect left. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1347 |
dT := dRect top. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1348 |
dR := dRect right. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1349 |
dB := dRect bottom. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1350 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1351 |
(rT == dT |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1352 |
and:[rB == dB]) ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1353 |
(rR > dR) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1354 |
(rL <= (dR + 1)) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1355 |
dRect right:rR. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1356 |
^ false |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1357 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1358 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1359 |
(rL < dL) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1360 |
(rR >= (dL - 1)) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1361 |
dRect left:rL. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1362 |
^ false |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1363 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1364 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1365 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1366 |
(rR == dR |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1367 |
and:[rL == dL]) ifTrue:[ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1368 |
(rB > dB) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1369 |
(rT <= (dB + 1)) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1370 |
dRect bottom:rB. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1371 |
^ false |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1372 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1373 |
]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1374 |
(rT < dT) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1375 |
(rB >= (dT - 1)) ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1376 |
dRect top:rT. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1377 |
^ false |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1378 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1379 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1380 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1381 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1382 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1383 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1384 |
] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1385 |
]. |
152 | 1386 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1387 |
"/ " |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1388 |
"/ if we nilled more then 20 events, reorganize the queue |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1389 |
"/ (doing this for every 20 removes only avoids excessive |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1390 |
"/ reorganization of the input queue) |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1391 |
"/ " |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1392 |
"/ count > 20 ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1393 |
"/ temp := OrderedCollection new:(sz - count + 1). |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1394 |
"/ index := 1. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1395 |
"/ 1 to:sz do:[:idx | |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1396 |
"/ aDamage := damage at:idx. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1397 |
"/ aDamage notNil ifTrue: [ |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1398 |
"/ temp add:aDamage. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1399 |
"/ ] |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1400 |
"/ ]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1401 |
"/ damage := temp |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1402 |
"/ ]. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1403 |
]. |
46 | 1404 |
]. |
1405 |
||
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1406 |
newEvent := WindowEvent damageFor:aView rectangle:r. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1407 |
damage add:newEvent. |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1408 |
|
144 | 1409 |
^ true |
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1410 |
|
1312
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1411 |
"Created: 8.2.1997 / 12:07:06 / cg" |
92570edec99c
try again with single wakeUp (#signalIf);
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
1412 |
"Modified: 8.2.1997 / 12:21:30 / cg" |
0 | 1413 |
! |
1414 |
||
428 | 1415 |
damage |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1416 |
"return the damage event list" |
428 | 1417 |
|
1418 |
^ damage. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1419 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1420 |
"Modified: 18.1.1997 / 14:11:08 / cg" |
428 | 1421 |
! |
1422 |
||
244 | 1423 |
nextDamage |
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1424 |
"retrieve the next damage (either expose or resize event) |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1425 |
or nil, if there is none. Remove it from the queue." |
244 | 1426 |
|
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1427 |
|d| |
244 | 1428 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1429 |
damage size == 0 ifTrue:[^ nil]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1430 |
|
244 | 1431 |
[d isNil] whileTrue:[ |
1271 | 1432 |
" |
1433 |
be careful: events are inserted at higher prio ... |
|
1434 |
" |
|
1435 |
accessLock critical:[ |
|
1436 |
damage size == 0 ifTrue:[^ nil]. |
|
1437 |
d := damage removeFirst. |
|
1438 |
] |
|
244 | 1439 |
]. |
1440 |
^ d |
|
476 | 1441 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1442 |
"Modified: 18.1.1997 / 14:13:50 / cg" |
244 | 1443 |
! |
1444 |
||
1445 |
nextEvent |
|
1446 |
"retrieve the next event or nil, if there is none. |
|
1447 |
Remove it from the queue." |
|
1448 |
||
1063 | 1449 |
|e| |
244 | 1450 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1451 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1452 |
|
244 | 1453 |
[e isNil] whileTrue:[ |
1271 | 1454 |
" |
1455 |
be careful: events are inserted at higher prio ... |
|
1456 |
" |
|
1457 |
accessLock critical:[ |
|
1458 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
|
1459 |
e := mouseAndKeyboard removeFirst. |
|
1460 |
] |
|
244 | 1461 |
]. |
1462 |
^ e |
|
476 | 1463 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1464 |
"Modified: 18.1.1997 / 14:13:39 / cg" |
244 | 1465 |
! |
1466 |
||
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1467 |
nextExposeEventFor:aView |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1468 |
"retrieve the next expose event for aView, or nil, if there is none. |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1469 |
Remove it from the queue." |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1470 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1471 |
damage size == 0 ifTrue:[^ nil]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1472 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1473 |
" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1474 |
be careful: events are inserted at higher prio ... |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1475 |
" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1476 |
accessLock critical:[ |
1271 | 1477 |
damage keysAndValuesDo:[:idx :aDamage | |
1478 |
aDamage notNil ifTrue:[ |
|
1479 |
aDamage view == aView ifTrue:[ |
|
1480 |
damage at:idx put:nil. |
|
1481 |
^ aDamage |
|
1482 |
]. |
|
1483 |
]. |
|
1484 |
] |
|
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1485 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1486 |
|
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1487 |
^ nil |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1488 |
|
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1489 |
"Created: 21.5.1996 / 17:20:54 / cg" |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1490 |
"Modified: 18.1.1997 / 14:14:59 / cg" |
703
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1491 |
! |
4324ab5e3630
added facility to lock expose event queue (temporary kludge ?)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
1492 |
|
140 | 1493 |
pendingEvent |
152 | 1494 |
"retrieve the next pending user (i.e. non-damage) event. |
1495 |
Return nil, if there is none pending. |
|
140 | 1496 |
Do not remove it from the queue." |
47 | 1497 |
|
1063 | 1498 |
|e| |
47 | 1499 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1500 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1501 |
|
47 | 1502 |
[e isNil] whileTrue:[ |
1271 | 1503 |
" |
1504 |
be careful: events are inserted at higher prio ... |
|
1505 |
" |
|
1506 |
accessLock critical:[ |
|
1507 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1508 |
|
1271 | 1509 |
e := mouseAndKeyboard first. |
1510 |
e isNil ifTrue:[ |
|
1511 |
mouseAndKeyboard removeFirst |
|
1512 |
]. |
|
1513 |
] |
|
0 | 1514 |
]. |
47 | 1515 |
^ e |
476 | 1516 |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1517 |
"Modified: 18.1.1997 / 14:13:04 / cg" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1518 |
! |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1519 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1520 |
pushDamageEvent:anEvent |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1521 |
"put an event into the damage queue |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1522 |
- this is not meant for public use" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1523 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1524 |
accessLock critical:[ |
1271 | 1525 |
damage addLast:anEvent. |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1526 |
self notifyEventArrival:anEvent view |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1527 |
]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1528 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1529 |
"Modified: 18.1.1997 / 14:04:39 / cg" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1530 |
"Created: 18.1.1997 / 14:16:45 / cg" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1531 |
! |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1532 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1533 |
pushEvent:anEvent |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1534 |
"put an event into the queue - this can also be sent by |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1535 |
applications and allows simulation of events |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1536 |
(implementation of recorders & playback) |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1537 |
or asynchronous communication between view applications |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1538 |
(by sending arbitrary events, which leads to a message sent, |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1539 |
when the target windowGroups process is rescheduled)." |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1540 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1541 |
accessLock critical:[ |
1271 | 1542 |
mouseAndKeyboard addLast:anEvent. |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1543 |
self notifyEventArrival:anEvent view |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1544 |
]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1545 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1546 |
"Created: 18.9.1995 / 22:37:57 / claus" |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1547 |
"Modified: 18.1.1997 / 14:04:39 / cg" |
0 | 1548 |
! ! |
1549 |
||
244 | 1550 |
!WindowSensor methodsFor:'event simulation'! |
1551 |
||
1552 |
forwardKeyEventsTo:aView |
|
1553 |
"remove all keyboard events and send them to aViews sensor instead" |
|
1554 |
||
1555 |
1 to:mouseAndKeyboard size do:[:i | |
|
1271 | 1556 |
|anEvent| |
244 | 1557 |
|
1271 | 1558 |
anEvent := mouseAndKeyboard at:i. |
1559 |
anEvent notNil ifTrue:[ |
|
1560 |
anEvent isKeyEvent ifTrue:[ |
|
1561 |
anEvent view:aView. |
|
1562 |
aView sensor pushEvent:anEvent. |
|
1563 |
mouseAndKeyboard at:i put:nil |
|
1564 |
] |
|
1565 |
] |
|
244 | 1566 |
]. |
1567 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1568 |
"Modified: 18.1.1997 / 14:05:02 / cg" |
244 | 1569 |
! |
1570 |
||
1571 |
pushUserEvent:aSelector for:aView |
|
1572 |
"manually put an event into the queue - this allows |
|
1573 |
simulation of events (implementation of recorders & playback) |
|
1574 |
or asynchronous communication between view applications. |
|
1575 |
The view will perform a method as specified by aSelector, |
|
1576 |
when it performs event processing; this is different than sending |
|
1577 |
this message directly, since the execution is done by the views process, |
|
1578 |
not by the current process (which is especially worthwhile, if that method |
|
1579 |
shows a modal box or similar)." |
|
1580 |
||
1581 |
self pushUserEvent:aSelector for:aView withArguments:#() |
|
1582 |
||
1583 |
"Modified: 18.9.1995 / 22:40:12 / claus" |
|
1584 |
! |
|
1585 |
||
1586 |
pushUserEvent:aSelector for:aView withArguments:arguments |
|
1587 |
"manually put an event into the queue - this allows |
|
1588 |
simulation of events (implementation of recorders & playback) |
|
1589 |
or asynchronous communication between view applications. |
|
1590 |
The view will perform a method as specified by aSelector, |
|
1591 |
when it performs event processing; this is different than sending |
|
1592 |
this message directly, since the execution is done by the views process, |
|
1593 |
not by the current process (which is especially worthwhile, if that method |
|
1594 |
shows a modal box or similar)." |
|
1595 |
||
1596 |
self pushEvent:(WindowEvent |
|
1271 | 1597 |
for:aView |
1598 |
type:aSelector |
|
1599 |
arguments:arguments). |
|
244 | 1600 |
|
1601 |
" |
|
1602 |
|b| |
|
1603 |
b := Button label:'test'. |
|
1604 |
b open. |
|
1605 |
(Delay forSeconds:5) wait. |
|
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1606 |
b sensor pushUserEvent:#pointerEnter:x:y: for:b withArguments:#(0 1 1). |
244 | 1607 |
(Delay forSeconds:1) wait. |
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1608 |
b sensor pushUserEvent:#buttonPress:x:y: for:b withArguments:#(1 1 1). |
244 | 1609 |
(Delay forSeconds:2) wait. |
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1610 |
b sensor pushUserEvent:#buttonRelease:x:y: for:b withArguments:#(1 1 1). |
244 | 1611 |
(Delay forSeconds:1) wait. |
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1612 |
b sensor pushUserEvent:#pointerLeave: for:b withArguments:#(0). |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1613 |
" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1614 |
|
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1615 |
" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1616 |
|b| |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1617 |
b := Button label:'test'. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1618 |
b open. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1619 |
(Delay forSeconds:5) wait. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1620 |
b sensor pushUserEvent:#fooBar for:b withArguments:#(). |
244 | 1621 |
" |
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1622 |
|
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1623 |
" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1624 |
|b| |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1625 |
b := Button label:'test'. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1626 |
b open. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1627 |
(Delay forSeconds:3) wait. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1628 |
b sensor pushUserEvent:#disable for:b withArguments:#(). |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1629 |
" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1630 |
|
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1631 |
"Modified: 4.1.1997 / 13:53:01 / cg" |
244 | 1632 |
! ! |
1633 |
||
1634 |
!WindowSensor methodsFor:'initialization'! |
|
1635 |
||
1636 |
initialize |
|
1637 |
"initialize the event queues to empty" |
|
1638 |
||
1271 | 1639 |
accessLock := Semaphore forMutualExclusion name:'WSensor ev-q accessLock'. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1640 |
|
244 | 1641 |
damage := OrderedCollection new. |
1642 |
mouseAndKeyboard := OrderedCollection new. |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1643 |
|
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1644 |
gotExpose := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1645 |
catchExpose := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1646 |
gotOtherEvent := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1647 |
exposeEventSemaphore := Semaphore new name:'WSensor exposeSema'. |
244 | 1648 |
|
1649 |
compressMotionEvents := translateKeyboardEvents := true. |
|
1650 |
ignoreUserInput := false. |
|
1651 |
shiftDown := ctrlDown := altDown := metaDown := false. |
|
1652 |
leftButtonDown := middleButtonDown := rightButtonDown := false. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1653 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1654 |
"Modified: 18.1.1997 / 15:30:20 / cg" |
244 | 1655 |
! |
1656 |
||
1657 |
reinitialize |
|
1658 |
"called when an image is restarted; |
|
1659 |
reinitialize the event queues to empty; leave other setup as-is" |
|
1660 |
||
1661 |
self flushUserEvents. |
|
1662 |
self flushExposeEvents. |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1663 |
|
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1664 |
gotExpose := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1665 |
catchExpose := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1666 |
gotOtherEvent := IdentitySet new. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1667 |
exposeEventSemaphore := Semaphore new name:'WSensor exposeSema'. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
1668 |
|
244 | 1669 |
shiftDown := ctrlDown := altDown := metaDown := false. |
1670 |
leftButtonDown := middleButtonDown := rightButtonDown := false. |
|
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1671 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
1672 |
"Modified: 18.1.1997 / 15:30:23 / cg" |
244 | 1673 |
! ! |
1674 |
||
1100 | 1675 |
!WindowSensor methodsFor:'queries - event queue'! |
1676 |
||
1677 |
eventPending |
|
1678 |
"return true, if either damage or events are pending" |
|
1679 |
||
1680 |
mouseAndKeyboard size ~~ 0 ifTrue:[^ true]. |
|
1681 |
^ damage size ~~ 0 |
|
1682 |
! |
|
1683 |
||
1684 |
hasButtonEventFor:aView |
|
1685 |
"return true, if any button events are pending. |
|
1686 |
If the argument, aView is nil, the information is regarding any |
|
1687 |
view (i.e. is there a button event for any of my views); |
|
1688 |
otherwise, the information is regrding that specific view." |
|
1689 |
||
1690 |
(self hasButtonMotionEventFor:aView) ifTrue:[^ true]. |
|
1691 |
(self hasButtonPressEventFor:aView) ifTrue:[^ true]. |
|
1692 |
^ (self hasButtonReleaseEventFor:aView) |
|
1693 |
||
1694 |
"Created: 1.11.1996 / 17:02:23 / cg" |
|
1695 |
"Modified: 1.11.1996 / 17:12:03 / cg" |
|
1696 |
! |
|
1697 |
||
1698 |
hasButtonMotionEventFor:aView |
|
1699 |
"return true, if any buttonMotion events are pending. |
|
1700 |
If the argument, aView is nil, the information is regarding any |
|
1701 |
view (i.e. is there a motion event for any of my views); |
|
1702 |
otherwise, the information is regrding that specific view." |
|
1703 |
||
1704 |
^ self hasEvent:#buttonMotion:x:y: orPendingDeviceEvent:#buttonMotion for:aView |
|
1705 |
||
1706 |
"Created: 1.11.1996 / 17:04:01 / cg" |
|
1707 |
! |
|
1708 |
||
1709 |
hasButtonPressEventFor:aView |
|
1710 |
"return true, if any buttonPress events are pending. |
|
1711 |
If the argument, aView is nil, the information is regarding any |
|
1712 |
view (i.e. is there a buttonPress event for any of my views); |
|
1713 |
otherwise, the information is regrding that specific view." |
|
1714 |
||
1715 |
^ self hasEvent:#buttonPress:x:y: orPendingDeviceEvent:#buttonPress for:aView |
|
1716 |
||
1717 |
"Created: 1.11.1996 / 17:05:10 / cg" |
|
1718 |
"Modified: 1.11.1996 / 17:11:09 / cg" |
|
1719 |
! |
|
1720 |
||
1721 |
hasButtonReleaseEventFor:aView |
|
1722 |
"return true, if any buttonRelease events are pending. |
|
1723 |
If the argument, aView is nil, the information is regarding any |
|
1724 |
view (i.e. is there a buttonrelease event for any of my views); |
|
1725 |
otherwise, the information is regrding that specific view." |
|
1726 |
||
1727 |
^ self hasEvent:#buttonRelease:x:y: orPendingDeviceEvent:#buttonRelease for:aView |
|
1728 |
||
1729 |
"Created: 1.11.1996 / 17:05:26 / cg" |
|
1730 |
"Modified: 1.11.1996 / 17:11:18 / cg" |
|
1731 |
! |
|
1732 |
||
1733 |
hasConfigureEventFor:aView |
|
1734 |
"return true, if any resize/position events are pending. |
|
1735 |
If the argument, aView is nil, the information is regarding any |
|
1736 |
view (i.e. is there a configure event for any of my views); |
|
1737 |
otherwise, the information is regrding that specific view." |
|
1738 |
||
1739 |
^ self hasEvent:#configureX:y:width:height: orPendingDeviceEvent:#structureNotify for:aView |
|
1740 |
||
1741 |
"Modified: 1.11.1996 / 17:11:27 / cg" |
|
1742 |
! |
|
1743 |
||
1744 |
hasDamage |
|
1745 |
"return true, if any damage events (i.e. expose or resize) are pending" |
|
1746 |
||
1747 |
^ damage size ~~ 0 |
|
1748 |
||
1749 |
"Modified: 21.5.1996 / 17:20:31 / cg" |
|
1750 |
! |
|
1751 |
||
1752 |
hasDamageFor:aView |
|
1753 |
"return true, if any damage events (i.e. expose or resize) |
|
1754 |
are pending for aView" |
|
1755 |
||
1756 |
damage size ~~ 0 ifTrue:[ |
|
1271 | 1757 |
damage do:[:aDamage | |
1758 |
aDamage notNil ifTrue:[ |
|
1759 |
aDamage view == aView ifTrue:[^ true]. |
|
1760 |
]. |
|
1761 |
] |
|
1100 | 1762 |
]. |
1763 |
^ false |
|
1764 |
||
1765 |
"Modified: 21.5.1996 / 17:15:09 / cg" |
|
1766 |
! |
|
1767 |
||
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1768 |
hasEvent:type for:aView withArguments:args |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1769 |
"return true, if a specific event is pending in my queues. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1770 |
Type is the type of event, args are the arguments. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1771 |
If the argument, aView is nil, the information is regarding any |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1772 |
view (i.e. is there an event for any of my views); |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1773 |
otherwise, the information is regarding to that specific view." |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1774 |
|
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1775 |
mouseAndKeyboard size ~~ 0 ifTrue:[ |
1271 | 1776 |
mouseAndKeyboard do:[:anEvent | |
1777 |
anEvent notNil ifTrue:[ |
|
1778 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1779 |
anEvent type == type ifTrue:[ |
|
1780 |
(args isNil or:[anEvent arguments = args]) ifTrue:[ |
|
1781 |
^ true |
|
1782 |
]. |
|
1783 |
] |
|
1784 |
] |
|
1785 |
]. |
|
1786 |
] |
|
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1787 |
]. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1788 |
damage size ~~ 0 ifTrue:[ |
1271 | 1789 |
damage do:[:anEvent | |
1790 |
anEvent notNil ifTrue:[ |
|
1791 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1792 |
anEvent type == type ifTrue:[ |
|
1793 |
(args isNil or:[anEvent arguments = args]) ifTrue:[ |
|
1794 |
^ true |
|
1795 |
] |
|
1796 |
]. |
|
1797 |
] |
|
1798 |
]. |
|
1799 |
] |
|
1155
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1800 |
]. |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1801 |
^ false |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1802 |
|
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1803 |
"Modified: 1.11.1996 / 17:11:47 / cg" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1804 |
"Created: 4.1.1997 / 14:00:29 / cg" |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1805 |
! |
e8b6f0e8484e
added query for event with args for view pending
Claus Gittinger <cg@exept.de>
parents:
1108
diff
changeset
|
1806 |
|
1100 | 1807 |
hasEvent:type orPendingDeviceEvent:dType for:aView |
1808 |
"return true, if a specific event is pending. |
|
1809 |
Type is the type of event, dType the corresponding device event. |
|
1810 |
If the argument, aView is nil, the information is regarding any |
|
1811 |
view (i.e. is there an event for any of my views); |
|
1812 |
otherwise, the information is regarding to that specific view." |
|
1813 |
||
1814 |
mouseAndKeyboard size ~~ 0 ifTrue:[ |
|
1271 | 1815 |
mouseAndKeyboard do:[:anEvent | |
1816 |
anEvent notNil ifTrue:[ |
|
1817 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1818 |
anEvent type == type ifTrue:[^ true]. |
|
1819 |
] |
|
1820 |
]. |
|
1821 |
] |
|
1100 | 1822 |
]. |
1823 |
damage size ~~ 0 ifTrue:[ |
|
1271 | 1824 |
damage do:[:anEvent | |
1825 |
anEvent notNil ifTrue:[ |
|
1826 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1827 |
anEvent type == type ifTrue:[^ true]. |
|
1828 |
] |
|
1829 |
]. |
|
1830 |
] |
|
1100 | 1831 |
]. |
1832 |
aView notNil ifTrue:[ |
|
1271 | 1833 |
^ aView graphicsDevice eventPending:dType for:aView id |
1100 | 1834 |
]. |
1835 |
^ false |
|
1836 |
||
1837 |
"Modified: 1.11.1996 / 17:11:47 / cg" |
|
1838 |
! |
|
1839 |
||
1840 |
hasEvents |
|
1841 |
"return true, if any mouse/keyboard events are pending" |
|
1842 |
||
1843 |
^ mouseAndKeyboard size ~~ 0 |
|
1844 |
! |
|
1845 |
||
1846 |
hasExposeEventFor:aView |
|
1847 |
"return true, if any exposure events are pending for aView" |
|
1848 |
||
1849 |
damage size ~~ 0 ifTrue:[ |
|
1271 | 1850 |
damage do:[:aDamage | |
1851 |
aDamage notNil ifTrue:[ |
|
1852 |
aDamage isDamage ifTrue:[ |
|
1853 |
(aView isNil |
|
1854 |
or:[aDamage view == aView]) ifTrue:[^ true]. |
|
1855 |
] |
|
1856 |
]. |
|
1857 |
] |
|
1100 | 1858 |
]. |
1859 |
^ false |
|
1860 |
||
1861 |
"Modified: 21.5.1996 / 17:13:09 / cg" |
|
1862 |
"Created: 1.11.1996 / 17:05:41 / cg" |
|
1863 |
! |
|
1864 |
||
1865 |
hasKeyEventFor:aView |
|
1866 |
"return true, if any key (press or release) events are pending. |
|
1867 |
If the argument, aView is nil, the information is regarding any |
|
1868 |
view (i.e. is there a key event for any of my views); |
|
1869 |
otherwise, the information is regrding that specific view." |
|
1870 |
||
1871 |
(self hasKeyPressEventFor:aView) ifTrue:[^ true]. |
|
1872 |
^ self hasKeyReleaseEventFor:aView |
|
1873 |
||
1874 |
"Created: 1.11.1996 / 17:08:03 / cg" |
|
1875 |
"Modified: 1.11.1996 / 17:11:55 / cg" |
|
1876 |
! |
|
1877 |
||
1878 |
hasKeyPressEventFor:aView |
|
1879 |
"return true, if any keyPress events are pending. |
|
1880 |
If the argument, aView is nil, the information is regarding any |
|
1881 |
view (i.e. is there a keyPress event for any of my views); |
|
1882 |
otherwise, the information is regrding that specific view." |
|
1883 |
||
1884 |
^ self hasEvent:#keyPress:x:y: orPendingDeviceEvent:#keyPress for:aView |
|
1885 |
||
1886 |
"Created: 1.11.1996 / 17:05:58 / cg" |
|
1887 |
"Modified: 1.11.1996 / 17:12:10 / cg" |
|
1888 |
! |
|
1889 |
||
1890 |
hasKeyReleaseEventFor:aView |
|
1891 |
"return true, if any keyRelease events are pending. |
|
1892 |
If the argument, aView is nil, the information is regarding any |
|
1893 |
view (i.e. is there a keyRelease event for any of my views); |
|
1894 |
otherwise, the information is regrding that specific view." |
|
1895 |
||
1896 |
^ self hasEvent:#keyRelease:x:y: orPendingDeviceEvent:#keyRelease for:aView |
|
1897 |
||
1898 |
"Created: 1.11.1996 / 17:06:34 / cg" |
|
1899 |
"Modified: 1.11.1996 / 17:12:15 / cg" |
|
1900 |
! |
|
1901 |
||
1902 |
hasUserEventFor:aView |
|
1903 |
"return true, if any user event (i.e. key or button events) are pending. |
|
1904 |
If the argument, aView is nil, the information is regarding any |
|
1905 |
view (i.e. is there a user event for any of my views); |
|
1906 |
otherwise, the information is regrding that specific view." |
|
1907 |
||
1908 |
(self hasKeyEventFor:aView) ifTrue:[^ true]. |
|
1909 |
^ (self hasButtonEventFor:aView) |
|
1910 |
||
1911 |
"Created: 1.11.1996 / 17:08:50 / cg" |
|
1912 |
"Modified: 1.11.1996 / 17:12:21 / cg" |
|
1913 |
! |
|
1914 |
||
1915 |
motionEventPending |
|
1916 |
"return true, if any buttonMotion events are pending." |
|
1917 |
||
1918 |
^ self hasButtonMotionEventFor:nil |
|
1919 |
||
1920 |
"Created: 24.3.1996 / 20:09:55 / cg" |
|
1921 |
"Modified: 1.11.1996 / 17:04:43 / cg" |
|
1922 |
! ! |
|
1923 |
||
1924 |
!WindowSensor methodsFor:'queries - key & button state'! |
|
140 | 1925 |
|
244 | 1926 |
altDown |
1927 |
"return true, if the meta key is currently pressed. |
|
1928 |
Notice, that some keyboards dont have an alt key; |
|
1929 |
it is better to use 'sensor metaDown or:[sensor altDown]'." |
|
1930 |
||
1931 |
^ altDown |
|
1932 |
! |
|
1933 |
||
1934 |
anyButtonPressed |
|
1935 |
"ST-80 compatibility: return true, if any mouse button is pressed. |
|
1936 |
You should no use it in 'normal' applications. |
|
1937 |
Instead, keep track of the buttons state in your views or controllers |
|
1938 |
button-event methods." |
|
1939 |
||
1083
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
1940 |
^ leftButtonDown or:[middleButtonDown or:[rightButtonDown]] |
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
1941 |
|
6e947cc67324
fixed #anyButtonPressed & setting of buttonDown-flags
Claus Gittinger <cg@exept.de>
parents:
1082
diff
changeset
|
1942 |
"Modified: 21.10.1996 / 11:37:31 / cg" |
244 | 1943 |
! |
1944 |
||
1945 |
blueButtonPressed |
|
1946 |
"ST-80 compatibility: return true, if the right mouse button is pressed. |
|
1947 |
You should no use it in 'normal' applications. |
|
1948 |
Instead, keep track of the buttons state in your views or controllers |
|
1949 |
button-event methods." |
|
1950 |
||
1951 |
^ rightButtonDown |
|
1952 |
! |
|
1953 |
||
1954 |
ctrlDown |
|
1955 |
"return true, if any CTRL key is currently pressed." |
|
1956 |
||
1957 |
^ ctrlDown |
|
1958 |
! |
|
1959 |
||
157 | 1960 |
leftButtonPressed |
1961 |
"return true, if the left mouse button is pressed. |
|
1962 |
This has been added to support ST-80 style button polling; |
|
1963 |
however, you should no use it in 'normal' applications. |
|
1964 |
Instead, keep track of the buttons state in your views or controllers |
|
1965 |
button-event methods." |
|
1966 |
||
1967 |
^ leftButtonDown |
|
1968 |
! |
|
1969 |
||
244 | 1970 |
metaDown |
1971 |
"return true, if the meta key is currently pressed. |
|
1972 |
Notice, that most keyboards dont have a meta key; |
|
1973 |
it is better to use 'sensor metaDown or:[sensor altDown]'." |
|
1974 |
||
1975 |
^ metaDown |
|
1976 |
! |
|
1977 |
||
157 | 1978 |
middleButtonPressed |
1979 |
"return true, if the middle mouse button is pressed. |
|
1980 |
This has been added to support ST-80 style button polling; |
|
1981 |
however, you should no use it in 'normal' applications. |
|
1982 |
Instead, keep track of the buttons state in your views or controllers |
|
1983 |
button-event methods." |
|
1984 |
||
1985 |
^ middleButtonDown |
|
1986 |
! |
|
1987 |
||
244 | 1988 |
redButtonPressed |
1989 |
"ST-80 compatibility: return true, if the left mouse button is pressed. |
|
1990 |
You should no use it in 'normal' applications. |
|
1991 |
Instead, keep track of the buttons state in your views or controllers |
|
1992 |
button-event methods." |
|
1993 |
||
1994 |
^ leftButtonDown |
|
1995 |
! |
|
1996 |
||
157 | 1997 |
rightButtonPressed |
1998 |
"return true, if the right mouse button is pressed. |
|
1999 |
This has been added to support ST-80 style button polling; |
|
2000 |
however, you should no use it in 'normal' applications. |
|
2001 |
Instead, keep track of the buttons state in your views or controllers |
|
2002 |
button-event methods." |
|
2003 |
||
2004 |
^ rightButtonDown |
|
2005 |
! |
|
2006 |
||
244 | 2007 |
shiftDown |
2008 |
"return true, if any shift key is currently pressed." |
|
157 | 2009 |
|
244 | 2010 |
^ shiftDown |
157 | 2011 |
! |
2012 |
||
2013 |
yellowButtonPressed |
|
2014 |
"ST-80 compatibility: return true, if the middle mouse button is pressed. |
|
2015 |
You should no use it in 'normal' applications. |
|
2016 |
Instead, keep track of the buttons state in your views or controllers |
|
2017 |
button-event methods." |
|
2018 |
||
2019 |
^ middleButtonDown |
|
140 | 2020 |
! ! |
2021 |
||
1100 | 2022 |
!WindowSensor methodsFor:'queries - pointer'! |
2023 |
||
2024 |
cursorPoint |
|
2025 |
"ST-80 compatibility: |
|
2026 |
return the position of the mouse pointer on the current display |
|
2027 |
(in screen coordinates)" |
|
2028 |
||
2029 |
^ self class cursorPoint |
|
2030 |
! |
|
2031 |
||
2032 |
globalOrigin |
|
2033 |
"ST-80 compatibility: |
|
2034 |
dont know what we should return here ... |
|
2035 |
... at least the PD program which uses it works when we return 0@0." |
|
2036 |
||
2037 |
^ 0@0 |
|
2038 |
! |
|
2039 |
||
2040 |
mousePoint |
|
2041 |
"ST-80 compatibility: |
|
2042 |
return the position of the mouse pointer on the current display |
|
2043 |
(in screen coordinates)" |
|
2044 |
||
2045 |
^ self cursorPoint |
|
2046 |
! ! |
|
2047 |
||
26 | 2048 |
!WindowSensor methodsFor:'special'! |
2049 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2050 |
catchExposeFor:aView |
54 | 2051 |
"start catching noExpose events (must be done BEFORE a bitblt, |
2052 |
to prepare for the exposeEventSemaphore to be signalled when |
|
2053 |
the noExpose event arrives)." |
|
26 | 2054 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2055 |
"/ this is only needed for X ... |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2056 |
aView device scrollsAsynchronous ifFalse:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2057 |
^ self |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2058 |
]. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2059 |
|
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2060 |
(catchExpose includes:aView) ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2061 |
('WSensor [warning]: already catching (for ' , aView printString , ')') errorPrintCR. |
1274 | 2062 |
Delay waitForMilliseconds:100. |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2063 |
(catchExpose includes:aView) ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2064 |
('WSensor [warning]: still catching (for ' , aView printString , ')') errorPrintCR. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2065 |
"/ wake the other one |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2066 |
gotExpose add:aView. |
1274 | 2067 |
exposeEventSemaphore signalForAll. |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2068 |
Delay waitForMilliseconds:100. |
1274 | 2069 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2070 |
]. |
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2071 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2072 |
[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2073 |
gotOtherEvent remove:aView ifAbsent:nil. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2074 |
gotExpose remove:aView ifAbsent:nil. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2075 |
catchExpose add:aView. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2076 |
] valueUninterruptably. |
28 | 2077 |
! |
2078 |
||
244 | 2079 |
waitButton |
2080 |
"ST-80 compatibility: wait until any mouse button is pressed. |
|
2081 |
Do not use this in your applications; polling the sensor is |
|
2082 |
bad style." |
|
2083 |
||
2084 |
[self anyButtonPressed] whileFalse:[ |
|
1271 | 2085 |
"/ should add a buttonStateChangeSemaphore and wait on this ... |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2086 |
|
1271 | 2087 |
Delay waitForSeconds:0.01. |
244 | 2088 |
]. |
2089 |
||
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2090 |
"Modified: 18.1.1997 / 14:21:59 / cg" |
244 | 2091 |
! |
2092 |
||
26 | 2093 |
waitForExposeFor:aView |
157 | 2094 |
"wait until a graphicsExpose or a noExpose arrives (after a bitblt). |
2095 |
This may be too X-specific, and things may change in this area |
|
2096 |
in future versions. (or the new device may simulate the arrival of |
|
2097 |
such an event)" |
|
54 | 2098 |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2099 |
"/ this is only needed for X ... |
1027
0ba82862ca8d
fixes for synchronous scrolling (WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
2100 |
aView device scrollsAsynchronous ifFalse:[ |
1271 | 2101 |
^ self |
1027
0ba82862ca8d
fixes for synchronous scrolling (WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
2102 |
]. |
0ba82862ca8d
fixes for synchronous scrolling (WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
1013
diff
changeset
|
2103 |
|
1013
32d804ff472d
cleanup when unwinding from a waitForExpose
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
2104 |
[ |
1271 | 2105 |
aView flush. |
2106 |
Processor activeProcessIsSystemProcess ifTrue:[ |
|
2107 |
" |
|
2108 |
cannot really suspend, if its a systemProcess |
|
2109 |
" |
|
2110 |
[gotExpose] whileFalse:[ |
|
2111 |
aView graphicsDevice dispatchExposeEventFor:aView id. |
|
2112 |
Processor yield. |
|
2113 |
] |
|
2114 |
] ifFalse:[ |
|
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2115 |
[ (gotExpose includes:aView) ] whileFalse:[ |
1271 | 2116 |
" |
2117 |
just in case we have a (network or software) problem ... |
|
2118 |
explanation: it may happen, that an expose event is totally |
|
2119 |
lost - for example, if the network breaks down. |
|
2120 |
To not block forever, we wait with a timeout, to get out of here |
|
2121 |
if the event does not arrive after 15 seconds. |
|
2122 |
" |
|
2123 |
(exposeEventSemaphore waitWithTimeout:5) isNil ifTrue:[ |
|
2124 |
aView graphicsDevice flush. |
|
2125 |
" |
|
2126 |
you can put a comment around the following line, if you dont |
|
2127 |
like the message ... |
|
2128 |
" |
|
2129 |
('WindowSensor [info]: late expose event (' , aView printString , ')') infoPrintCR. |
|
2130 |
(exposeEventSemaphore waitWithTimeout:10) isNil ifFalse:[ |
|
2131 |
'WindowSensor [warning]: lost expose event again - ignore' errorPrintCR. |
|
2132 |
]. |
|
2133 |
" |
|
2134 |
ok, break out |
|
2135 |
" |
|
2136 |
^ self |
|
2137 |
] |
|
2138 |
]. |
|
2139 |
]. |
|
1013
32d804ff472d
cleanup when unwinding from a waitForExpose
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
2140 |
] valueNowOrOnUnwindDo:[ |
1295
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2141 |
gotExpose remove:aView ifAbsent:nil. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2142 |
catchExpose remove:aView ifAbsent:nil. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2143 |
|
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2144 |
"/ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2145 |
"/ other incoming events have been ignored during the wait. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2146 |
"/ Now handle those ... |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2147 |
"/ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2148 |
(gotOtherEvent includes:aView) ifTrue:[ |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2149 |
gotOtherEvent remove:aView ifAbsent:nil. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2150 |
]. |
ef93ded3c030
renamed graphicExpose -> graphicsExpose;
Claus Gittinger <cg@exept.de>
parents:
1274
diff
changeset
|
2151 |
eventSemaphore signalOnce |
1013
32d804ff472d
cleanup when unwinding from a waitForExpose
Claus Gittinger <cg@exept.de>
parents:
1012
diff
changeset
|
2152 |
]. |
26 | 2153 |
|
1268
612204a36c38
no, regular expose events should not trigger the exposeSema
Claus Gittinger <cg@exept.de>
parents:
1264
diff
changeset
|
2154 |
"Modified: 23.1.1997 / 22:29:16 / cg" |
47 | 2155 |
! |
2156 |
||
157 | 2157 |
waitNoButton |
2158 |
"ST-80 compatibility: wait until no mouse button is pressed. |
|
2159 |
Do not use this in your applications; polling the sensor is |
|
2160 |
bad style." |
|
2161 |
||
2162 |
[self anyButtonPressed] whileTrue:[ |
|
1271 | 2163 |
"/ should add a buttonStateChangeSemaphore and wait on this ... |
2164 |
Delay waitForSeconds:0.01. |
|
157 | 2165 |
]. |
1241
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2166 |
|
c65f1c9d8de4
use critical regions around queue manipulation code.
Claus Gittinger <cg@exept.de>
parents:
1184
diff
changeset
|
2167 |
"Modified: 18.1.1997 / 14:21:56 / cg" |
157 | 2168 |
! ! |
2169 |
||
1082 | 2170 |
!WindowSensor class methodsFor:'documentation'! |
251 | 2171 |
|
2172 |
version |
|
1318 | 2173 |
^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.86 1997-02-08 19:34:37 cg Exp $' |
251 | 2174 |
! ! |
140 | 2175 |
WindowSensor initialize! |