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