author | Claus Gittinger <cg@exept.de> |
Tue, 26 Mar 1996 14:24:46 +0100 | |
changeset 547 | 53735597aa7e |
parent 539 | 8b7e0a35264d |
child 581 | 23dc2352dce9 |
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 |
|
18 |
eventListener keyboardListener' |
|
326 | 19 |
classVariableNames:'ControlCEnabled EventListener ComposeTable GotCompose Compose1' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Support' |
|
0 | 22 |
! |
23 |
||
46 | 24 |
!WindowSensor class methodsFor:'documentation'! |
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 |
||
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 |
|
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 |
||
47 | 90 |
instance variables: |
72 | 91 |
eventSemaphore <Semaphore> the semaphore to be signalled when an event |
92 |
(or damage) arrives |
|
47 | 93 |
|
72 | 94 |
damage <Collection> collection of damage events |
47 | 95 |
|
72 | 96 |
mouseAndKeyboard <Collection> collection of user events |
47 | 97 |
|
72 | 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 |
|
72 | 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 |
|
144 | 107 |
shiftDown <Boolean> true while shift/meta/control-key is pressed |
108 |
metaDown (to support ST-80 style query: sensor shiftDown) |
|
152 | 109 |
ctrlDown |
144 | 110 |
altDown (notice, that on most systems, alt and meta key is |
111 |
the same, both reported as #Alt) |
|
72 | 112 |
|
113 |
exposeEventSemaphore <Semaphore> X-special: semaphore to be signalled when |
|
114 |
expose event arrives after a copyArea. |
|
47 | 115 |
|
72 | 116 |
catchExpose <Boolean> true, while waiting for an expose event |
117 |
(after a copyArea) |
|
47 | 118 |
|
72 | 119 |
gotExpose <Boolean> set to true, when an expose event arrives |
120 |
(after a copyarea) |
|
47 | 121 |
|
72 | 122 |
gotOtherEvent <Boolean> set to true if other events arrive while |
123 |
waiting for expose (after a copyarea). |
|
47 | 124 |
|
81 | 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. |
|
128 |
||
140 | 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. |
|
136 |
||
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 |
|
148 |
||
149 |
||
47 | 150 |
class variables: |
140 | 151 |
|
72 | 152 |
ControlCEnabled <Boolean> if true (which is the default) Control-C |
153 |
will interrupt the process handling the |
|
154 |
view. |
|
155 |
For secure stand-alone applications, |
|
156 |
this can be set to false, in which case |
|
157 |
Control-C does NOT interrupt the process. |
|
124 | 158 |
|
159 |
EventListener <Object> if non nil, this one will get all pointer |
|
160 |
and keyboard events for ALL views first. |
|
287 | 161 |
If it returns true, the event is supposed to |
162 |
be already handled by the listener and not enqueued. |
|
163 |
If false, the event is handled as usual. |
|
124 | 164 |
This allows overall event catchers to be |
165 |
installed for example to implement event |
|
166 |
recorders, active help managers etc. |
|
157 | 167 |
|
168 |
ComposeTable <Array> compose-key translation table |
|
46 | 169 |
" |
170 |
! ! |
|
171 |
||
47 | 172 |
!WindowSensor class methodsFor:'initialization'! |
173 |
||
174 |
initialize |
|
81 | 175 |
ControlCEnabled := true. |
158 | 176 |
|
386 | 177 |
ComposeTable isNil ifTrue:[ |
178 |
ComposeTable := #( |
|
179 |
"/ key1 key2 -> character or asciiValue |
|
180 |
($+ $+ $#) "/ number-sign |
|
181 |
($A $A $@) "/ at-sign |
|
157 | 182 |
|
386 | 183 |
($( $- ${) "/ left brace |
184 |
($) $- $}) "/ right brace |
|
157 | 185 |
|
386 | 186 |
($| $c 16rA2) "/ cent-sign |
187 |
($| $S $$) "/ dollar-sign |
|
188 |
($= $L 16rA3) "/ pound-sign |
|
189 |
($= $Y 16rA5) "/ yen-sign |
|
190 |
($!! $s 16rA7) "/ section-sign |
|
191 |
($O $C 16rA9) "/ copyright |
|
192 |
($< $< 16rAB) "/ french <<-quotes |
|
193 |
($O $R 16rAE) "/ registered |
|
194 |
($/ $u 16rB5) "/ greek mu |
|
195 |
($!! $p 16rB6) "/ paragraph sign |
|
196 |
($> $> 16rBB) "/ french >> quotes |
|
197 |
($^ $0 16rB0) "/ degree sign |
|
198 |
($+ $- 16rB1) "/ plus-minus |
|
199 |
($^ $2 16rB2) "/ superscript-2 |
|
200 |
($^ $3 16rB3) "/ superscript-3 |
|
201 |
"/ ($. $^ 16rB7) "/ middle dot |
|
202 |
($^ $. 16rB7) "/ middle dot |
|
203 |
($^ $1 16rB9) "/ superscript-1 |
|
204 |
($1 $4 16rBC) "/ 1/4 |
|
205 |
($1 $2 16rBD) "/ 1/2 |
|
206 |
($3 $4 16rBE) "/ 3/4 |
|
207 |
($? $? 16rBF) "/ ?-inverted |
|
208 |
($- $: 16rF7) "/ divide |
|
157 | 209 |
|
386 | 210 |
"/ diacriticals: Compose diacrit character |
211 |
"/ grave |
|
157 | 212 |
|
386 | 213 |
($A $` 16rC0) "/ A-` |
214 |
($a $` 16rE0) "/ a-` |
|
215 |
($E $` 16rC8) "/ E-` |
|
216 |
($e $` 16rE8) "/ e-` |
|
217 |
($I $` 16rCC) "/ I-` |
|
218 |
($i $` 16rEC) "/ i-` |
|
219 |
($O $` 16rD2) "/ O-` |
|
220 |
($o $` 16rF2) "/ o-` |
|
221 |
($U $` 16rD9) "/ U-` |
|
222 |
($u $` 16rF9) "/ u-` |
|
157 | 223 |
|
386 | 224 |
"/ acute |
225 |
($A $' 16rC1) "/ A-' |
|
226 |
($a $' 16rE1) "/ a-' |
|
227 |
($E $' 16rC9) "/ E-' |
|
228 |
($e $' 16rE9) "/ e-' |
|
229 |
($I $' 16rCD) "/ I-' |
|
230 |
($i $' 16rED) "/ i-' |
|
231 |
($O $' 16rD3) "/ O-' |
|
232 |
($o $' 16rF3) "/ o-' |
|
233 |
($U $' 16rDA) "/ U-' |
|
234 |
($u $' 16rFA) "/ u-' |
|
235 |
($Y $' 16rDD) "/ Y-' |
|
236 |
($y $' 16rFD) "/ y-' |
|
157 | 237 |
|
386 | 238 |
"/ circumflex |
239 |
($A $^ 16rC2) "/ A-^ |
|
240 |
($a $^ 16rE2) "/ a-^ |
|
241 |
($E $^ 16rCA) "/ E-^ |
|
242 |
($e $^ 16rEA) "/ e-^ |
|
243 |
($I $^ 16rCE) "/ I-^ |
|
244 |
($i $^ 16rEE) "/ i-^ |
|
245 |
($O $^ 16rD4) "/ O-^ |
|
246 |
($o $^ 16rF4) "/ o-^ |
|
247 |
($U $^ 16rDB) "/ U-^ |
|
248 |
($u $^ 16rFB) "/ u-^ |
|
157 | 249 |
|
386 | 250 |
"/ tilde |
251 |
($A $~ 16rC3) "/ A-~ |
|
252 |
($a $~ 16rE3) "/ a-~ |
|
253 |
($O $~ 16rD5) "/ O-~ |
|
254 |
($o $~ 16rF5) "/ o-~ |
|
255 |
($N $~ 16rD1) "/ N-tilde |
|
256 |
($n $~ 16rF1) "/ n-~ |
|
157 | 257 |
|
386 | 258 |
"/ ring above |
259 |
($a $* 16rE5) "/ a-* |
|
260 |
($A $* 16rC5) "/ A-* |
|
157 | 261 |
|
386 | 262 |
"/ cedille |
263 |
($C $, 16rC7) "/ C-, |
|
264 |
($c $, 16rE7) "/ c-, |
|
157 | 265 |
|
386 | 266 |
"/ dieresis |
267 |
($A $" 16rC4) "/ A-" |
|
268 |
($a $" 16rE4) "/ a-" |
|
269 |
($E $" 16rCB) "/ E-" |
|
270 |
($e $" 16rEB) "/ e-" |
|
271 |
($I $" 16rCF) "/ I-" |
|
272 |
($i $" 16rEF) "/ i-" |
|
273 |
($O $" 16rD6) "/ O-" |
|
274 |
($o $" 16rF6) "/ o-" |
|
275 |
($U $" 16rDC) "/ U-" |
|
276 |
($u $" 16rFC) "/ u-" |
|
277 |
($y $" 16rFF) "/ y-" |
|
157 | 278 |
|
386 | 279 |
"/ ligatures |
280 |
($s $s 16rDF) "/ german sz |
|
281 |
($a $e 16rE6) "/ (french) ae |
|
282 |
($A $E 16rC6) "/ (french) AE |
|
283 |
). |
|
284 |
] |
|
157 | 285 |
|
286 |
" |
|
287 |
WindowSensor initialize |
|
288 |
" |
|
140 | 289 |
! ! |
81 | 290 |
|
140 | 291 |
!WindowSensor class methodsFor:'instance creation'! |
292 |
||
293 |
new |
|
294 |
^ self basicNew initialize |
|
124 | 295 |
! ! |
296 |
||
297 |
!WindowSensor class methodsFor:'accessing'! |
|
47 | 298 |
|
244 | 299 |
composeTable |
300 |
"return the compose-key table. |
|
301 |
Entries consist of 3-element arrays each, where |
|
302 |
the first two entries (of each entry) are the raw characters, |
|
303 |
and the third is the resulting composed-key" |
|
304 |
||
305 |
^ ComposeTable |
|
306 |
! |
|
307 |
||
308 |
composeTable:aTable |
|
309 |
"set the compose-key table. |
|
310 |
Entries consist of 3-element arrays each, where |
|
311 |
the first two entries (of each entry) are the raw characters, |
|
312 |
and the third is the resulting composed-key" |
|
313 |
||
314 |
ComposeTable := aTable |
|
315 |
! |
|
316 |
||
144 | 317 |
controlCEnabled:aBoolean |
318 |
"enable/disable Control-C processing. |
|
319 |
If enabled, pressing CNTL-C in a view will interrupt it and bring |
|
72 | 320 |
its process into the debugger (actually raising signal). |
47 | 321 |
Otherwise, CNTL-C is sent to the view like any other key. |
144 | 322 |
The default is true (enabled). |
47 | 323 |
" |
324 |
||
144 | 325 |
ControlCEnabled := aBoolean |
124 | 326 |
! |
327 |
||
328 |
eventListener |
|
329 |
"return the eventListener |
|
330 |
- see documentation for what this can be used for" |
|
331 |
||
332 |
^ EventListener |
|
157 | 333 |
! |
334 |
||
244 | 335 |
eventListener:aListener |
336 |
"set the eventListener |
|
337 |
- see documentation for what this can be used for" |
|
157 | 338 |
|
244 | 339 |
EventListener := aListener |
47 | 340 |
! ! |
341 |
||
133 | 342 |
!WindowSensor class methodsFor:'queries'! |
343 |
||
344 |
cursorPoint |
|
140 | 345 |
"ST-80 compatibility: |
157 | 346 |
return the position of the cursor on the current display" |
133 | 347 |
|
153 | 348 |
^ Screen current pointerPosition |
133 | 349 |
|
350 |
" |
|
351 |
WindowSensor cursorPoint |
|
352 |
" |
|
353 |
! ! |
|
354 |
||
244 | 355 |
!WindowSensor methodsFor:'accessing'! |
356 |
||
357 |
compressMotionEvents:aBoolean |
|
358 |
"turn on/off motion event compression" |
|
359 |
||
360 |
compressMotionEvents := aBoolean |
|
361 |
! |
|
362 |
||
363 |
eventListener |
|
364 |
"return the eventListener |
|
365 |
- see documentation for what this can be used for" |
|
366 |
||
367 |
^ eventListener |
|
368 |
! |
|
369 |
||
370 |
eventListener:aListener |
|
371 |
"set the eventListener |
|
372 |
- see documentation for what this can be used for" |
|
373 |
||
374 |
eventListener := aListener |
|
375 |
||
376 |
! |
|
140 | 377 |
|
244 | 378 |
eventSemaphore |
379 |
"return the semaphore used to signal event arrival" |
|
380 |
||
381 |
^ eventSemaphore |
|
382 |
! |
|
383 |
||
384 |
eventSemaphore:aSemaphore |
|
385 |
"set the semaphore used to signal event arrival" |
|
386 |
||
387 |
eventSemaphore := aSemaphore |
|
388 |
! |
|
389 |
||
390 |
ignoreUserInput |
|
391 |
"return true, if Ctrl-C processing is currently turned off" |
|
392 |
||
393 |
^ ignoreUserInput |
|
394 |
! |
|
395 |
||
396 |
ignoreUserInput:aBoolean |
|
397 |
"turn on/off ignoring of Ctrl-C processing" |
|
398 |
||
399 |
ignoreUserInput := aBoolean |
|
140 | 400 |
! |
401 |
||
244 | 402 |
keyboardListener |
403 |
"return the keyboardListener |
|
404 |
- see documentation for what this can be used for" |
|
405 |
||
406 |
^ keyboardListener |
|
407 |
! |
|
408 |
||
409 |
keyboardListener:aListener |
|
410 |
"set the keyboardListener |
|
411 |
- see documentation for what this can be used for" |
|
412 |
||
413 |
keyboardListener := aListener |
|
414 |
||
415 |
! ! |
|
416 |
||
417 |
!WindowSensor methodsFor:'event flushing'! |
|
144 | 418 |
|
244 | 419 |
compressKeyPressEventsWithKey:aKey |
420 |
"count and remove multiple pending keyPress events for the |
|
421 |
same key, aKey. This is currently used in TextViews to compress |
|
422 |
multiple cursorUp/cursorDown events and do the scroll in one |
|
423 |
operation. (to avoid run-after-cursor on slow displays)" |
|
424 |
||
425 |
|n ev| |
|
426 |
||
427 |
n := 0. |
|
428 |
ev := self pendingEvent. |
|
429 |
[ev notNil and:[ev isKeyPressEvent]] whileTrue:[ |
|
430 |
((ev arguments at:1) == aKey) ifTrue:[ |
|
431 |
n := n + 1. |
|
432 |
self nextEvent. |
|
433 |
ev := self pendingEvent. |
|
434 |
] ifFalse:[ |
|
435 |
ev := nil |
|
436 |
] |
|
144 | 437 |
]. |
244 | 438 |
^ n |
439 |
! |
|
440 |
||
441 |
flushEventsFor:aView |
|
442 |
"throw away all events for aView, |
|
443 |
or any view, if the argument is nil." |
|
444 |
||
445 |
self flushExposeEventsFor:aView. |
|
446 |
self flushUserEventsFor:aView. |
|
447 |
! |
|
448 |
||
449 |
flushExposeEvents |
|
450 |
"throw away all pending expose events; this |
|
451 |
can be done after a full redraw (or in views, which are |
|
452 |
doing full redraws anly)" |
|
453 |
||
454 |
(damage isNil or:[damage size > 0]) ifTrue:[ |
|
455 |
damage := OrderedCollection new |
|
144 | 456 |
]. |
457 |
! |
|
458 |
||
244 | 459 |
flushExposeEventsFor:aView |
460 |
"throw away all pending expose events for aView, |
|
461 |
or any view, if the argument is nil. |
|
462 |
This can be done after a full redraw |
|
463 |
(or in views, which are always doing full redraws - |
|
464 |
instead of drawing the clip-area only)" |
|
465 |
||
466 |
|nEvent "{ Class: SmallInteger }"| |
|
157 | 467 |
|
244 | 468 |
damage notNil ifTrue:[ |
469 |
nEvent := damage size. |
|
470 |
1 to:nEvent do:[:index | |
|
471 |
|aDamage| |
|
157 | 472 |
|
244 | 473 |
aDamage := damage at:index. |
474 |
aDamage notNil ifTrue:[ |
|
475 |
(aView isNil or:[aDamage view == aView]) ifTrue:[ |
|
476 |
damage at:index put:nil |
|
477 |
] |
|
478 |
] |
|
157 | 479 |
] |
480 |
]. |
|
244 | 481 |
! |
482 |
||
483 |
flushKeyboard |
|
484 |
"ST-80 compatibility: throw away all pending keyboard events" |
|
485 |
||
486 |
self flushKeyboardFor:nil |
|
487 |
! |
|
488 |
||
489 |
flushKeyboardFor:aView |
|
490 |
"throw away all pending keyboard events for aView, |
|
491 |
or any view, if the argument is nil." |
|
492 |
||
493 |
|nEvent "{ Class: SmallInteger }"| |
|
494 |
||
495 |
mouseAndKeyboard notNil ifTrue:[ |
|
496 |
nEvent := mouseAndKeyboard size. |
|
497 |
1 to:nEvent do:[:i | |
|
498 |
|anEvent| |
|
499 |
||
500 |
anEvent := mouseAndKeyboard at:i. |
|
501 |
(anEvent notNil and:[anEvent isKeyEvent]) ifTrue:[ |
|
502 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
503 |
mouseAndKeyboard at:i put:nil |
|
504 |
] |
|
505 |
] |
|
506 |
] |
|
507 |
]. |
|
508 |
! |
|
509 |
||
510 |
flushUserEvents |
|
511 |
"throw away all pending user events" |
|
512 |
||
513 |
(mouseAndKeyboard isNil or:[mouseAndKeyboard size > 0]) ifTrue:[ |
|
514 |
mouseAndKeyboard := OrderedCollection new |
|
515 |
]. |
|
516 |
! |
|
517 |
||
518 |
flushUserEventsFor:aView |
|
519 |
"throw away all pending user events for aView, |
|
520 |
or any view, if the argument is nil." |
|
521 |
||
522 |
|nEvent "{ Class: SmallInteger }"| |
|
523 |
||
524 |
mouseAndKeyboard notNil ifTrue:[ |
|
525 |
nEvent := mouseAndKeyboard size. |
|
526 |
1 to:nEvent do:[:i | |
|
527 |
|anEvent| |
|
528 |
||
529 |
anEvent := mouseAndKeyboard at:i. |
|
530 |
anEvent notNil ifTrue:[ |
|
531 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
532 |
mouseAndKeyboard at:i put:nil |
|
533 |
] |
|
534 |
] |
|
535 |
] |
|
536 |
]. |
|
157 | 537 |
! ! |
538 |
||
539 |
!WindowSensor methodsFor:'event processing'! |
|
540 |
||
541 |
button:button inView:aView state:onOrOff |
|
542 |
"update the state of the xxxButtonDown flags" |
|
543 |
||
544 |
|physicalButton| |
|
545 |
||
546 |
physicalButton := aView device buttonTranslation keyAtValue:button ifAbsent:button. |
|
547 |
(physicalButton == 1) ifTrue:[ |
|
548 |
leftButtonDown := onOrOff. |
|
549 |
^ self |
|
550 |
]. |
|
551 |
(physicalButton == 2) ifTrue:[ |
|
552 |
middleButtonDown := onOrOff. |
|
553 |
^ self |
|
554 |
]. |
|
555 |
(physicalButton == 3) ifTrue:[ |
|
556 |
rightButtonDown := onOrOff. |
|
557 |
^ self |
|
558 |
]. |
|
559 |
! |
|
560 |
||
140 | 561 |
buttonMotion:state x:x y:y view:aView |
562 |
"mouse was moved - this is sent from the device (Display)" |
|
563 |
||
564 |
|args| |
|
565 |
||
566 |
EventListener notNil ifTrue:[ |
|
567 |
(EventListener buttonMotion:state x:x y:y view:aView) ifTrue:[^ self] |
|
568 |
]. |
|
569 |
eventListener notNil ifTrue:[ |
|
570 |
(eventListener buttonMotion:state x:x y:y view:aView) ifTrue:[^ self] |
|
571 |
]. |
|
572 |
||
573 |
ignoreUserInput == true ifTrue:[ |
|
574 |
^ self |
|
575 |
]. |
|
576 |
args := Array with:state with:x with:y. |
|
577 |
||
578 |
compressMotionEvents ifTrue:[ |
|
579 |
" |
|
580 |
merge with last motion |
|
581 |
" |
|
582 |
mouseAndKeyboard reverseDo:[:ev | |
|
583 |
ev notNil ifTrue:[ |
|
584 |
((ev type == #buttonMotion:x:y:) |
|
585 |
and:[(ev view == aView) |
|
586 |
and:[(ev arguments at:1) == state]]) ifTrue:[ |
|
587 |
ev arguments:args. |
|
588 |
^ self |
|
589 |
] |
|
590 |
] |
|
591 |
] |
|
592 |
]. |
|
593 |
mouseAndKeyboard |
|
594 |
addLast:(WindowEvent |
|
595 |
for:aView |
|
596 |
type:#buttonMotion:x:y: |
|
597 |
arguments:args). |
|
598 |
self notifyEventArrival |
|
599 |
! |
|
600 |
||
244 | 601 |
buttonMultiPress:button x:x y:y view:aView |
602 |
"mouse button was pressed - this is sent from the device (Display)" |
|
140 | 603 |
|
604 |
EventListener notNil ifTrue:[ |
|
244 | 605 |
(EventListener buttonMultiPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 606 |
]. |
607 |
eventListener notNil ifTrue:[ |
|
244 | 608 |
(eventListener buttonMultiPress:button x:x y:y view:aView) ifTrue:[^ self] |
140 | 609 |
]. |
610 |
||
611 |
ignoreUserInput == true ifTrue:[ |
|
612 |
^ self |
|
613 |
]. |
|
614 |
mouseAndKeyboard |
|
244 | 615 |
addLast:(WindowEvent |
616 |
for:aView |
|
617 |
type:#buttonMultiPress:x:y: |
|
618 |
arguments:(Array with:button with:x with:y)). |
|
140 | 619 |
self notifyEventArrival |
620 |
! |
|
621 |
||
622 |
buttonPress:button x:x y:y view:aView |
|
623 |
"mouse button was pressed - this is sent from the device (Display)" |
|
624 |
||
157 | 625 |
self button:button inView:aView state:true. |
626 |
||
140 | 627 |
EventListener notNil ifTrue:[ |
628 |
(EventListener buttonPress:button x:x y:y view:aView) ifTrue:[^ self] |
|
629 |
]. |
|
630 |
eventListener notNil ifTrue:[ |
|
631 |
(eventListener buttonPress:button x:x y:y view:aView) ifTrue:[^ self] |
|
632 |
]. |
|
633 |
||
634 |
ignoreUserInput == true ifTrue:[ |
|
635 |
^ self |
|
636 |
]. |
|
637 |
mouseAndKeyboard |
|
638 |
addLast:(WindowEvent |
|
639 |
for:aView |
|
640 |
type:#buttonPress:x:y: |
|
641 |
arguments:(Array with:button with:x with:y)). |
|
642 |
self notifyEventArrival |
|
643 |
! |
|
644 |
||
244 | 645 |
buttonRelease:button x:x y:y view:aView |
646 |
"mouse button was released- this is sent from the device (Display)" |
|
647 |
||
648 |
self button:button inView:aView state:false. |
|
649 |
||
650 |
EventListener notNil ifTrue:[ |
|
651 |
(EventListener buttonRelease:button x:x y:y view:aView) ifTrue:[^ self] |
|
652 |
]. |
|
653 |
eventListener notNil ifTrue:[ |
|
654 |
(eventListener buttonRelease:button x:x y:y view:aView) ifTrue:[^ self] |
|
655 |
]. |
|
656 |
||
657 |
ignoreUserInput == true ifTrue:[ |
|
658 |
^ self |
|
659 |
]. |
|
660 |
mouseAndKeyboard |
|
661 |
addLast:(WindowEvent |
|
662 |
for:aView |
|
663 |
type:#buttonRelease:x:y: |
|
664 |
arguments:(Array with:button with:x with:y)). |
|
665 |
self notifyEventArrival |
|
666 |
! |
|
667 |
||
668 |
buttonShiftPress:button x:x y:y view:aView |
|
669 |
"mouse button was pressed - this is sent from the device (Display)" |
|
670 |
||
671 |
self button:button inView:aView state:true. |
|
672 |
||
673 |
EventListener notNil ifTrue:[ |
|
674 |
(EventListener buttonShiftPress:button x:x y:y view:aView) ifTrue:[^ self] |
|
675 |
]. |
|
676 |
eventListener notNil ifTrue:[ |
|
677 |
(eventListener buttonShiftPress:button x:x y:y view:aView) ifTrue:[^ self] |
|
678 |
]. |
|
140 | 679 |
|
244 | 680 |
ignoreUserInput == true ifTrue:[ |
681 |
^ self |
|
682 |
]. |
|
683 |
mouseAndKeyboard |
|
684 |
addLast:(WindowEvent |
|
685 |
for:aView |
|
686 |
type:#buttonShiftPress:x:y: |
|
687 |
arguments:(Array with:button with:x with:y)). |
|
688 |
self notifyEventArrival |
|
689 |
! |
|
690 |
||
691 |
configureX:x y:y width:w height:h view:aView |
|
692 |
"a views size or position has changed - this is sent from the device (Display)" |
|
693 |
||
694 |
damage |
|
695 |
addLast:(WindowEvent |
|
696 |
for:aView |
|
697 |
type:#configureX:y:width:height: |
|
698 |
arguments:(Array with:x with:y with:w with:h)). |
|
699 |
self notifyEventArrival |
|
700 |
! |
|
701 |
||
702 |
coveredBy:sibling view:aView |
|
703 |
"aView was covered by one of its siblings - this is sent from the device (Display)" |
|
704 |
||
705 |
damage |
|
706 |
addLast:(WindowEvent |
|
707 |
for:aView |
|
708 |
type:#coveredBy: |
|
709 |
arguments:(Array with:sibling)). |
|
710 |
self notifyEventArrival |
|
711 |
! |
|
712 |
||
713 |
destroyedView:aView |
|
714 |
"view was destroyed (from window manager) - this is sent from the device (Display)" |
|
715 |
||
716 |
"at this time, the view is already gone; remove |
|
717 |
all pending events for this one ..." |
|
718 |
||
719 |
self flushEventsFor:aView. |
|
720 |
damage |
|
721 |
addLast:(WindowEvent |
|
722 |
for:aView |
|
723 |
type:#destroyed). |
|
724 |
self notifyEventArrival |
|
725 |
! |
|
726 |
||
727 |
exposeX:left y:top width:width height:height view:aView |
|
728 |
"an expose event arrived - this is sent from the device (Display)" |
|
729 |
||
730 |
(self addDamage:(Rectangle left:left top:top width:width height:height) view:aView) ifTrue:[ |
|
731 |
self notifyEventArrival |
|
732 |
] |
|
140 | 733 |
! |
734 |
||
735 |
focusInView:aView |
|
736 |
"view got input focus - this is sent from the device (Display)" |
|
737 |
||
738 |
mouseAndKeyboard |
|
739 |
addLast:(WindowEvent |
|
740 |
for:aView |
|
741 |
type:#focusIn). |
|
742 |
self notifyEventArrival |
|
743 |
! |
|
744 |
||
244 | 745 |
focusOutView:aView |
746 |
"view lost input focus - this is sent from the device (Display)" |
|
140 | 747 |
|
748 |
mouseAndKeyboard |
|
244 | 749 |
addLast:(WindowEvent |
750 |
for:aView |
|
751 |
type:#focusOut). |
|
140 | 752 |
self notifyEventArrival |
753 |
! |
|
754 |
||
244 | 755 |
graphicExposeX:left y:top width:width height:height view:aView |
756 |
"a graphic expose event arrived - this is sent from the device (Display)" |
|
140 | 757 |
|
244 | 758 |
self addDamage:(left @ top extent:width @ height) view:aView. |
140 | 759 |
! |
760 |
||
761 |
keyPress:key x:x y:y view:aView |
|
762 |
"key was pressed - this is sent from the device (Display). |
|
763 |
beside the keyboard translation, CntlC processing is done here." |
|
764 |
||
510 | 765 |
<resource: #keyboard ( #Compose #DestroyView #DestroyTopView #FlushInput |
766 |
#UserInterrupt ) > |
|
767 |
||
140 | 768 |
|xlatedKey group process| |
769 |
||
144 | 770 |
self key:key state:true. |
771 |
||
140 | 772 |
EventListener notNil ifTrue:[ |
510 | 773 |
(EventListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 774 |
]. |
775 |
eventListener notNil ifTrue:[ |
|
510 | 776 |
(eventListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 777 |
]. |
778 |
keyboardListener notNil ifTrue:[ |
|
510 | 779 |
(keyboardListener keyPress:key x:x y:y view:aView) ifTrue:[^ self] |
140 | 780 |
]. |
781 |
||
782 |
translateKeyboardEvents ifTrue:[ |
|
510 | 783 |
xlatedKey := aView device translateKey:key. |
140 | 784 |
] ifFalse:[ |
510 | 785 |
xlatedKey := key. |
140 | 786 |
]. |
157 | 787 |
|
140 | 788 |
xlatedKey isNil ifTrue:[^ self]. |
789 |
||
157 | 790 |
(xlatedKey == #Compose) ifTrue:[ |
510 | 791 |
GotCompose := true. Compose1 := nil. |
792 |
^ self |
|
157 | 793 |
]. |
794 |
GotCompose == true ifTrue:[ |
|
510 | 795 |
Compose1 isNil ifTrue:[ |
796 |
(self isModifierKey:xlatedKey) ifFalse:[ |
|
797 |
Compose1 := xlatedKey. |
|
798 |
]. |
|
799 |
^ self |
|
800 |
]. |
|
801 |
(self isModifierKey:xlatedKey) ifFalse:[ |
|
802 |
xlatedKey := self compose:Compose1 with:xlatedKey. |
|
803 |
Compose1 := nil. GotCompose := false. |
|
804 |
] |
|
157 | 805 |
]. |
806 |
||
807 |
(xlatedKey == #CmdCtrlV) ifTrue:[ |
|
510 | 808 |
'Smalltalk/X ' errorPrint. |
809 |
Smalltalk versionString errorPrint. ' of ' errorPrint. |
|
810 |
Smalltalk versionDate errorPrintNL. |
|
811 |
Smalltalk copyrightString errorPrintNL. |
|
140 | 812 |
]. |
813 |
||
157 | 814 |
(xlatedKey == #DestroyView) ifTrue:[ |
510 | 815 |
aView closeRequest. |
157 | 816 |
]. |
817 |
(xlatedKey == #DestroyTopView) ifTrue:[ |
|
510 | 818 |
aView topView closeRequest. |
157 | 819 |
]. |
820 |
||
152 | 821 |
(xlatedKey == #FlushInput) ifTrue:[ |
510 | 822 |
"this removes any enqueued user events - |
823 |
helps, if you pressed DoIt too often, and want to flush those |
|
824 |
" |
|
825 |
self flushUserEvents. |
|
826 |
^ self |
|
152 | 827 |
]. |
828 |
||
140 | 829 |
((xlatedKey == #UserInterrupt) and:[ControlCEnabled]) ifTrue:[ |
510 | 830 |
" |
831 |
Special handling for Ctrl-C: interrupt the underlying process. |
|
140 | 832 |
|
510 | 833 |
cannot halt here (this would stop the event-dispatcher), |
834 |
but instead interrupt the underlying process and have it |
|
835 |
perform the userInterrupt in the interrupt-method. |
|
836 |
" |
|
837 |
group := aView windowGroup. |
|
838 |
group notNil ifTrue:[ |
|
839 |
process := group process. |
|
840 |
process notNil ifTrue:[ |
|
841 |
process interruptWith:[process userInterrupt] |
|
842 |
] |
|
843 |
]. |
|
844 |
^ self |
|
140 | 845 |
]. |
846 |
||
847 |
ignoreUserInput == true ifTrue:[ |
|
510 | 848 |
^ self |
140 | 849 |
]. |
850 |
mouseAndKeyboard |
|
510 | 851 |
addLast:(WindowEvent |
852 |
for:aView |
|
853 |
type:#keyPress:x:y: |
|
854 |
arguments:(Array with:xlatedKey with:x with:y)). |
|
140 | 855 |
self notifyEventArrival |
510 | 856 |
|
857 |
"Modified: 7.3.1996 / 13:20:25 / cg" |
|
140 | 858 |
! |
859 |
||
860 |
keyRelease:key x:x y:y view:aView |
|
861 |
"key was released - this is sent from the device (Display)." |
|
862 |
||
863 |
|xlatedKey| |
|
864 |
||
144 | 865 |
self key:key state:false. |
866 |
||
140 | 867 |
EventListener notNil ifTrue:[ |
868 |
(EventListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
|
869 |
]. |
|
870 |
eventListener notNil ifTrue:[ |
|
871 |
(eventListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
|
872 |
]. |
|
873 |
keyboardListener notNil ifTrue:[ |
|
874 |
(keyboardListener keyRelease:key x:x y:y view:aView) ifTrue:[^ self] |
|
875 |
]. |
|
876 |
||
877 |
ignoreUserInput == true ifTrue:[ |
|
878 |
^ self |
|
879 |
]. |
|
880 |
translateKeyboardEvents ifTrue:[ |
|
881 |
xlatedKey := aView device translateKey:key. |
|
882 |
] ifFalse:[ |
|
883 |
xlatedKey := key. |
|
884 |
]. |
|
885 |
xlatedKey isNil ifTrue:[^ self]. |
|
886 |
||
887 |
mouseAndKeyboard |
|
888 |
addLast:(WindowEvent |
|
889 |
for:aView |
|
890 |
type:#keyRelease:x:y: |
|
891 |
arguments:(Array with:xlatedKey with:x with:y)). |
|
892 |
self notifyEventArrival |
|
893 |
! |
|
894 |
||
244 | 895 |
mappedView:aView |
896 |
"view was mapped (from window manager) - this is sent from the device (Display)" |
|
140 | 897 |
|
898 |
damage |
|
899 |
addLast:(WindowEvent |
|
900 |
for:aView |
|
244 | 901 |
type:#mapped). |
902 |
self notifyEventArrival |
|
903 |
! |
|
904 |
||
905 |
noExposeView:aView |
|
906 |
"an noexpose event arrived - this is sent from the device (Display)" |
|
907 |
||
908 |
gotExpose := true. |
|
909 |
exposeEventSemaphore notNil ifTrue:[ |
|
910 |
exposeEventSemaphore signal |
|
911 |
] |
|
912 |
! |
|
913 |
||
914 |
notifyEventArrival |
|
915 |
"an event arrived - if there is an eventSemaphore, |
|
916 |
signal it, to wake up any windowGroup process" |
|
917 |
||
918 |
catchExpose == true ifTrue:[ |
|
919 |
" |
|
920 |
dont wake up, if we are currently waiting for an expose |
|
921 |
but remember arrival of something. |
|
922 |
" |
|
923 |
gotOtherEvent := true. |
|
924 |
^ self |
|
925 |
]. |
|
926 |
eventSemaphore notNil ifTrue:[ |
|
927 |
eventSemaphore signal |
|
928 |
] |
|
929 |
! |
|
930 |
||
931 |
pointerEnter:state x:x y:y view:aView |
|
932 |
"mouse cursor was moved into the view - this is sent from the device (Display)" |
|
933 |
||
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
|
934 |
"/ update my idea of shift/alt/ctrl pressed information |
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
|
935 |
|
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
|
936 |
self updateModifierStateFrom:state device:(aView device). |
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
|
937 |
|
244 | 938 |
EventListener notNil ifTrue:[ |
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
|
939 |
(EventListener pointerEnter:state x:x y:y view:aView) ifTrue:[^ self] |
244 | 940 |
]. |
941 |
eventListener notNil ifTrue:[ |
|
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
|
942 |
(eventListener pointerEnter:state x:x y:y view:aView) ifTrue:[^ self] |
244 | 943 |
]. |
944 |
||
945 |
mouseAndKeyboard |
|
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
|
946 |
addLast:(WindowEvent |
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
|
947 |
for:aView |
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
|
948 |
type:#pointerEnter:x:y: |
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
|
949 |
arguments:(Array with:state with:x with:y)). |
244 | 950 |
self notifyEventArrival |
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
|
951 |
|
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
|
952 |
"Modified: 27.2.1996 / 14:54:47 / cg" |
244 | 953 |
! |
954 |
||
955 |
pointerLeave:state view:aView |
|
956 |
"mouse cursor was moved out of the view - this is sent from the device (Display)" |
|
957 |
||
958 |
EventListener notNil ifTrue:[ |
|
959 |
(EventListener pointerLeave:state view:aView) ifTrue:[^ self] |
|
960 |
]. |
|
961 |
eventListener notNil ifTrue:[ |
|
962 |
(eventListener pointerLeave:state view:aView) ifTrue:[^ self] |
|
963 |
]. |
|
964 |
||
965 |
mouseAndKeyboard |
|
966 |
addLast:(WindowEvent |
|
967 |
for:aView |
|
968 |
type:#pointerLeave: |
|
969 |
arguments:(Array with:state)). |
|
140 | 970 |
self notifyEventArrival |
971 |
! |
|
972 |
||
973 |
saveAndTerminateView:aView |
|
974 |
"view should save & terminate (from window manager) - this is sent from the device (Display)" |
|
975 |
||
976 |
self flushEventsFor:aView. |
|
977 |
damage |
|
978 |
addLast:(WindowEvent |
|
979 |
for:aView |
|
980 |
type:#saveAndTerminate). |
|
981 |
self notifyEventArrival |
|
982 |
! |
|
983 |
||
244 | 984 |
terminateView:aView |
985 |
"view should terminate (from window manager) - this is sent from the device (Display)" |
|
140 | 986 |
|
987 |
self flushEventsFor:aView. |
|
988 |
damage |
|
989 |
addLast:(WindowEvent |
|
990 |
for:aView |
|
244 | 991 |
type:#terminate). |
992 |
self notifyEventArrival |
|
993 |
! |
|
994 |
||
995 |
unmappedView:aView |
|
996 |
"view was unmapped (from window manager) - this is sent from the device (Display)" |
|
997 |
||
998 |
damage |
|
999 |
addLast:(WindowEvent |
|
1000 |
for:aView |
|
1001 |
type:#unmapped). |
|
140 | 1002 |
self notifyEventArrival |
0 | 1003 |
! ! |
1004 |
||
140 | 1005 |
!WindowSensor methodsFor:'event queue'! |
1006 |
||
144 | 1007 |
addDamage:aRectangle view:aView |
0 | 1008 |
"Add aRectangle to the damage list. |
144 | 1009 |
Try to merge incoming rectangles with the existing damage rectangles. |
1010 |
Incoming rectangles which are completely contained in any existing damage rect are ignored, |
|
1011 |
any existing damage rectangle which is completely contained in the incoming rectangle |
|
152 | 1012 |
is replaced. Also, rectangles are merged into bigger ones, if they join exactly. |
144 | 1013 |
Except for special cases (moveOpaque of a view over one of my views), |
1014 |
these optimizations are not noticable." |
|
0 | 1015 |
|
154 | 1016 |
|temp index newEvent r rL rT rB rR |
152 | 1017 |
count "{ Class: SmallInteger }" |
1018 |
sz "{ Class: SmallInteger }" |
|
322 | 1019 |
firstInteresting "{ Class: SmallInteger }" |
1020 |
lastInteresting "{ Class: SmallInteger }"| |
|
0 | 1021 |
|
152 | 1022 |
r := aRectangle. |
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1023 |
aView redrawsFull ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1024 |
r := 0@0 corner:9999@9999 |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1025 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1026 |
|
54 | 1027 |
sz := damage size. |
1028 |
sz == 0 ifTrue: [ |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1029 |
damage := OrderedCollection new:10. |
152 | 1030 |
] ifFalse:[ |
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1031 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1032 |
first look, if this rectangle is already in the expose list; |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1033 |
if so, dont add to queue |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1034 |
On the fly, count the number of damages for this view |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1035 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1036 |
count := firstInteresting := 0. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1037 |
1 to:sz do:[:i | |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1038 |
|aDamage| |
152 | 1039 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1040 |
aDamage := damage at:i. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1041 |
aDamage notNil ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1042 |
aDamage isDamage ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1043 |
aDamage view == aView ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1044 |
((aDamage rectangle) contains:r) ifTrue: [^ false]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1045 |
count := count + 1. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1046 |
lastInteresting := i. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1047 |
firstInteresting == 0 ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1048 |
firstInteresting := i |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1049 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1050 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1051 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1052 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1053 |
]. |
152 | 1054 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1055 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1056 |
are there any damages for this view in the queue ? |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1057 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1058 |
firstInteresting ~~ 0 ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1059 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1060 |
if there are already many damages for this view, |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1061 |
remove them all, and replace by a full expose |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1062 |
This limits the runtime spent here, which may become big |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1063 |
due to the square runtime behavior (stupid algorithm ...) |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1064 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1065 |
count > 20 ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1066 |
r := 0@0 corner:99999@99999. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1067 |
]. |
152 | 1068 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1069 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1070 |
then look, if the new rectangle contains any in the expose list; |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1071 |
if so, remove the old damage (here, by nilling it in the queue). |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1072 |
Or, merge it with existing rectangles if possible. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1073 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1074 |
count := 0. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1075 |
rR := r right. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1076 |
rL := r left. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1077 |
rT := r top. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1078 |
rB := r bottom. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1079 |
firstInteresting to:lastInteresting do:[:i | |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1080 |
|aDamage dRect dL dR dT dB| |
46 | 1081 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1082 |
aDamage := damage at:i. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1083 |
aDamage notNil ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1084 |
aDamage isDamage ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1085 |
(aDamage view) == aView ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1086 |
dRect := aDamage rectangle. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1087 |
(r contains:dRect) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1088 |
damage at:i put:nil. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1089 |
count := count + 1 |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1090 |
] ifFalse:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1091 |
dL := dRect left. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1092 |
dT := dRect top. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1093 |
dR := dRect right. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1094 |
dB := dRect bottom. |
152 | 1095 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1096 |
(rT == dT |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1097 |
and:[rB == dB]) ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1098 |
(rR > dR) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1099 |
(rL <= (dR + 1)) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1100 |
dRect right:rR. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1101 |
^ false |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1102 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1103 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1104 |
(rL < dL) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1105 |
(rR >= (dL - 1)) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1106 |
dRect left:rL. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1107 |
^ false |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1108 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1109 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1110 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1111 |
(rR == dR |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1112 |
and:[rL == dL]) ifTrue:[ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1113 |
(rB > dB) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1114 |
(rT <= (dB + 1)) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1115 |
dRect bottom:rB. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1116 |
^ false |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1117 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1118 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1119 |
(rT < dT) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1120 |
(rB >= (dT - 1)) ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1121 |
dRect top:rT. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1122 |
^ false |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1123 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1124 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1125 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1126 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1127 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1128 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1129 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1130 |
]. |
152 | 1131 |
|
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1132 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1133 |
if we nilled more then 10 events, reorganize the queue |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1134 |
(doing this for every 10 removes only avoids excessive |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1135 |
reorganization of the input queue) |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1136 |
" |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1137 |
count > 10 ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1138 |
temp := OrderedCollection new:(sz - count + 1). |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1139 |
index := 1. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1140 |
damage do:[:aDamage | |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1141 |
aDamage notNil ifTrue: [ |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1142 |
temp add:aDamage. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1143 |
] |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1144 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1145 |
damage := temp |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1146 |
]. |
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1147 |
]. |
46 | 1148 |
]. |
1149 |
||
152 | 1150 |
newEvent := WindowEvent damageFor:aView rectangle:r. |
46 | 1151 |
damage add:newEvent. |
144 | 1152 |
^ true |
488
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1153 |
|
97f384f5e2aa
views which always redraw full may say so in #redrawsFull
Claus Gittinger <cg@exept.de>
parents:
476
diff
changeset
|
1154 |
"Modified: 4.3.1996 / 16:44:23 / cg" |
0 | 1155 |
! |
1156 |
||
428 | 1157 |
damage |
1158 |
"retrieve the next damage rectangle or nil, if there is none. |
|
1159 |
Remove it from the queue." |
|
1160 |
||
1161 |
^ damage. |
|
1162 |
! |
|
1163 |
||
244 | 1164 |
nextDamage |
1165 |
"retrieve the next damage rectangle or nil, if there is none. |
|
1166 |
Remove it from the queue." |
|
1167 |
||
1168 |
|d wasBlocked| |
|
1169 |
||
1170 |
[d isNil] whileTrue:[ |
|
476 | 1171 |
damage size == 0 ifTrue:[^ nil]. |
1172 |
" |
|
1173 |
be careful: events are inserted at higher prio ... |
|
1174 |
" |
|
1175 |
[ |
|
1176 |
d := damage removeFirst. |
|
1177 |
] valueUninterruptably |
|
244 | 1178 |
]. |
1179 |
^ d |
|
476 | 1180 |
|
1181 |
"Modified: 28.2.1996 / 21:28:59 / cg" |
|
244 | 1182 |
! |
1183 |
||
1184 |
nextEvent |
|
1185 |
"retrieve the next event or nil, if there is none. |
|
1186 |
Remove it from the queue." |
|
1187 |
||
1188 |
|e wasBlocked| |
|
1189 |
||
1190 |
[e isNil] whileTrue:[ |
|
476 | 1191 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
1192 |
" |
|
1193 |
be careful: events are inserted at higher prio ... |
|
1194 |
" |
|
1195 |
[ |
|
1196 |
e := mouseAndKeyboard removeFirst. |
|
1197 |
] valueUninterruptably |
|
244 | 1198 |
]. |
1199 |
^ e |
|
476 | 1200 |
|
1201 |
"Modified: 28.2.1996 / 21:28:37 / cg" |
|
244 | 1202 |
! |
1203 |
||
140 | 1204 |
pendingEvent |
152 | 1205 |
"retrieve the next pending user (i.e. non-damage) event. |
1206 |
Return nil, if there is none pending. |
|
140 | 1207 |
Do not remove it from the queue." |
47 | 1208 |
|
140 | 1209 |
|e wasBlocked| |
47 | 1210 |
|
1211 |
[e isNil] whileTrue:[ |
|
476 | 1212 |
mouseAndKeyboard size == 0 ifTrue:[^ nil]. |
1213 |
||
1214 |
" |
|
1215 |
be careful: events are inserted at higher prio ... |
|
1216 |
" |
|
1217 |
[ |
|
1218 |
e := mouseAndKeyboard first. |
|
1219 |
e isNil ifTrue:[ |
|
1220 |
mouseAndKeyboard removeFirst |
|
1221 |
]. |
|
1222 |
] valueUninterruptably |
|
0 | 1223 |
]. |
47 | 1224 |
^ e |
476 | 1225 |
|
1226 |
"Modified: 28.2.1996 / 21:28:45 / cg" |
|
0 | 1227 |
! ! |
1228 |
||
244 | 1229 |
!WindowSensor methodsFor:'event simulation'! |
1230 |
||
1231 |
forwardKeyEventsTo:aView |
|
1232 |
"remove all keyboard events and send them to aViews sensor instead" |
|
1233 |
||
1234 |
"/ 'fwd' printNL. |
|
1235 |
1 to:mouseAndKeyboard size do:[:i | |
|
1236 |
|anEvent| |
|
1237 |
||
1238 |
anEvent := mouseAndKeyboard at:i. |
|
1239 |
anEvent notNil ifTrue:[ |
|
1240 |
anEvent isKeyEvent ifTrue:[ |
|
1241 |
anEvent view:aView. |
|
1242 |
aView sensor pushEvent:anEvent. |
|
1243 |
"/ anEvent type printNL. |
|
1244 |
mouseAndKeyboard at:i put:nil |
|
1245 |
] |
|
1246 |
] |
|
1247 |
]. |
|
1248 |
! |
|
1249 |
||
1250 |
pushEvent:anEvent |
|
1251 |
"manually put an event into the queue - this allows |
|
1252 |
simulation of events (implementation of recorders & playback) |
|
1253 |
or asynchronous communication between view applications." |
|
1254 |
||
1255 |
mouseAndKeyboard addLast:anEvent. |
|
1256 |
self notifyEventArrival |
|
1257 |
||
1258 |
"Created: 18.9.1995 / 22:37:57 / claus" |
|
1259 |
! |
|
1260 |
||
1261 |
pushUserEvent:aSelector for:aView |
|
1262 |
"manually put an event into the queue - this allows |
|
1263 |
simulation of events (implementation of recorders & playback) |
|
1264 |
or asynchronous communication between view applications. |
|
1265 |
The view will perform a method as specified by aSelector, |
|
1266 |
when it performs event processing; this is different than sending |
|
1267 |
this message directly, since the execution is done by the views process, |
|
1268 |
not by the current process (which is especially worthwhile, if that method |
|
1269 |
shows a modal box or similar)." |
|
1270 |
||
1271 |
self pushUserEvent:aSelector for:aView withArguments:#() |
|
1272 |
||
1273 |
"Modified: 18.9.1995 / 22:40:12 / claus" |
|
1274 |
! |
|
1275 |
||
1276 |
pushUserEvent:aSelector for:aView withArguments:arguments |
|
1277 |
"manually put an event into the queue - this allows |
|
1278 |
simulation of events (implementation of recorders & playback) |
|
1279 |
or asynchronous communication between view applications. |
|
1280 |
The view will perform a method as specified by aSelector, |
|
1281 |
when it performs event processing; this is different than sending |
|
1282 |
this message directly, since the execution is done by the views process, |
|
1283 |
not by the current process (which is especially worthwhile, if that method |
|
1284 |
shows a modal box or similar)." |
|
1285 |
||
1286 |
self pushEvent:(WindowEvent |
|
1287 |
for:aView |
|
1288 |
type:aSelector |
|
1289 |
arguments:arguments). |
|
1290 |
||
1291 |
" |
|
1292 |
|b| |
|
1293 |
b := Button label:'test'. |
|
1294 |
b open. |
|
1295 |
(Delay forSeconds:5) wait. |
|
1296 |
b sensor pushEvent:#pointerEnter:x:y: for:b withArguments:#(0 1 1). |
|
1297 |
(Delay forSeconds:1) wait. |
|
1298 |
b sensor pushEvent:#buttonPress:x:y: for:b withArguments:#(1 1 1). |
|
1299 |
(Delay forSeconds:2) wait. |
|
1300 |
b sensor pushEvent:#buttonRelease:x:y: for:b withArguments:#(1 1 1). |
|
1301 |
(Delay forSeconds:1) wait. |
|
1302 |
b sensor pushEvent:#pointerLeave: for:b withArguments:#(0). |
|
1303 |
" |
|
1304 |
! ! |
|
1305 |
||
1306 |
!WindowSensor methodsFor:'initialization'! |
|
1307 |
||
1308 |
initialize |
|
1309 |
"initialize the event queues to empty" |
|
1310 |
||
1311 |
damage := OrderedCollection new. |
|
1312 |
mouseAndKeyboard := OrderedCollection new. |
|
1313 |
gotExpose := true. |
|
1314 |
catchExpose := false. |
|
1315 |
||
1316 |
compressMotionEvents := translateKeyboardEvents := true. |
|
1317 |
ignoreUserInput := false. |
|
1318 |
shiftDown := ctrlDown := altDown := metaDown := false. |
|
1319 |
leftButtonDown := middleButtonDown := rightButtonDown := false. |
|
1320 |
! |
|
1321 |
||
1322 |
reinitialize |
|
1323 |
"called when an image is restarted; |
|
1324 |
reinitialize the event queues to empty; leave other setup as-is" |
|
1325 |
||
1326 |
self flushUserEvents. |
|
1327 |
self flushExposeEvents. |
|
1328 |
gotExpose := true. |
|
1329 |
catchExpose := false. |
|
1330 |
shiftDown := ctrlDown := altDown := metaDown := false. |
|
1331 |
leftButtonDown := middleButtonDown := rightButtonDown := false. |
|
1332 |
! ! |
|
1333 |
||
1334 |
!WindowSensor methodsFor:'private'! |
|
1335 |
||
1336 |
compose:key1 with:key2 |
|
1337 |
"compose a 2-character sequence into a composed key" |
|
1338 |
||
1339 |
ComposeTable do:[:entry | |
|
1340 |
|v| |
|
1341 |
||
1342 |
((key1 == (entry at:1)) and:[key2 == (entry at:2)]) ifTrue:[ |
|
1343 |
v := entry at:3. |
|
1344 |
v isCharacter ifFalse:[v := Character value:v]. |
|
1345 |
^ v |
|
1346 |
] |
|
1347 |
]. |
|
1348 |
"/ |
|
1349 |
"/ for illegal sequence, return 2nd key |
|
1350 |
"/ |
|
1351 |
"/ key1 print. ' ' print. key2 printNL. |
|
1352 |
^ key2 |
|
1353 |
! |
|
1354 |
||
1355 |
isModifierKey:key |
|
1356 |
(key == #Shift |
|
1357 |
or:[key == #'Shift_R' |
|
1358 |
or:[key == #'Shift_L']]) ifTrue:[ |
|
1359 |
^ true |
|
1360 |
]. |
|
1361 |
(key == #Alt |
|
1362 |
or:[key == #'Alt_R' or:[key == #'Alt_L']]) ifTrue:[ |
|
1363 |
^ true |
|
1364 |
]. |
|
1365 |
(key == #Meta |
|
1366 |
or:[key == #'Meta_R' or:[key == #'Meta_L']]) ifTrue:[ |
|
1367 |
^ true |
|
1368 |
]. |
|
1369 |
(key == #Control |
|
1370 |
or:[key == #'Control_R' or:[key == #'Control_L']]) ifTrue:[ |
|
1371 |
^ true |
|
1372 |
]. |
|
1373 |
^ false |
|
1374 |
! |
|
1375 |
||
1376 |
key:key state:onOrOff |
|
1377 |
"update the state of the shiftDown/metaDown and ctrlDown |
|
1378 |
flags" |
|
1379 |
||
260 | 1380 |
(key = #Shift |
1381 |
or:[key = #'Shift_R' |
|
1382 |
or:[key = #'Shift_L']]) ifTrue:[ |
|
244 | 1383 |
shiftDown := onOrOff. |
1384 |
^ self |
|
1385 |
]. |
|
260 | 1386 |
(key = #Alt |
1387 |
or:[key = #'Alt_R' or:[key = #'Alt_L']]) ifTrue:[ |
|
244 | 1388 |
altDown := onOrOff. |
1389 |
^ self |
|
1390 |
]. |
|
260 | 1391 |
(key = #Meta |
1392 |
or:[key = #'Meta_R' or:[key = #'Meta_L']]) ifTrue:[ |
|
244 | 1393 |
metaDown := onOrOff. |
1394 |
^ self |
|
1395 |
]. |
|
260 | 1396 |
(key = #Control |
1397 |
or:[key = #'Control_R' or:[key = #'Control_L']]) ifTrue:[ |
|
244 | 1398 |
ctrlDown := onOrOff. |
1399 |
^ self |
|
1400 |
]. |
|
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
|
1401 |
! |
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
|
1402 |
|
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
|
1403 |
updateModifierStateFrom:state device:aDevice |
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
|
1404 |
"this refetches the modifier key-states." |
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
|
1405 |
|
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
|
1406 |
|
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
|
1407 |
"/ Prevents wrong behavior in the following scenario: |
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
|
1408 |
"/ ctrl is pressed in a view |
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
|
1409 |
"/ pointer is moved out of view |
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
|
1410 |
"/ ctrl is released |
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
|
1411 |
"/ pointer moved back into view |
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
|
1412 |
"/ popup-menu still thinks that ctrl is pressed" |
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
|
1413 |
|
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
|
1414 |
"/ could do it from state - but I am lazy |
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
|
1415 |
shiftDown := aDevice shiftDown. |
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
|
1416 |
ctrlDown := aDevice ctrlDown. |
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
|
1417 |
metaDown := aDevice metaDown. |
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
|
1418 |
altDown := aDevice altDown. |
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
|
1419 |
|
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
|
1420 |
"Created: 27.2.1996 / 14:54:38 / cg" |
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
|
1421 |
"Modified: 27.2.1996 / 15:02:53 / cg" |
244 | 1422 |
! ! |
1423 |
||
140 | 1424 |
!WindowSensor methodsFor:'queries '! |
1425 |
||
244 | 1426 |
altDown |
1427 |
"return true, if the meta key is currently pressed. |
|
1428 |
Notice, that some keyboards dont have an alt key; |
|
1429 |
it is better to use 'sensor metaDown or:[sensor altDown]'." |
|
1430 |
||
1431 |
^ altDown |
|
1432 |
! |
|
1433 |
||
1434 |
anyButtonPressed |
|
1435 |
"ST-80 compatibility: return true, if any mouse button is pressed. |
|
1436 |
You should no use it in 'normal' applications. |
|
1437 |
Instead, keep track of the buttons state in your views or controllers |
|
1438 |
button-event methods." |
|
1439 |
||
1440 |
^ rightButtonDown or:[middleButtonDown or:[rightButtonDown]] |
|
1441 |
! |
|
1442 |
||
1443 |
blueButtonPressed |
|
1444 |
"ST-80 compatibility: return true, if the right mouse button is pressed. |
|
1445 |
You should no use it in 'normal' applications. |
|
1446 |
Instead, keep track of the buttons state in your views or controllers |
|
1447 |
button-event methods." |
|
1448 |
||
1449 |
^ rightButtonDown |
|
1450 |
! |
|
1451 |
||
1452 |
ctrlDown |
|
1453 |
"return true, if any CTRL key is currently pressed." |
|
1454 |
||
1455 |
^ ctrlDown |
|
1456 |
! |
|
1457 |
||
1458 |
cursorPoint |
|
1459 |
"ST-80 compatibility: |
|
1460 |
return the position of the mouse pointer on the current display |
|
1461 |
(in screen coordinates)" |
|
1462 |
||
1463 |
^ self class cursorPoint |
|
1464 |
! |
|
140 | 1465 |
|
244 | 1466 |
eventPending |
1467 |
"return true, if either damage or events are pending" |
|
1468 |
||
1469 |
mouseAndKeyboard size ~~ 0 ifTrue:[^ true]. |
|
1470 |
^ damage size ~~ 0 |
|
1471 |
! |
|
1472 |
||
1473 |
globalOrigin |
|
1474 |
"ST-80 compatibility: |
|
1475 |
dont know what we should return here ... |
|
1476 |
... at least the PD program which uses it works when we return 0@0." |
|
1477 |
||
1478 |
^ 0@0 |
|
1479 |
! |
|
1480 |
||
1481 |
hasButtonMotionEventsFor:aView |
|
1482 |
"return true, if any buttonMotion events are pending. |
|
1483 |
If the argument, aView is nil, the information is regarding any |
|
1484 |
view (i.e. is there a motion event for any of my views); |
|
1485 |
otherwise, the information is regrding that specific view." |
|
1486 |
||
1487 |
^ self hasEvent:#buttonMotion:x:y: orPendingDeviceEvent:#buttonMotion for:aView |
|
1488 |
! |
|
1489 |
||
1490 |
hasButtonPressEventFor:aView |
|
1491 |
"return true, if any buttonPress events are pending. |
|
1492 |
If the argument, aView is nil, the information is regarding any |
|
1493 |
view (i.e. is there a motion event for any of my views); |
|
1494 |
otherwise, the information is regrding that specific view." |
|
1495 |
||
1496 |
^ self hasEvent:#buttonPress:x:y: orPendingDeviceEvent:#buttonPress for:aView |
|
1497 |
! |
|
1498 |
||
1499 |
hasButtonReleaseEventFor:aView |
|
1500 |
"return true, if any buttonRelease events are pending. |
|
1501 |
If the argument, aView is nil, the information is regarding any |
|
1502 |
view (i.e. is there a motion event for any of my views); |
|
1503 |
otherwise, the information is regrding that specific view." |
|
1504 |
||
1505 |
^ self hasEvent:#buttonRelease:x:y: orPendingDeviceEvent:#buttonRelease for:aView |
|
140 | 1506 |
! |
1507 |
||
428 | 1508 |
hasConfigureEventFor:aView |
1509 |
"return true, if any resize/position events are pending. |
|
1510 |
If the argument, aView is nil, the information is regarding any |
|
1511 |
view (i.e. is there a motion event for any of my views); |
|
1512 |
otherwise, the information is regrding that specific view." |
|
1513 |
||
1514 |
^ self hasEvent:#configureX:y:width:height: orPendingDeviceEvent:#structureNotify for:aView |
|
1515 |
! |
|
1516 |
||
140 | 1517 |
hasDamage |
1518 |
"return true, if any exposure events are pending" |
|
1519 |
||
1520 |
^ damage size ~~ 0 |
|
1521 |
! |
|
1522 |
||
1523 |
hasDamageFor:aView |
|
1524 |
"return true, if any exposure events are pending for aView" |
|
1525 |
||
1526 |
damage size ~~ 0 ifTrue:[ |
|
1527 |
damage do:[:aDamage | |
|
1528 |
aDamage notNil ifTrue:[ |
|
1529 |
aDamage view == aView ifTrue:[^ true]. |
|
1530 |
]. |
|
1531 |
] |
|
1532 |
]. |
|
1533 |
^ false |
|
1534 |
! |
|
1535 |
||
157 | 1536 |
hasEvent:type orPendingDeviceEvent:dType for:aView |
1537 |
"return true, if a specific event is pending. |
|
1538 |
Type is the type of event, dType the corresponding device event. |
|
1539 |
If the argument, aView is nil, the information is regarding any |
|
1540 |
view (i.e. is there a motion event for any of my views); |
|
1541 |
otherwise, the information is regrding that specific view." |
|
140 | 1542 |
|
1543 |
mouseAndKeyboard size ~~ 0 ifTrue:[ |
|
428 | 1544 |
mouseAndKeyboard do:[:anEvent | |
1545 |
anEvent notNil ifTrue:[ |
|
1546 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1547 |
anEvent type == type ifTrue:[^ true]. |
|
1548 |
] |
|
1549 |
]. |
|
1550 |
] |
|
1551 |
]. |
|
1552 |
damage size ~~ 0 ifTrue:[ |
|
1553 |
damage do:[:anEvent | |
|
1554 |
anEvent notNil ifTrue:[ |
|
1555 |
(aView isNil or:[anEvent view == aView]) ifTrue:[ |
|
1556 |
anEvent type == type ifTrue:[^ true]. |
|
1557 |
] |
|
1558 |
]. |
|
1559 |
] |
|
140 | 1560 |
]. |
157 | 1561 |
aView notNil ifTrue:[ |
428 | 1562 |
^ aView device eventPending:dType for:aView id |
157 | 1563 |
]. |
1564 |
^ false |
|
1565 |
! |
|
1566 |
||
244 | 1567 |
hasEvents |
1568 |
"return true, if any mouse/keyboard events are pending" |
|
157 | 1569 |
|
244 | 1570 |
^ mouseAndKeyboard size ~~ 0 |
157 | 1571 |
! |
1572 |
||
539
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1573 |
hasKeyPressEventsFor:aView |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1574 |
"return true, if any keyPress events are pending. |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1575 |
If the argument, aView is nil, the information is regarding any |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1576 |
view (i.e. is there a motion event for any of my views); |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1577 |
otherwise, the information is regrding that specific view." |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1578 |
|
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1579 |
^ self hasEvent:#keyPress:x:y: orPendingDeviceEvent:#keyPress for:aView |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1580 |
|
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1581 |
"Created: 23.3.1996 / 14:16:50 / cg" |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1582 |
! |
8b7e0a35264d
added query for pending keyPress events
Claus Gittinger <cg@exept.de>
parents:
510
diff
changeset
|
1583 |
|
157 | 1584 |
leftButtonPressed |
1585 |
"return true, if the left mouse button is pressed. |
|
1586 |
This has been added to support ST-80 style button polling; |
|
1587 |
however, you should no use it in 'normal' applications. |
|
1588 |
Instead, keep track of the buttons state in your views or controllers |
|
1589 |
button-event methods." |
|
1590 |
||
1591 |
^ leftButtonDown |
|
1592 |
! |
|
1593 |
||
244 | 1594 |
metaDown |
1595 |
"return true, if the meta key is currently pressed. |
|
1596 |
Notice, that most keyboards dont have a meta key; |
|
1597 |
it is better to use 'sensor metaDown or:[sensor altDown]'." |
|
1598 |
||
1599 |
^ metaDown |
|
1600 |
! |
|
1601 |
||
157 | 1602 |
middleButtonPressed |
1603 |
"return true, if the middle mouse button is pressed. |
|
1604 |
This has been added to support ST-80 style button polling; |
|
1605 |
however, you should no use it in 'normal' applications. |
|
1606 |
Instead, keep track of the buttons state in your views or controllers |
|
1607 |
button-event methods." |
|
1608 |
||
1609 |
^ middleButtonDown |
|
1610 |
! |
|
1611 |
||
547 | 1612 |
motionEventPending |
1613 |
"return true, if any buttonMotion events are pending." |
|
1614 |
||
1615 |
^ self hasButtonMotionEventsFor:nil |
|
1616 |
||
1617 |
"Created: 24.3.1996 / 20:09:55 / cg" |
|
1618 |
! |
|
1619 |
||
244 | 1620 |
mousePoint |
1621 |
"ST-80 compatibility: |
|
1622 |
return the position of the mouse pointer on the current display |
|
1623 |
(in screen coordinates)" |
|
1624 |
||
1625 |
^ self cursorPoint |
|
1626 |
! |
|
1627 |
||
1628 |
redButtonPressed |
|
1629 |
"ST-80 compatibility: return true, if the left mouse button is pressed. |
|
1630 |
You should no use it in 'normal' applications. |
|
1631 |
Instead, keep track of the buttons state in your views or controllers |
|
1632 |
button-event methods." |
|
1633 |
||
1634 |
^ leftButtonDown |
|
1635 |
! |
|
1636 |
||
157 | 1637 |
rightButtonPressed |
1638 |
"return true, if the right mouse button is pressed. |
|
1639 |
This has been added to support ST-80 style button polling; |
|
1640 |
however, you should no use it in 'normal' applications. |
|
1641 |
Instead, keep track of the buttons state in your views or controllers |
|
1642 |
button-event methods." |
|
1643 |
||
1644 |
^ rightButtonDown |
|
1645 |
! |
|
1646 |
||
244 | 1647 |
shiftDown |
1648 |
"return true, if any shift key is currently pressed." |
|
157 | 1649 |
|
244 | 1650 |
^ shiftDown |
157 | 1651 |
! |
1652 |
||
1653 |
yellowButtonPressed |
|
1654 |
"ST-80 compatibility: return true, if the middle mouse button is pressed. |
|
1655 |
You should no use it in 'normal' applications. |
|
1656 |
Instead, keep track of the buttons state in your views or controllers |
|
1657 |
button-event methods." |
|
1658 |
||
1659 |
^ middleButtonDown |
|
140 | 1660 |
! ! |
1661 |
||
26 | 1662 |
!WindowSensor methodsFor:'special'! |
1663 |
||
54 | 1664 |
catchExpose |
1665 |
"start catching noExpose events (must be done BEFORE a bitblt, |
|
1666 |
to prepare for the exposeEventSemaphore to be signalled when |
|
1667 |
the noExpose event arrives)." |
|
26 | 1668 |
|
54 | 1669 |
gotExpose := false. |
1670 |
gotOtherEvent := false. |
|
1671 |
catchExpose := true. |
|
26 | 1672 |
exposeEventSemaphore := Semaphore new. |
28 | 1673 |
! |
1674 |
||
244 | 1675 |
waitButton |
1676 |
"ST-80 compatibility: wait until any mouse button is pressed. |
|
1677 |
Do not use this in your applications; polling the sensor is |
|
1678 |
bad style." |
|
1679 |
||
1680 |
[self anyButtonPressed] whileFalse:[ |
|
371 | 1681 |
Delay waitForSeconds:0.01. |
244 | 1682 |
]. |
1683 |
||
1684 |
"/ (leftButtonPressed |
|
1685 |
"/ or:[middleButtonPressed |
|
1686 |
"/ or:[rightButtonPressed]]) ifTrue:[^ self]. |
|
1687 |
"/ |
|
1688 |
"/ [self hasButtonPressEventFor:nil] whileFalse:[ |
|
1689 |
"/ (Delay forSeconds:0.01) wait. |
|
1690 |
"/ ] |
|
1691 |
! |
|
1692 |
||
26 | 1693 |
waitForExposeFor:aView |
157 | 1694 |
"wait until a graphicsExpose or a noExpose arrives (after a bitblt). |
1695 |
This may be too X-specific, and things may change in this area |
|
1696 |
in future versions. (or the new device may simulate the arrival of |
|
1697 |
such an event)" |
|
54 | 1698 |
|
313 | 1699 |
aView flush. |
90 | 1700 |
Processor activeProcessIsSystemProcess ifTrue:[ |
386 | 1701 |
" |
1702 |
cannot really suspend, if its a systemProcess |
|
1703 |
" |
|
1704 |
[gotExpose] whileFalse:[ |
|
1705 |
aView device dispatchExposeEventFor:aView id. |
|
1706 |
Processor yield. |
|
1707 |
] |
|
90 | 1708 |
] ifFalse:[ |
386 | 1709 |
[gotExpose] whileFalse:[ |
1710 |
" |
|
1711 |
just in case we have a (network or software) problem ... |
|
1712 |
explanation: it may happen, that an expose event is totally |
|
1713 |
lost - for example, if the network breaks down. |
|
1714 |
To not block forever, we wait with a timeout, to get out of here |
|
1715 |
if the event does not arrive after 15 seconds. |
|
1716 |
" |
|
1717 |
(exposeEventSemaphore waitWithTimeout:5) isNil ifTrue:[ |
|
1718 |
aView device flush. |
|
1719 |
" |
|
1720 |
you can put a comment around the following line, if you dont |
|
1721 |
like the message ... |
|
1722 |
" |
|
1723 |
'WSENSOR: late expose event' errorPrintNL. |
|
1724 |
(exposeEventSemaphore waitWithTimeout:10) isNil ifFalse:[ |
|
1725 |
'WSENSOR: lost expose event again - ignore' errorPrintNL. |
|
1726 |
]. |
|
1727 |
" |
|
1728 |
ok, break out |
|
1729 |
" |
|
1730 |
catchExpose := false. |
|
1731 |
gotExpose := true. |
|
1732 |
^ self |
|
1733 |
] |
|
1734 |
]. |
|
26 | 1735 |
|
386 | 1736 |
" |
1737 |
other incoming events have been ignored during the wait. |
|
1738 |
Now handle those ... |
|
1739 |
" |
|
1740 |
gotOtherEvent ifTrue:[ |
|
1741 |
eventSemaphore signal |
|
1742 |
]. |
|
26 | 1743 |
]. |
28 | 1744 |
catchExpose := false |
326 | 1745 |
|
327 | 1746 |
"Modified: 16.12.1995 / 02:27:15 / cg" |
47 | 1747 |
! |
1748 |
||
157 | 1749 |
waitNoButton |
1750 |
"ST-80 compatibility: wait until no mouse button is pressed. |
|
1751 |
Do not use this in your applications; polling the sensor is |
|
1752 |
bad style." |
|
1753 |
||
1754 |
[self anyButtonPressed] whileTrue:[ |
|
371 | 1755 |
Delay waitForSeconds:0.01. |
157 | 1756 |
]. |
1757 |
"/ (leftButtonPressed |
|
1758 |
"/ or:[middleButtonPressed |
|
1759 |
"/ or:[rightButtonPressed]]) ifFalse:[^ self]. |
|
1760 |
"/ |
|
1761 |
"/ [self hasButtonReleaseEventFor:nil] whileFalse:[ |
|
1762 |
"/ (Delay forSeconds:0.01) wait. |
|
1763 |
"/ ] |
|
1764 |
! ! |
|
1765 |
||
251 | 1766 |
!WindowSensor class methodsFor:'documentation'! |
1767 |
||
1768 |
version |
|
547 | 1769 |
^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.50 1996-03-26 13:24:46 cg Exp $' |
251 | 1770 |
! ! |
140 | 1771 |
WindowSensor initialize! |