diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-06-03 19:44:25 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2015-06-03 20:23:39 +0100 |
commit | 36316b400e48e0ee64ee1a016c8bde68785b7dc0 (patch) | |
tree | 8449b6e5ad2dbd56d4445d139134a2d93d852f5d /platform/x11/win_main.c | |
parent | 3df425033f3d214470c013930336be3af32955c1 (diff) | |
download | mupdf-36316b400e48e0ee64ee1a016c8bde68785b7dc0.tar.xz |
Fix Windows 8.1 operation on hi-dpi displays.
MuPDF only.
Call SetProcessDPIAware if it's available; this stops Windows
doing its own horrible scaling causing blurriness.
Also, interrogate the screen display to get the real dpi and use that
as our basis.
Diffstat (limited to 'platform/x11/win_main.c')
-rw-r--r-- | platform/x11/win_main.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/platform/x11/win_main.c b/platform/x11/win_main.c index d24c9c3a..40d91004 100644 --- a/platform/x11/win_main.c +++ b/platform/x11/win_main.c @@ -1169,6 +1169,28 @@ viewproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, message, wParam, lParam); } +typedef BOOL (SetProcessDPIAwareFn)(void); + +static int +get_system_dpi(void) +{ + HMODULE hUser32 = LoadLibrary(TEXT("user32.dll")); + SetProcessDPIAwareFn *ptr; + int hdpi, vdpi; + HDC desktopDC; + + ptr = (SetProcessDPIAwareFn *)GetProcAddress(hUser32, "SetProcessDPIAware"); + if (ptr != NULL) + ptr(); + FreeLibrary(hUser32); + + desktopDC = GetDC(NULL); + hdpi = GetDeviceCaps(desktopDC, LOGPIXELSX); + vdpi = GetDeviceCaps(desktopDC, LOGPIXELSY); + /* hdpi,vdpi = 100 means 96dpi. */ + return ((hdpi + vdpi) * 96.0 + 0.5) / 200; +} + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { @@ -1180,6 +1202,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow fz_context *ctx; int arg; int bps = 0; + int displayRes = get_system_dpi(); ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT); if (!ctx) @@ -1188,6 +1211,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow exit(1); } pdfapp_init(ctx, &gapp); + pdfapp_setresolution(&gapp, displayRes); GetModuleFileNameA(NULL, argv0, sizeof argv0); install_app(argv0); |