"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
WindowSensor subclass:#SynchronousWindowSensor
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Interface-Support'
!
!SynchronousWindowSensor class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
in contrast to a regular windowSensor, instances of SynchronousWindowSensor
do NOT put events into a queue and do NOT wakeup any windowGroup process.
Instead, the underlying view is notified synchronously (via a message send)
about the event.
These are used for only one single situation:
when a modal debugger is open
(i.e. one that is debugging the scheduler or event-dispatcher).
This debuggers windowGroup is augmented with a synchronous Sensor, in order
to prevent the event handling code from suspending any process
(you cannot suspend the scheduler; you should not suspend the event dispatcher).
This is pretty tricky and magic - you dont have to understand this.
(consider this system internal code)
These sensors are not used with regular views.
[author:]
Claus Gittinger
"
! !
!SynchronousWindowSensor methodsFor:'event handling'!
addDamage:aRectangle view:aView wakeup:doWakeup
"forward as an expose for some view"
aView
dispatchEvent:#exposeX:y:width:height:
arguments:(Array with:aRectangle left
with:aRectangle top
with:aRectangle width
with:aRectangle height)
"/ WindowEvent
"/ sendEvent:#exposeX:y:width:height:
"/ arguments:(Array with:aRectangle left
"/ with:aRectangle top
"/ with:aRectangle width
"/ with:aRectangle height)
"/ view:aView
"Modified: / 20.5.1998 / 22:55:37 / cg"
!
buttonMotion:button x:x y:y view:aView
"forward a button-motion for some view"
aView
dispatchEvent:#buttonMotion:x:y:
arguments:(Array with:button with:x with:y)
"/ WindowEvent
"/ sendEvent:#buttonMotion:x:y:
"/ arguments:(Array with:button with:x with:y)
"/ view:aView
"Created: / 24.11.1995 / 19:14:02 / cg"
"Modified: / 20.5.1998 / 22:55:54 / cg"
!
buttonMultiPress:button x:x y:y view:aView
"forward a button-multi-press event for some view"
aView
dispatchEvent:#buttonMultiPress:x:y:
arguments:(Array with:button with:x with:y)
"/ WindowEvent
"/ sendEvent:#buttonMultiPress:x:y:
"/ arguments:(Array with:button with:x with:y)
"/ view:aView
"Created: / 24.11.1995 / 19:14:14 / cg"
"Modified: / 20.5.1998 / 22:56:07 / cg"
!
buttonPress:button x:x y:y view:aView
"forward a button-press event for some view"
aView
dispatchEvent:#buttonPress:x:y:
arguments:(Array with:button with:x with:y)
"/ WindowEvent
"/ sendEvent:#buttonPress:x:y:
"/ arguments:(Array with:button with:x with:y)
"/ view:aView
"Created: / 24.11.1995 / 19:14:25 / cg"
"Modified: / 20.5.1998 / 22:56:23 / cg"
!
buttonRelease:button x:x y:y view:aView
"forward a button-release event for some view"
aView
dispatchEvent:#buttonRelease:x:y:
arguments:(Array with:button with:x with:y)
"/ WindowEvent
"/ sendEvent:#buttonRelease:x:y:
"/ arguments:(Array with:button with:x with:y)
"/ view:aView
"Created: / 24.11.1995 / 19:14:36 / cg"
"Modified: / 20.5.1998 / 22:56:34 / cg"
!
configureX:x y:y width:w height:h view:aView
"forward a configure for some view"
aView configureX:x y:y width:w height:h
"Created: 24.11.1995 / 19:14:59 / cg"
!
coveredBy:otherView view:aView
"forward a covered for some view"
aView coveredBy:otherView
"Created: 24.11.1995 / 19:15:11 / cg"
!
destroyedView:aView
"forward a destroyed event for some view"
aView destroyed
"Created: 24.11.1995 / 19:15:22 / cg"
!
exposeX:x y:y width:w height:h view:aView
"forward an expose for some view"
aView
dispatchEvent:#exposeX:y:width:height:
arguments:(Array with:x with:y with:w with:h)
"/ WindowEvent
"/ sendEvent:#exposeX:y:width:height:
"/ arguments:(Array with:x with:y with:w with:h)
"/ view:aView
"Created: / 24.11.1995 / 19:15:54 / cg"
"Modified: / 20.5.1998 / 22:56:49 / cg"
!
focusInView:aView
"forward a focusIn event for some view"
aView
dispatchEvent:#focusIn
arguments:nil
"/ WindowEvent
"/ sendEvent:#focusIn
"/ arguments:nil
"/ view:aView
"Created: / 24.11.1995 / 19:16:11 / cg"
"Modified: / 20.5.1998 / 22:57:04 / cg"
!
focusOutView:aView
"forward a focusOut event for some view"
aView
dispatchEvent:#focusOut
arguments:nil
"/ WindowEvent
"/ sendEvent:#focusOut
"/ arguments:nil
"/ view:aView
"Created: / 24.11.1995 / 19:16:24 / cg"
"Modified: / 20.5.1998 / 22:57:16 / cg"
!
graphicsExposeX:x y:y width:w height:h final:final view:aView
"forward a graphic expose for some view"
"/ this is a possible response to a scroll operation
"/ (if an expose is pending)
final ifTrue:[
(catchExpose includes:aView) ifTrue:[
gotExpose add:aView.
]
].
aView
dispatchEvent:#graphicsExposeX:y:width:height:final:
arguments:(Array with:x with:y with:w with:h with:final)
"/ WindowEvent
"/ sendEvent:#graphicsExposeX:y:width:height:final:
"/ arguments:(Array with:x with:y with:w with:h with:final)
"/ view:aView
"Created: / 24.11.1995 / 19:16:38 / cg"
"Modified: / 20.5.1998 / 22:57:32 / cg"
!
keyPress:untranslatedKey x:x y:y view:aView
"forward a key-press event for some view"
|xlatedKey|
self key:untranslatedKey state:true.
xlatedKey := aView graphicsDevice translateKey:untranslatedKey forView:aView.
xlatedKey notNil ifTrue:[
aView
dispatchEvent:#keyPress:x:y:
arguments:(Array with:xlatedKey with:x with:y)
"/ WindowEvent
"/ sendEvent:#keyPress:x:y:
"/ arguments:(Array with:xlatedKey with:x with:y)
"/ view:aView
]
"Created: / 24.11.1995 / 19:17:23 / cg"
"Modified: / 20.5.1998 / 22:57:52 / cg"
!
keyRelease:untranslatedKey x:x y:y view:aView
"forward a key-release event for some view"
|xlatedKey|
self key:untranslatedKey state:false.
xlatedKey := aView graphicsDevice translateKey:untranslatedKey forView:aView.
xlatedKey notNil ifTrue:[
aView
dispatchEvent:#keyRelease:x:y:
arguments:(Array with:xlatedKey with:x with:y)
"/ WindowEvent
"/ sendEvent:#keyRelease:x:y:
"/ arguments:(Array with:xlatedKey with:x with:y)
"/ view:aView
]
"Created: / 24.11.1995 / 19:17:50 / cg"
"Modified: / 20.5.1998 / 22:58:05 / cg"
!
mappedView:aView
"forward a mapped event for some view"
aView mapped
"Created: 24.11.1995 / 19:18:01 / cg"
!
mouseWheelMotion:amount state:state deltaTime:dTime view:aView
"forward a wheel-motion for some view"
aView
dispatchEvent:#mouseWheelMotion:state:deltaTime:
arguments:(Array with:amount with:state with:dTime)
"Created: / 21.5.1999 / 13:07:51 / cg"
!
noExposeView:aView
"forward a noExpose event for some view"
catchExpose isNil ifTrue:[
'SWSensor [info]: noExpose but not catching' infoPrintCR.
].
(catchExpose includes:aView) ifTrue:[
gotExpose add:aView.
catchExpose remove:aView.
].
aView noExpose.
"Created: 24.11.1995 / 19:18:10 / cg"
"Modified: 29.1.1997 / 20:46:47 / cg"
!
pointerEnter:buttonState x:x y:y view:aView
"forward a pointer enter for some view"
aView
dispatchEvent:#pointerEnter:x:y:
arguments:(Array with:buttonState with:x with:y)
"/ WindowEvent
"/ sendEvent:#pointerEnter:x:y:
"/ arguments:(Array with:buttonState with:x with:y)
"/ view:aView
"Created: / 24.11.1995 / 19:18:20 / cg"
"Modified: / 20.5.1998 / 22:58:20 / cg"
!
pointerLeave:buttonState view:aView
"forward a pointer leave for some view"
aView
dispatchEvent:#pointerLeave:
arguments:(Array with:buttonState)
"/ WindowEvent
"/ sendEvent:#pointerLeave:
"/ arguments:(Array with:buttonState)
"/ view:aView
"Created: / 24.11.1995 / 19:18:30 / cg"
"Modified: / 20.5.1998 / 22:58:35 / cg"
!
saveAndTerminateView:aView
"forward a saveAndTerminate event for some view"
aView saveAndTerminate
"Created: 24.11.1995 / 19:18:38 / cg"
!
terminateView:aView
"forward a terminate event for some view"
aView terminate
"Created: 24.11.1995 / 19:18:48 / cg"
!
unmappedView:aView
"forward an unmapped event for some view"
aView unmapped
"Created: 24.11.1995 / 19:18:59 / cg"
! !
!SynchronousWindowSensor methodsFor:'specials'!
catchExposeFor:aView
"start catching noExpose events (must be done BEFORE a bitblt)."
catchExpose notEmpty ifTrue:[
'SWSensor [warning]: already catching in catchExpose' errorPrintCR.
].
gotOtherEvent remove:aView ifAbsent:nil.
gotExpose remove:aView ifAbsent:nil.
catchExpose add:aView.
"Modified: 29.1.1997 / 20:43:44 / cg"
!
waitForExposeFor:aView
"wait until a graphicsExpose or a noExpose arrives (after a bitblt)."
|device windowId stopPoll endPollTime|
device := aView graphicsDevice.
"/ this is only needed for X ...
device scrollsAsynchronous ifTrue:[
windowId := aView id.
"/
"/ cannot suspend, I am a synchronous-modal sensor
"/ must poll for the event
"/
endPollTime := AbsoluteTime now addSeconds:10.
stopPoll := false.
[(gotExpose includes:aView) or:[stopPoll]] whileFalse:[
(device exposeEventPendingFor:windowId withSync:true) ifTrue:[
device dispatchExposeEventFor:windowId.
].
stopPoll := (AbsoluteTime now > endPollTime).
Processor yield.
].
stopPoll ifTrue:[
'SyncWindowSensor [warning]: lost expose event' errorPrintCR.
]
].
catchExpose remove:aView ifAbsent:nil.
gotExpose remove:aView ifAbsent:nil.
"Modified: 19.8.1997 / 17:25:09 / cg"
! !
!SynchronousWindowSensor class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview/SynchronousWindowSensor.st,v 1.19 1999-05-22 14:32:22 cg Exp $'
! !