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