summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2010-03-23 04:45:37 -0500
committerJon TURNEY <jon.turney@dronecode.org.uk>2010-08-13 14:59:04 +0100
commit03cdc9df6fc33cd3af0227b2c962125dd0cb3de3 (patch)
tree922d438ed5ca4c7578da9c93e2f2ca87e56c1fea
parentf2595bd23994afa0f1997129f395c6b294733d8f (diff)
Cygwin/X: Make default DPI match native DPI
Make the default DPI match the current Windows DPI setting. If that setting can't be retrieved, change the fallback DPI value from 75 dpi to 96 dpi. Mark the application as dpiAware in the manifest, which prevents dpi virtualization for high (>96) dpi values on Vista and later. Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
-rwxr-xr-xhw/xwin/XWin.exe.manifest5
-rw-r--r--hw/xwin/win.h2
-rwxr-xr-xhw/xwin/winprocarg.c23
3 files changed, 25 insertions, 5 deletions
diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 221150d52..a0d4d7dae 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -13,4 +13,9 @@
/>
</dependentAssembly>
</dependency>
+ <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+ <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+ <dpiAware>true</dpiAware>
+ </asmv3:windowsSettings>
+ </asmv3:application>
</assembly>
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index b7661ded1..64e3a8814 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -64,7 +64,7 @@
#define WIN_DEFAULT_BLACKPIXEL 0
#define WIN_DEFAULT_LINEBIAS 0
#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
-#define WIN_DEFAULT_DPI 75
+#define WIN_DEFAULT_DPI 96
#define WIN_DEFAULT_REFRESH 0
#define WIN_DEFAULT_WIN_KILL TRUE
#define WIN_DEFAULT_UNIX_KILL FALSE
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 66a0503f2..8880f30da 100755
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -156,12 +156,27 @@ winInitializeScreenDefaults(void)
dwWidth = GetSystemMetrics (SM_CXSCREEN);
dwHeight = GetSystemMetrics (SM_CYSCREEN);
- winErrorFVerb (2, "winInitializeScreenDefaults - w %d h %d\n",
- (int) dwWidth, (int) dwHeight);
+ winErrorFVerb(2, "winInitializeScreenDefaults - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
- /* Set a default DPI, if no parameter was passed */
+ /* Set a default DPI, if no '-dpi' option was used */
if (monitorResolution == 0)
- monitorResolution = WIN_DEFAULT_DPI;
+ {
+ HDC hdc = GetDC(NULL);
+ if (hdc)
+ {
+ int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+ int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+ winErrorFVerb(2, "winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
+ monitorResolution = dpiY;
+ ReleaseDC(NULL, hdc);
+ }
+ else
+ {
+ winErrorFVerb(1, "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
+ monitorResolution = WIN_DEFAULT_DPI;
+ }
+ }
defaultScreenInfo.dwWidth = dwWidth;
defaultScreenInfo.dwHeight = dwHeight;