[squeak-dev] The Trunk: Graphics-mt.507.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 6 09:57:51 UTC 2022

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

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

Name: Graphics-mt.507
Author: mt
Time: 6 April 2022, 11:57:44.501029 am
UUID: 98abf5e0-883f-9f42-9e3d-6cb2191866ff
Ancestors: Graphics-mt.506

Activate #primitiveScreenScaleFactor bc. most recent OSVM reports NaN for unknown factor, not 1.0. Still report 1.0 for unknown cases to make #platformScaleFactor robust, see #platformScaleFactorKnown.

=============== Diff against Graphics-mt.506 ===============

Item was changed:
  ----- Method: DisplayScreen class>>actualScreenScaleFactor (in category 'snapshots') -----
+ 	<primitive: #primitiveScreenScaleFactor>
- 	"<primitive: #primitiveScreenScaleFactor>"
- 	"Once the primitive is ready, you can simply uncomment it. The system is prepared for changes from 'nil' to actual factors and back."
+ 	^ Float nan "Unknown scale factor"!
- 	^ nil "unknown -- do not default to 1.0 here"!

Item was changed:
  ----- Method: DisplayScreen>>platformScaleFactor (in category 'scale factor') -----
+ 	"Answers the platform's (and thus monitor's) current scale factor as last reported via VM primitive. See #checkForNewScreenScaleFactor. For robustness, always report a sensible value. However, you should check via #platformScaleFactorKnown whether this value is reliable."
- 	"Answers the platform's (and thus monitor's) current scale factor as last reported via VM primitive. See #checkForNewScreenScaleFactor."
  	^ PlatformScaleFactor ifNil: [1.0 "Primitive not ready."]!

Item was changed:
  ----- Method: DisplayScreen>>platformScaleFactor: (in category 'scale factor') -----
  platformScaleFactor: aFloatOrNil
  	"Report a new scale factor from the platform to the image. This can happen if you move Squeak's window between monitors with different pixels-per-inch. On some platforms, you can also set a scale factor independent of monitor PPI. Note that the user might have scaled the image regardless of the previous platform scale factor."
  	| old new |
+ 	(aFloatOrNil isNil or: [aFloatOrNil isNaN]) ifTrue: [
- 	aFloatOrNil ifNil: [
  		"Ignore. Primitive not ready (anymore)."
  		PlatformScaleFactor := nil.
  		^ self].
  	PlatformScaleFactor ifNil: [
  		"First time. Ignore. Assume that the user scaled manually until now."
+ 		"self assert: [aFloatOrNil notNil]."
+ 		"self assert: [aFloatOrNil isNaN not]."
  		PlatformScaleFactor := aFloatOrNil.
  		^ self].
  	(old := self platformScaleFactor) = (new := aFloatOrNil) ifTrue: [^ self].
  	PlatformScaleFactor := new.
  	self uiScaleFactor: self uiScaleFactor * (new/old).!

More information about the Squeak-dev mailing list