diff options
author | Christian Walther | 2021-06-16 10:27:49 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2021-06-17 04:48:57 +0000 |
commit | 3ba28b7d220540aa3e73c37aaf43a9dfee38e1fd (patch) | |
tree | 245929be5d7718c3d024d3440ba731734ae22fa1 | |
parent | 77fda35b312c6da5c6ce1530829804f7512bae7c (diff) | |
download | rt.equinox.framework-3ba28b7d220540aa3e73c37aaf43a9dfee38e1fd.tar.gz rt.equinox.framework-3ba28b7d220540aa3e73c37aaf43a9dfee38e1fd.tar.xz rt.equinox.framework-3ba28b7d220540aa3e73c37aaf43a9dfee38e1fd.zip |
Bug 574245 - [Win32] Fix splash size with swt.autoScale=exact
Take into account the -Dswt.autoScale vmarg in the same way SWT does
so the splash screen is correctly sized for what SWT will later draw
into it.
This effectively brings the scaling logic back in sync with
org.eclipse.swt.internal.DPIUtil.
Change-Id: I4936670206237f1f2ba7c37855bcb19ddb4822f9
Signed-off-by: Christian Walther <walther@indel.ch>
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/182059
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
Tested-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
Reviewed-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r-- | features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c index 72d46a06c..e843758aa 100644 --- a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c +++ b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c @@ -52,6 +52,17 @@ static _TCHAR** openFilePath; /* Define the window system arguments for the Java VM. */ static _TCHAR* argVM[] = { NULL }; +/* Define the SWT auto-scale setting for the splash screen. */ +enum { + AUTOSCALE_DEFAULT = -1, + AUTOSCALE_FALSE = -2, + AUTOSCALE_QUARTER = -3, + AUTOSCALE_EXACT = -4, + AUTOSCALE_INTEGER = -5 + /* positive values indicate a literal percentage */ +}; +static int autoScaleValue = AUTOSCALE_DEFAULT; + /* Define local variables for running the JVM and detecting its exit. */ static HANDLE jvmProcess = 0; static JavaResults* jvmResults = NULL; @@ -226,10 +237,29 @@ int showSplash( const _TCHAR* featureImage ) hDC = GetDC( NULL); depth = GetDeviceCaps( hDC, BITSPIXEL ) * GetDeviceCaps( hDC, PLANES); - /* fetch screen DPI and round it to 100% multiples, + /* fetch screen DPI and round it according to the swt.autoScale setting, this implementation needs to be kept in sync with org.eclipse.swt.internal.DPIUtil#setDeviceZoom(int) */ dpiX = GetDeviceCaps ( hDC, LOGPIXELSX ); - dpiX = ((int)((dpiX + 24) / 96 )) * 96; + switch (autoScaleValue) { + case AUTOSCALE_FALSE: + dpiX = 96; + break; + case AUTOSCALE_QUARTER: + dpiX = ((dpiX + 12) / 24) * 24; + break; + case AUTOSCALE_EXACT: + break; + case AUTOSCALE_DEFAULT: + case AUTOSCALE_INTEGER: + dpiX = ((int)((dpiX + 24) / 96 )) * 96; + if (autoScaleValue == AUTOSCALE_DEFAULT) { + if (dpiX > 192) dpiX = 192; + } + break; + default: + dpiX = (dpiX * autoScaleValue + 50) / 100; + break; + } ReleaseDC(NULL, hDC); if (featureImage != NULL) @@ -611,7 +641,37 @@ static void CALLBACK detectJvmExit( HWND hwnd, UINT uMsg, UINT id, DWORD dwTime } void processVMArgs(_TCHAR **vmargs[] ) { - /* nothing yet */ + _TCHAR** arg; + for (arg = *vmargs; *arg != NULL; arg++) { + if (_tcsncmp(*arg, _T("-Dswt.autoScale="), 16) == 0) { + // see org.eclipse.swt.internal.DPIUtil.getZoomForAutoscaleProperty() + _TCHAR* value = *arg + 16; + if (_tcsicmp(value, _T("false")) == 0) { + autoScaleValue = AUTOSCALE_FALSE; + } + else if (_tcsicmp(value, _T("quarter")) == 0) { + autoScaleValue = AUTOSCALE_QUARTER; + } + else if (_tcsicmp(value, _T("exact")) == 0) { + autoScaleValue = AUTOSCALE_EXACT; + } + else if (_tcsicmp(value, _T("integer")) == 0) { + autoScaleValue = AUTOSCALE_INTEGER; + } + else { + _TCHAR* end = NULL; + autoScaleValue = (int)_tcstol(value, &end, 10); + if (end == NULL || *end != _T('\0')) { + /* conversion error, reset to default */ + autoScaleValue = AUTOSCALE_DEFAULT; + } + else { + if (autoScaleValue < 25) autoScaleValue = 25; + else if (autoScaleValue > 1600) autoScaleValue = 1600; + } + } + } + } } JavaResults* startJavaVM( _TCHAR* libPath, _TCHAR* vmArgs[], _TCHAR* progArgs[], _TCHAR* jarFile ) |