From f0c7e9bdfa70bbb233ff0a57ae0bbcb150dc473b Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 19 Jul 2021 19:26:59 -0400 Subject: [PATCH] [host] windows: declare high DPI support in manifest This is the normal way of doing things, and it's easier and less sketchy than GetProcAddress. --- host/platform/Windows/app.manifest | 8 +++++++- host/platform/Windows/src/platform.c | 13 +------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/host/platform/Windows/app.manifest b/host/platform/Windows/app.manifest index 3b536185..4026a810 100644 --- a/host/platform/Windows/app.manifest +++ b/host/platform/Windows/app.manifest @@ -1,5 +1,5 @@ - + Looking Glass (host) @@ -9,4 +9,10 @@ + + + true + PerMonitorV2 + + diff --git a/host/platform/Windows/src/platform.c b/host/platform/Windows/src/platform.c index 10b86a9d..3b6834be 100644 --- a/host/platform/Windows/src/platform.c +++ b/host/platform/Windows/src/platform.c @@ -400,18 +400,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // setup a handler for ctrl+c SetConsoleCtrlHandler(CtrlHandler, TRUE); - // enable high DPI awareness - // this is required for DXGI 1.5 support to function and also capturing desktops with high DPI - DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); - #define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) - typedef BOOL (*User32_SetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT value); - - HMODULE user32 = GetModuleHandle("user32.dll"); - User32_SetProcessDpiAwarenessContext fn; - fn = (User32_SetProcessDpiAwarenessContext)GetProcAddress(user32, "SetProcessDpiAwarenessContext"); - if (fn) - fn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); - // create a message window so that our message pump works WNDCLASSEX wx = {}; wx.cbSize = sizeof(WNDCLASSEX); @@ -437,6 +425,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine app.exitThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // this is needed so that unprivileged processes can send us this message + HMODULE user32 = GetModuleHandle("user32.dll"); _ChangeWindowMessageFilterEx = (PChangeWindowMessageFilterEx)GetProcAddress(user32, "ChangeWindowMessageFilterEx"); if (_ChangeWindowMessageFilterEx) _ChangeWindowMessageFilterEx(app.messageWnd, app.trayRestartMsg, MSGFLT_ALLOW, NULL);