[squeak-dev] The Trunk: Morphic-mt.1805.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Dec 1 14:54:22 UTC 2021

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

==================== Summary ====================

Name: Morphic-mt.1805
Author: mt
Time: 1 December 2021, 3:54:09.720361 pm
UUID: 6f406a88-dc84-ad41-ad2a-a27839816f28
Ancestors: Morphic-mt.1804

Adds support for #windowDeactivated event delivered by newer VMs.

Thanks to Christoph (ct) for the idea and also implementation on the VM side!

See: http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-November/216931.html

=============== Diff against Morphic-mt.1804 ===============

Item was changed:
  ----- Method: HandMorph>>generateWindowEvent: (in category 'private events') -----
  generateWindowEvent: evtBuf 
  	"Generate the appropriate window event for the given raw event buffer"
  	| evt |
  	evt := WindowEvent new.
+ 	evt setHand: self.
  	evt setTimeStamp: evtBuf second.
  	evt timeStamp = 0 ifTrue: [evt setTimeStamp: Sensor eventTimeNow].
  	evt action: evtBuf third.
  	evt rectangle: (Rectangle origin: evtBuf fourth @ evtBuf fifth corner: evtBuf sixth @ evtBuf seventh ).

Item was changed:
  ----- Method: PasteUpMorph>>windowEvent: (in category 'event handling') -----
  windowEvent: anEvent
  	self windowEventHandler
  		ifNotNil: [^self windowEventHandler windowEvent: anEvent].
+ 	anEvent type
+ 		caseOf: {
+ 			[#windowClose] -> [
+ 				Preferences eToyFriendly 
+ 					ifTrue: [ProjectNavigationMorph basicNew quitSqueak]
+ 					ifFalse: [TheWorldMenu basicNew quitSession]].
+ 			[#windowDeactivated]	-> [
+ 				"The host window has been deactivated. Until it regains the focus, honor the fact that we will not receive keyboard events again by changing the current keyboard focus morph. windowHostFocusMorph represents the host system which now holds the keyboard focus instead of the previousFocus. If enabled, disable #mouseOverForKeyboardFocus temporarily because when inactive, we *can't* set the keyboard focus."
+ 				(self valueOfProperty: #windowHostFocusMorph ifAbsentPut: [
+ 					Morph new
+ 						name: #windowHostFocusMorph;
+ 						yourself]) in: [:hostFocus |
+ 					hostFocus setProperty: #previousFocus toValue: anEvent hand keyboardFocus.
+ 					anEvent hand newKeyboardFocus: hostFocus.
+ 					Preferences mouseOverForKeyboardFocus ifTrue: [
+ 						hostFocus setProperty: #previousMouseOverForKeyboardFocus toValue: true.
+ 						Preferences setPreference: #mouseOverForKeyboardFocus toValue: false]]].
+ 			[#windowActivated] -> [
+ 				"Alright, the spook is over!! We have back control over the keyboard focus, delete the windowHostFocusMorph and restore the previous focus holder and the #mouseOverForKeyboardFocus preference."
+ 				self valueOfProperty: #windowHostFocusMorph ifPresentDo: [:hostFocus |
+ 					hostFocus abandon.
+ 					(hostFocus valueOfProperty: #previousFocus) ifNotNil: [:previousFocus |
+ 						anEvent hand newKeyboardFocus: previousFocus].
+ 					(hostFocus valueOfProperty: #previousMouseOverForKeyboardFocus) ifNotNil: [:value |
+ 						Preferences setPreference: #mouseOverForKeyboardFocus toValue: value].
+ 					self removeProperty: #windowHostFocusMorph]]. }
+ 		otherwise: []!
- 	anEvent type == #windowClose
- 		ifTrue: [
- 			^Preferences eToyFriendly 
- 				ifTrue: [ProjectNavigationMorph basicNew quitSqueak]
- 				ifFalse: [TheWorldMenu basicNew quitSession]].
- !

Item was changed:
  ----- Method: WindowEvent>>type (in category 'accessing') -----
  	"This should match the definitions in sq.h"
+ 		windowChangedScreen
+ 		windowDeactivated
  	) at: action ifAbsent: [#windowEventUnknown]!

More information about the Squeak-dev mailing list