--- a/WinWorkstation.st Mon Nov 25 10:04:06 2019 +0100
+++ b/WinWorkstation.st Mon Nov 25 10:04:14 2019 +0100
@@ -6266,6 +6266,82 @@
"
! !
+!WinWorkstation class methodsFor:'actions'!
+
+commonSetDpiAwareModeForExpeccoBinaries:dpiAwareMode
+ |currentBinary otherBinary
+ registryKeyForDpiAware|
+
+ currentBinary := OperatingSystem pathOfSTXExecutable asFilename.
+ currentBinary suffix asLowercase = 'exe' ifTrue:[
+ otherBinary := currentBinary withSuffix:'com'.
+ ] ifFalse:[
+ otherBinary := currentBinary withSuffix:'exe'.
+ ].
+
+ registryKeyForDpiAware := self registryKeyForHighDpiAware.
+
+ (Array
+ with:currentBinary
+ with:otherBinary) do:[:eachBinaryFilename |
+ registryKeyForDpiAware
+ valueNamed:eachBinaryFilename nameString
+ put:dpiAwareMode.
+ ].
+
+ "Created: / 25-11-2019 / 09:43:56 / Stefan Reise"
+!
+
+setHighDpiAware
+ "after set this key,
+ the next started stx/expecco instance will not be scaled by windows
+ you can check for success by inspect the binary properties
+ via windows context menu of the binary"
+
+ "
+ self unsetHighDpiAware.
+ self isApplicationHighDpiAware.
+ self setHighDpiAware.
+ self isApplicationHighDpiAware.
+ "
+
+ self commonSetDpiAwareModeForExpeccoBinaries:self registryValueForHighDpiAware.
+
+ "Created: / 25-11-2019 / 09:44:30 / Stefan Reise"
+!
+
+unsetHighDpiAware
+ "after unset this key,
+ the next started stx/expecco instance will be scaled by windows
+ you can check for success by inspect the binary properties
+ via windows context menu of the binary"
+
+ "
+ self unsetHighDpiAware.
+ self isApplicationHighDpiAware.
+ self setHighDpiAware.
+ self isApplicationHighDpiAware.
+ "
+
+ self commonSetDpiAwareModeForExpeccoBinaries:self regitsryValueForHighDpiUnAware.
+
+ "Created: / 25-11-2019 / 09:44:55 / Stefan Reise"
+! !
+
+!WinWorkstation class methodsFor:'constants'!
+
+registryValueForHighDpiAware
+ ^ '~HIGHDPIAWARE'
+
+ "Created: / 25-11-2019 / 09:52:25 / Stefan Reise"
+!
+
+regitsryValueForHighDpiUnAware
+ ^ '~DPIUNAWARE'
+
+ "Created: / 25-11-2019 / 09:53:30 / Stefan Reise"
+! !
+
!WinWorkstation class methodsFor:'converting'!
convertVirtualResolutionPointToCurrentResolutionPoint:aPoint
@@ -6663,6 +6739,21 @@
!WinWorkstation class methodsFor:'queries'!
+isApplicationHighDpiAware
+ "just the query if stx/expecco is high dpi aware,
+ if not: windows does scale expecco"
+
+ "
+ self isApplicationHighDpiAware
+ "
+
+ ^ (self registryKeyForHighDpiAware
+ valueNamed:OperatingSystem pathOfSTXExecutable)
+ = self registryValueForHighDpiAware
+
+ "Created: / 25-11-2019 / 09:55:34 / Stefan Reise"
+!
+
isWindowsPlatform
"return true, if this device is a windows screen"
@@ -6677,6 +6768,18 @@
^ 'WIN32'
"Modified: 26.5.1996 / 15:32:46 / cg"
+!
+
+registryKeyForHighDpiAware
+ "
+ self registryKeyForHighDpiAware
+ "
+
+ ^ Win32OperatingSystem::RegistryEntry
+ key:'HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers'
+ createIfAbsent:true.
+
+ "Created: / 25-11-2019 / 09:51:45 / Stefan Reise"
! !
!WinWorkstation class methodsFor:'queries - monitor'!
@@ -6695,6 +6798,8 @@
virtual resolution -> 1080p"
"
+ Screen currentMonitorResolutionByMonitorDeviceName:nil.
+ Screen currentMonitorResolutionByMonitorDeviceName:'ereswt'.
Screen currentMonitorResolutionByMonitorDeviceName:'\\.\DISPLAY1'.
Screen currentMonitorResolutionByMonitorDeviceName:'\\.\DISPLAY2'.
"
@@ -6702,24 +6807,28 @@
|currentX currentY|
aMonitorDeviceName isEmptyOrNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
%{
HDC hdc = CreateDCA(__stringVal(aMonitorDeviceName), NULL, NULL, NULL);
- if (hdc == NULL) {
- RETURN(nil);
+ if (hdc != NULL) {
+ currentX = __MKSMALLINT(GetDeviceCaps(hdc, DESKTOPHORZRES));
+ currentY = __MKSMALLINT(GetDeviceCaps(hdc, DESKTOPVERTRES));
+ DeleteDC(hdc);
}
-
- currentX = __MKSMALLINT(GetDeviceCaps(hdc, DESKTOPHORZRES));
- currentY = __MKSMALLINT(GetDeviceCaps(hdc, DESKTOPVERTRES));
-
- DeleteDC(hdc);
-%}.
+%}.
+
+ currentX isNil ifTrue:[
+ "return a default"
+ ^ Display extent
+ ].
^ currentX@currentY
"Created: / 22-11-2019 / 14:25:10 / Stefan Reise"
+ "Modified: / 25-11-2019 / 09:34:50 / Stefan Reise"
!
currentMonitorResolutionByPoint:aPoint
@@ -6745,17 +6854,20 @@
|monitorName|
aPoint isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
monitorName := self monitorDeviceNameForPoint:aPoint.
monitorName isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
^ self currentMonitorResolutionByMonitorDeviceName:monitorName
"Created: / 22-11-2019 / 14:26:31 / Stefan Reise"
+ "Modified (format): / 25-11-2019 / 09:35:18 / Stefan Reise"
!
currentMonitorResolutionByView:aView
@@ -6779,17 +6891,20 @@
|monitorName|
aView isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
monitorName := self monitorDeviceNameForView:aView.
monitorName isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
^ self currentMonitorResolutionByMonitorDeviceName:monitorName
"Created: / 22-11-2019 / 14:22:47 / Stefan Reise"
+ "Modified (format): / 25-11-2019 / 09:35:22 / Stefan Reise"
!
monitorDeviceNameForPoint:aPoint
@@ -6866,11 +6981,7 @@
!
scaleFactorForMonitorNamed:aMonitorDeviceName
- "ATTENTION: returns the may wrong default 1@1 if the package or the tools are missing:
- stx:support/win32/displayResolutionTools/bin/cdr.exe
- stx:support/win32/displayResolutionTools/bin/vdr.exe
-
- ATTENTION: this method always returns the scale factor set by os,
+ "ATTENTION: this method always returns the scale factor set by os,
REGARDLESS if the application (stx, expecco) has a virtual resolution or not
use #scaleFactorForRootViewTranslationOnMonitorNamed: which is dependent on the
application's (stx, expecco) high dpi awareness (if the application has a virtual
@@ -6903,6 +7014,7 @@
"Created: / 21-11-2019 / 10:12:00 / Stefan Reise"
"Modified: / 22-11-2019 / 15:17:05 / Stefan Reise"
+ "Modified (comment): / 25-11-2019 / 09:36:06 / Stefan Reise"
!
scaleFactorForRootViewTranslationOnMonitorNamed:aMonitorDeviceName
@@ -6973,25 +7085,33 @@
|virtualX virtualY|
+
+
+
+
aMonitorDeviceName isEmptyOrNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
%{
HDC hdc = CreateDCA(__stringVal(aMonitorDeviceName), NULL, NULL, NULL);
- if (hdc == NULL) {
- RETURN(nil);
+ if (hdc != NULL) {
+ virtualX = __MKSMALLINT(GetDeviceCaps(hdc, HORZRES));
+ virtualY = __MKSMALLINT(GetDeviceCaps(hdc, VERTRES));
+ DeleteDC(hdc);
}
-
- virtualX = __MKSMALLINT(GetDeviceCaps(hdc, HORZRES));
- virtualY = __MKSMALLINT(GetDeviceCaps(hdc, VERTRES));
-
- DeleteDC(hdc);
-%}.
+%}.
+
+ virtualX isNil ifTrue:[
+ "return a default"
+ ^ Display extent
+ ].
^ virtualX@virtualY
"Created: / 22-11-2019 / 14:28:41 / Stefan Reise"
+ "Modified (format): / 25-11-2019 / 09:38:42 / Stefan Reise"
!
virtualMonitorResolutionByPoint:aPoint
@@ -7020,17 +7140,20 @@
|monitorName|
aPoint isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
monitorName := self monitorDeviceNameForPoint:aPoint.
monitorName isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
^ self virtualMonitorResolutionByMonitorDeviceName:monitorName
"Created: / 22-11-2019 / 14:28:55 / Stefan Reise"
+ "Modified: / 25-11-2019 / 09:37:34 / Stefan Reise"
!
virtualMonitorResolutionByView:aView
@@ -7057,17 +7180,20 @@
|monitorName|
aView isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
monitorName := self monitorDeviceNameForView:aView.
monitorName isNil ifTrue:[
- ^ nil
+ "return a default"
+ ^ Display extent
].
^ self virtualMonitorResolutionByMonitorDeviceName:monitorName
"Created: / 22-11-2019 / 14:29:09 / Stefan Reise"
+ "Modified: / 25-11-2019 / 09:37:38 / Stefan Reise"
! !
!WinWorkstation methodsFor:'accessing & queries'!