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