From 71bb081645d75f830a6b71410defc12c41b54ad9 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Fri, 7 Feb 2025 10:11:06 +0000 Subject: [PATCH] game_window: respect per-monitor DPI scale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: DarĂ­o <538504+DarioSamo@users.noreply.github.com> --- UnleashedRecomp/CMakeLists.txt | 8 +++++--- UnleashedRecomp/ui/game_window.cpp | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 41285d4..09012d7 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -351,10 +351,12 @@ file(CHMOD ${DIRECTX_DXC_TOOL} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) if (WIN32) target_link_libraries(UnleashedRecomp PRIVATE - comctl32 - ntdll - winmm + comctl32 + dwmapi + ntdll + Shcore Synchronization + winmm ) endif() diff --git a/UnleashedRecomp/ui/game_window.cpp b/UnleashedRecomp/ui/game_window.cpp index cd6fac9..1297c3b 100644 --- a/UnleashedRecomp/ui/game_window.cpp +++ b/UnleashedRecomp/ui/game_window.cpp @@ -9,7 +9,7 @@ #if _WIN32 #include -#pragma comment(lib, "dwmapi.lib") +#include #endif #include @@ -184,7 +184,7 @@ void GameWindow::Init(const char* sdlVideoDriver) SDL_AddEventWatch(Window_OnSDLEvent, s_pWindow); #ifdef _WIN32 - SetProcessDPIAware(); + SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); #endif Config::WindowSize.LockCallback = [](ConfigDef* def) @@ -442,7 +442,7 @@ void GameWindow::ResetDimensions() uint32_t GameWindow::GetWindowFlags() { - uint32_t flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE; + uint32_t flags = SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; if (Config::WindowState == EWindowState::Maximised) flags |= SDL_WINDOW_MAXIMIZED;