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