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