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