From 7fa3827ceb8969d31a1db12eb2ec49ab39016263 Mon Sep 17 00:00:00 2001 From: Sravan Kumar Lakkimsetti Date: Wed, 11 May 2016 16:04:27 +0530 Subject: Bug 493797 - [HiDPI][Win32][GTK] Adapts Launcher to 'integer' scaling which is default for Eclipse/SWT Change-Id: Ie2fa7b5c8e65216d3852bb1daee60be06e0f8927 Signed-off-by: Sravan Kumar Lakkimsetti --- .../library/gtk/eclipseGtk.c | 4 ++-- .../library/win32/eclipseWin.c | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtk.c b/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtk.c index 2b25cc61e..361c3d098 100644 --- a/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtk.c +++ b/features/org.eclipse.equinox.executable.feature/library/gtk/eclipseGtk.c @@ -235,8 +235,8 @@ float scaleFactor () screen = gtk.gdk_screen_get_default(); resolution = gtk.gdk_screen_get_resolution (screen); if (resolution <= 0) resolution = 96; // in unix and windows 100% corresponds to dpi of 96 - resolution = ((int)(resolution/24 + 0.5)) * 24; //rounding the resolution to 25% multiples, 25% of 96 is 24. - scaleFactor = (float)(resolution/96); + resolution = ((int)((resolution + 24) / 96)) * 96; //rounding the resolution to 100% multiples,this implementation needs to be kept in sync with org.eclipse.swt.internal.DPIUtil#setDeviceZoom(int) + scaleFactor = (float)(resolution / 96); return scaleFactor; } /* Create and Display the Splash Window */ 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 4af33336c..9fdcea04c 100644 --- a/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c +++ b/features/org.eclipse.equinox.executable.feature/library/win32/eclipseWin.c @@ -221,9 +221,10 @@ int showSplash( const _TCHAR* featureImage ) hDC = GetDC( NULL); depth = GetDeviceCaps( hDC, BITSPIXEL ) * GetDeviceCaps( hDC, PLANES); - /* fetch screen DPI and round it to closest 25% interval(25% of 96 is 24) */ + /* fetch screen DPI and round it to 100% multiples, + this implementation needs to be kept in sync with org.eclipse.swt.internal.DPIUtil#setDeviceZoom(int) */ dpiX = GetDeviceCaps ( hDC, LOGPIXELSX ); - dpiX = ((int)(dpiX / 24.f + 0.5)) * 24; + dpiX = ((int)((dpiX + 24) / 96 )) * 96; ReleaseDC(NULL, hDC); if (featureImage != NULL) @@ -236,10 +237,10 @@ int showSplash( const _TCHAR* featureImage ) GetObject(hBitmap, sizeof(BITMAP), &bmp); /* reload scaled up image when zoom > 100% */ - if (dpiX > 96.f) { + if (dpiX > 96) { /* calculate scaled-up bounds */ - scaledWidth = dpiX * bmp.bmWidth / 96.f; - scaledHeight = dpiX * bmp.bmHeight / 96.f; + scaledWidth = dpiX * bmp.bmWidth / 96; + scaledHeight = dpiX * bmp.bmHeight / 96; hBitmap = LoadImage(NULL, featureImage, IMAGE_BITMAP, scaledWidth, scaledHeight, LR_LOADFROMFILE); -- cgit v1.2.3