summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2015-06-03 19:44:25 +0100
committerRobin Watts <Robin.Watts@artifex.com>2015-06-03 20:23:39 +0100
commit36316b400e48e0ee64ee1a016c8bde68785b7dc0 (patch)
tree8449b6e5ad2dbd56d4445d139134a2d93d852f5d /platform/x11
parent3df425033f3d214470c013930336be3af32955c1 (diff)
downloadmupdf-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')
-rw-r--r--platform/x11/pdfapp.c5
-rw-r--r--platform/x11/pdfapp.h1
-rw-r--r--platform/x11/win_main.c24
3 files changed, 30 insertions, 0 deletions
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index c6bbdd3c..3d796e47 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -134,6 +134,11 @@ void pdfapp_init(fz_context *ctx, pdfapp_t *app)
app->tint_b = 240;
}
+void pdfapp_setresolution(pdfapp_t *app, int res)
+{
+ app->resolution = res;
+}
+
void pdfapp_invert(pdfapp_t *app, const fz_rect *rect)
{
fz_irect b;
diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h
index 1bac5872..e3633577 100644
--- a/platform/x11/pdfapp.h
+++ b/platform/x11/pdfapp.h
@@ -141,6 +141,7 @@ struct pdfapp_s
};
void pdfapp_init(fz_context *ctx, pdfapp_t *app);
+void pdfapp_setresolution(pdfapp_t *app, int res);
void pdfapp_open(pdfapp_t *app, char *filename, int reload);
void pdfapp_open_progressive(pdfapp_t *app, char *filename, int reload, int bps);
void pdfapp_close(pdfapp_t *app);
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);